diff --git a/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java new file mode 100644 index 0000000..634ceae --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java @@ -0,0 +1,46 @@ +package com.casic.accessControl.app.domain; + +import javax.persistence.*; +import java.util.Date; + +/** + * app的版本信息 + */ +//工单 +@Entity +@Table(name = "apkVersion") +public class ApkVersion { + private String version; + private String path; + private Date ts;//时间戳 + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "version") + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + @Column(name = "path") + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + @Column(name = "ts") + public Date getTs() { + return ts; + } + + public void setTs(Date ts) { + this.ts = ts; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java new file mode 100644 index 0000000..634ceae --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java @@ -0,0 +1,46 @@ +package com.casic.accessControl.app.domain; + +import javax.persistence.*; +import java.util.Date; + +/** + * app的版本信息 + */ +//工单 +@Entity +@Table(name = "apkVersion") +public class ApkVersion { + private String version; + private String path; + private Date ts;//时间戳 + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "version") + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + @Column(name = "path") + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + @Column(name = "ts") + public Date getTs() { + return ts; + } + + public void setTs(Date ts) { + this.ts = ts; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java new file mode 100644 index 0000000..1d0242a --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java @@ -0,0 +1,50 @@ +package com.casic.accessControl.app.dto; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.util.TimeFormat; + +/** + * Created by lenovo on 2016/4/13. + */ +public class ApkVersionDto { + private String version; + private String path; + private String ts; + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public String getTs() { + return ts; + } + + public void setTs(String ts) { + this.ts = ts; + } + + public static ApkVersionDto Convert(ApkVersion version) { + if (version == null) { + return null; + } + ApkVersionDto versionDto = new ApkVersionDto(); + versionDto.setVersion(version.getVersion()); + versionDto.setPath(version.getVersion()); + versionDto.setTs(TimeFormat.formatTimestamp(version.getTs())); + + return versionDto; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java new file mode 100644 index 0000000..634ceae --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java @@ -0,0 +1,46 @@ +package com.casic.accessControl.app.domain; + +import javax.persistence.*; +import java.util.Date; + +/** + * app的版本信息 + */ +//工单 +@Entity +@Table(name = "apkVersion") +public class ApkVersion { + private String version; + private String path; + private Date ts;//时间戳 + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "version") + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + @Column(name = "path") + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + @Column(name = "ts") + public Date getTs() { + return ts; + } + + public void setTs(Date ts) { + this.ts = ts; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java new file mode 100644 index 0000000..1d0242a --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java @@ -0,0 +1,50 @@ +package com.casic.accessControl.app.dto; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.util.TimeFormat; + +/** + * Created by lenovo on 2016/4/13. + */ +public class ApkVersionDto { + private String version; + private String path; + private String ts; + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public String getTs() { + return ts; + } + + public void setTs(String ts) { + this.ts = ts; + } + + public static ApkVersionDto Convert(ApkVersion version) { + if (version == null) { + return null; + } + ApkVersionDto versionDto = new ApkVersionDto(); + versionDto.setVersion(version.getVersion()); + versionDto.setPath(version.getVersion()); + versionDto.setTs(TimeFormat.formatTimestamp(version.getTs())); + + return versionDto; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java b/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java new file mode 100644 index 0000000..28b12a7 --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java @@ -0,0 +1,27 @@ +package com.casic.accessControl.app.manager; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.core.hibernate.HibernateEntityDao; +import org.hibernate.Query; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * + */ +@Service("apkVersionManager") +public class ApkVersionManager extends HibernateEntityDao { + + public ApkVersion getLatestVersion() { + String sql = "from ApkVersion order by ts desc"; + Query query = getSession().createQuery(sql); + List list = query.list(); + if (null != list && list.isEmpty() == false) { + return list.get(0); + } + + return null; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java new file mode 100644 index 0000000..634ceae --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java @@ -0,0 +1,46 @@ +package com.casic.accessControl.app.domain; + +import javax.persistence.*; +import java.util.Date; + +/** + * app的版本信息 + */ +//工单 +@Entity +@Table(name = "apkVersion") +public class ApkVersion { + private String version; + private String path; + private Date ts;//时间戳 + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "version") + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + @Column(name = "path") + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + @Column(name = "ts") + public Date getTs() { + return ts; + } + + public void setTs(Date ts) { + this.ts = ts; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java new file mode 100644 index 0000000..1d0242a --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java @@ -0,0 +1,50 @@ +package com.casic.accessControl.app.dto; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.util.TimeFormat; + +/** + * Created by lenovo on 2016/4/13. + */ +public class ApkVersionDto { + private String version; + private String path; + private String ts; + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public String getTs() { + return ts; + } + + public void setTs(String ts) { + this.ts = ts; + } + + public static ApkVersionDto Convert(ApkVersion version) { + if (version == null) { + return null; + } + ApkVersionDto versionDto = new ApkVersionDto(); + versionDto.setVersion(version.getVersion()); + versionDto.setPath(version.getVersion()); + versionDto.setTs(TimeFormat.formatTimestamp(version.getTs())); + + return versionDto; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java b/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java new file mode 100644 index 0000000..28b12a7 --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java @@ -0,0 +1,27 @@ +package com.casic.accessControl.app.manager; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.core.hibernate.HibernateEntityDao; +import org.hibernate.Query; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * + */ +@Service("apkVersionManager") +public class ApkVersionManager extends HibernateEntityDao { + + public ApkVersion getLatestVersion() { + String sql = "from ApkVersion order by ts desc"; + Query query = getSession().createQuery(sql); + List list = query.list(); + if (null != list && list.isEmpty() == false) { + return list.get(0); + } + + return null; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java b/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java new file mode 100644 index 0000000..065d3cc --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java @@ -0,0 +1,66 @@ +package com.casic.accessControl.app.web; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.app.manager.ApkVersionManager; +import com.casic.accessControl.marker.domain.Marker; +import com.casic.accessControl.marker.manager.MarkerManager; +import com.casic.accessControl.task.domain.Task; +import com.casic.accessControl.task.domain.TaskDetail; +import com.casic.accessControl.task.dto.TaskDetailDto; +import com.casic.accessControl.task.dto.TaskDto; +import com.casic.accessControl.task.dto.TaskStatus; +import com.casic.accessControl.task.manager.TaskDetailManager; +import com.casic.accessControl.task.manager.TaskManager; +import com.casic.accessControl.user.domain.Company; +import com.casic.accessControl.user.domain.Role; +import com.casic.accessControl.user.domain.User; +import com.casic.accessControl.user.dto.UserDto; +import com.casic.accessControl.user.manager.RoleManager; +import com.casic.accessControl.user.manager.UserManager; +import com.casic.accessControl.util.DataTable; +import com.casic.accessControl.util.StringUtils; +import com.google.gson.Gson; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +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.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * Created by lenovo on 2016/4/13. + */ +@Controller +@RequestMapping("app") +public class ApkVersionController { + + @Resource + private ApkVersionManager apkVersionManager; + + @RequestMapping("get-latest-version") + @ResponseBody + public Map getLatestVersion(HttpServletResponse response, HttpSession session) { + Map result = new HashMap(); + try { + ApkVersion latest = apkVersionManager.getLatestVersion(); + if (null != latest) { + result.put("version", latest.getVersion()); + result.put("path", latest.getPath()); + } else { + result.put("version", "1.0.0"); + } + } catch (Exception e) { + e.printStackTrace(); + result.put("version", "1.0.0"); + } + + return result; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java new file mode 100644 index 0000000..634ceae --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java @@ -0,0 +1,46 @@ +package com.casic.accessControl.app.domain; + +import javax.persistence.*; +import java.util.Date; + +/** + * app的版本信息 + */ +//工单 +@Entity +@Table(name = "apkVersion") +public class ApkVersion { + private String version; + private String path; + private Date ts;//时间戳 + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "version") + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + @Column(name = "path") + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + @Column(name = "ts") + public Date getTs() { + return ts; + } + + public void setTs(Date ts) { + this.ts = ts; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java new file mode 100644 index 0000000..1d0242a --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java @@ -0,0 +1,50 @@ +package com.casic.accessControl.app.dto; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.util.TimeFormat; + +/** + * Created by lenovo on 2016/4/13. + */ +public class ApkVersionDto { + private String version; + private String path; + private String ts; + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public String getTs() { + return ts; + } + + public void setTs(String ts) { + this.ts = ts; + } + + public static ApkVersionDto Convert(ApkVersion version) { + if (version == null) { + return null; + } + ApkVersionDto versionDto = new ApkVersionDto(); + versionDto.setVersion(version.getVersion()); + versionDto.setPath(version.getVersion()); + versionDto.setTs(TimeFormat.formatTimestamp(version.getTs())); + + return versionDto; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java b/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java new file mode 100644 index 0000000..28b12a7 --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java @@ -0,0 +1,27 @@ +package com.casic.accessControl.app.manager; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.core.hibernate.HibernateEntityDao; +import org.hibernate.Query; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * + */ +@Service("apkVersionManager") +public class ApkVersionManager extends HibernateEntityDao { + + public ApkVersion getLatestVersion() { + String sql = "from ApkVersion order by ts desc"; + Query query = getSession().createQuery(sql); + List list = query.list(); + if (null != list && list.isEmpty() == false) { + return list.get(0); + } + + return null; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java b/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java new file mode 100644 index 0000000..065d3cc --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java @@ -0,0 +1,66 @@ +package com.casic.accessControl.app.web; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.app.manager.ApkVersionManager; +import com.casic.accessControl.marker.domain.Marker; +import com.casic.accessControl.marker.manager.MarkerManager; +import com.casic.accessControl.task.domain.Task; +import com.casic.accessControl.task.domain.TaskDetail; +import com.casic.accessControl.task.dto.TaskDetailDto; +import com.casic.accessControl.task.dto.TaskDto; +import com.casic.accessControl.task.dto.TaskStatus; +import com.casic.accessControl.task.manager.TaskDetailManager; +import com.casic.accessControl.task.manager.TaskManager; +import com.casic.accessControl.user.domain.Company; +import com.casic.accessControl.user.domain.Role; +import com.casic.accessControl.user.domain.User; +import com.casic.accessControl.user.dto.UserDto; +import com.casic.accessControl.user.manager.RoleManager; +import com.casic.accessControl.user.manager.UserManager; +import com.casic.accessControl.util.DataTable; +import com.casic.accessControl.util.StringUtils; +import com.google.gson.Gson; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +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.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * Created by lenovo on 2016/4/13. + */ +@Controller +@RequestMapping("app") +public class ApkVersionController { + + @Resource + private ApkVersionManager apkVersionManager; + + @RequestMapping("get-latest-version") + @ResponseBody + public Map getLatestVersion(HttpServletResponse response, HttpSession session) { + Map result = new HashMap(); + try { + ApkVersion latest = apkVersionManager.getLatestVersion(); + if (null != latest) { + result.put("version", latest.getVersion()); + result.put("path", latest.getPath()); + } else { + result.put("version", "1.0.0"); + } + } catch (Exception e) { + e.printStackTrace(); + result.put("version", "1.0.0"); + } + + return result; + } + +} diff --git a/src/main/java/com/casic/accessControl/marker/domain/Marker.java b/src/main/java/com/casic/accessControl/marker/domain/Marker.java index 0575cfe..7d5b854 100644 --- a/src/main/java/com/casic/accessControl/marker/domain/Marker.java +++ b/src/main/java/com/casic/accessControl/marker/domain/Marker.java @@ -67,6 +67,10 @@ private String area; @Column(name = "line") private String line; + @Column(name = "colorType") + private String colorType; + @Column(name = "photos") + private String photos; @@ -315,4 +319,20 @@ public void setArea(String area) { this.area = area; } + + public String getColorType() { + return colorType; + } + + public void setColorType(String colorType) { + this.colorType = colorType; + } + + public String getPhotos() { + return photos; + } + + public void setPhotos(String photos) { + this.photos = photos; + } } diff --git a/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java new file mode 100644 index 0000000..634ceae --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java @@ -0,0 +1,46 @@ +package com.casic.accessControl.app.domain; + +import javax.persistence.*; +import java.util.Date; + +/** + * app的版本信息 + */ +//工单 +@Entity +@Table(name = "apkVersion") +public class ApkVersion { + private String version; + private String path; + private Date ts;//时间戳 + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "version") + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + @Column(name = "path") + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + @Column(name = "ts") + public Date getTs() { + return ts; + } + + public void setTs(Date ts) { + this.ts = ts; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java new file mode 100644 index 0000000..1d0242a --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java @@ -0,0 +1,50 @@ +package com.casic.accessControl.app.dto; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.util.TimeFormat; + +/** + * Created by lenovo on 2016/4/13. + */ +public class ApkVersionDto { + private String version; + private String path; + private String ts; + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public String getTs() { + return ts; + } + + public void setTs(String ts) { + this.ts = ts; + } + + public static ApkVersionDto Convert(ApkVersion version) { + if (version == null) { + return null; + } + ApkVersionDto versionDto = new ApkVersionDto(); + versionDto.setVersion(version.getVersion()); + versionDto.setPath(version.getVersion()); + versionDto.setTs(TimeFormat.formatTimestamp(version.getTs())); + + return versionDto; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java b/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java new file mode 100644 index 0000000..28b12a7 --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java @@ -0,0 +1,27 @@ +package com.casic.accessControl.app.manager; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.core.hibernate.HibernateEntityDao; +import org.hibernate.Query; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * + */ +@Service("apkVersionManager") +public class ApkVersionManager extends HibernateEntityDao { + + public ApkVersion getLatestVersion() { + String sql = "from ApkVersion order by ts desc"; + Query query = getSession().createQuery(sql); + List list = query.list(); + if (null != list && list.isEmpty() == false) { + return list.get(0); + } + + return null; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java b/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java new file mode 100644 index 0000000..065d3cc --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java @@ -0,0 +1,66 @@ +package com.casic.accessControl.app.web; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.app.manager.ApkVersionManager; +import com.casic.accessControl.marker.domain.Marker; +import com.casic.accessControl.marker.manager.MarkerManager; +import com.casic.accessControl.task.domain.Task; +import com.casic.accessControl.task.domain.TaskDetail; +import com.casic.accessControl.task.dto.TaskDetailDto; +import com.casic.accessControl.task.dto.TaskDto; +import com.casic.accessControl.task.dto.TaskStatus; +import com.casic.accessControl.task.manager.TaskDetailManager; +import com.casic.accessControl.task.manager.TaskManager; +import com.casic.accessControl.user.domain.Company; +import com.casic.accessControl.user.domain.Role; +import com.casic.accessControl.user.domain.User; +import com.casic.accessControl.user.dto.UserDto; +import com.casic.accessControl.user.manager.RoleManager; +import com.casic.accessControl.user.manager.UserManager; +import com.casic.accessControl.util.DataTable; +import com.casic.accessControl.util.StringUtils; +import com.google.gson.Gson; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +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.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * Created by lenovo on 2016/4/13. + */ +@Controller +@RequestMapping("app") +public class ApkVersionController { + + @Resource + private ApkVersionManager apkVersionManager; + + @RequestMapping("get-latest-version") + @ResponseBody + public Map getLatestVersion(HttpServletResponse response, HttpSession session) { + Map result = new HashMap(); + try { + ApkVersion latest = apkVersionManager.getLatestVersion(); + if (null != latest) { + result.put("version", latest.getVersion()); + result.put("path", latest.getPath()); + } else { + result.put("version", "1.0.0"); + } + } catch (Exception e) { + e.printStackTrace(); + result.put("version", "1.0.0"); + } + + return result; + } + +} diff --git a/src/main/java/com/casic/accessControl/marker/domain/Marker.java b/src/main/java/com/casic/accessControl/marker/domain/Marker.java index 0575cfe..7d5b854 100644 --- a/src/main/java/com/casic/accessControl/marker/domain/Marker.java +++ b/src/main/java/com/casic/accessControl/marker/domain/Marker.java @@ -67,6 +67,10 @@ private String area; @Column(name = "line") private String line; + @Column(name = "colorType") + private String colorType; + @Column(name = "photos") + private String photos; @@ -315,4 +319,20 @@ public void setArea(String area) { this.area = area; } + + public String getColorType() { + return colorType; + } + + public void setColorType(String colorType) { + this.colorType = colorType; + } + + public String getPhotos() { + return photos; + } + + public void setPhotos(String photos) { + this.photos = photos; + } } diff --git a/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java b/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java index 506f31d..c5f8cf5 100644 --- a/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java +++ b/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java @@ -2,12 +2,12 @@ //import com.casic.accessControl.feature.domain.Feature; import com.casic.accessControl.marker.domain.Marker; +import com.casic.accessControl.util.StringUtils; +import com.casic.accessControl.util.TimeFormat; import org.apache.commons.collections.CollectionUtils; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.List; +import java.text.ParseException; +import java.util.*; /** * Created by lenovo on 2016/5/16. @@ -43,6 +43,8 @@ private Long userId; private String area; private String line; + private String colorType; + private String photos; private String btnEdit = "编辑"; private String btnDelete = "删除"; @@ -296,6 +298,23 @@ this.area = area; } + public String getColorType() { + if (StringUtils.isEmpty(colorType)) return "0"; + return colorType; + } + + public void setColorType(String colorType) { + this.colorType = colorType; + } + + public String getPhotos() { + return photos; + } + + public void setPhotos(String photos) { + this.photos = photos; + } + public String getLine() { return line; } @@ -335,6 +354,52 @@ result.setRoad(doNullChange(marker.getRoad())); result.setArea(doNullChange(marker.getArea())); result.setLine(doNullChange(marker.getLine())); + result.setColorType(marker.getColorType()); + result.setPhotos(marker.getPhotos()); + return result; + } + + public static Marker convert2Marker(MarkerDto markerDto) { + if (markerDto == null) return null; + Marker result = new Marker(); + if(markerDto.getLongitude()==null||markerDto.getLatitude()==null) return null; + if (null != markerDto.getCreateTime() && markerDto.getCreateTime().length() == 19) { + try { + result.setCreateTime(TimeFormat.parse(markerDto.getCreateTime(), "yyyy-MM-dd HH:mm:ss")); + } catch (ParseException pex) { + result.setCreateTime(Calendar.getInstance().getTime()); + } + } else { + result.setCreateTime(Calendar.getInstance().getTime()); + } + result.setDepth(doNullChange(markerDto.getDepth())); + result.setId(markerDto.getId()); + result.setLatitude(markerDto.getLatitude()); + result.setLongitude(markerDto.getLongitude()); + result.setMarkerId(markerDto.getMarkerId()); + result.setMarkerDepth(doNullChange(markerDto.getMarkerDepth())); + result.setMarkerObjectId(doNullChange(markerDto.getMarkerObjectId())); + result.setMarkerObjectType(doNullChange(markerDto.getMarkerObjectType())); + result.setOwnerComp(doNullChange(markerDto.getOwnerComp())); + result.setIsValid(markerDto.getIsValid()); + result.setMemo(doNullChange(markerDto.getMemo())); + result.setPipeDiameter(doNullChange(markerDto.getPipeDiameter())); + result.setPipeMaterial(doNullChange(markerDto.getPipeMaterial())); + result.setMarkerType(doNullChange(markerDto.getMarkerType())); + result.setCreator(doNullChange(markerDto.getCreator())); + + result.setLayStyle(doNullChange(markerDto.getLayStyle())); + result.setBelowDepth(doNullChange(markerDto.getBelowDepth())); + result.setBelowDiameter(doNullChange(markerDto.getBelowDiameter())); + result.setBelowMaterial(doNullChange(markerDto.getBelowMaterial())); + result.setBelowType(doNullChange(markerDto.getBelowType())); + result.setConstructTime(doNullChange(markerDto.getConstructTime())); + result.setRecordType(markerDto.getRecordType()); + result.setRoad(doNullChange(markerDto.getRoad())); + result.setArea(doNullChange(markerDto.getArea())); + result.setLine(doNullChange(markerDto.getLine())); + result.setColorType(markerDto.getColorType()); + result.setPhotos(markerDto.getPhotos()); return result; } diff --git a/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java new file mode 100644 index 0000000..634ceae --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java @@ -0,0 +1,46 @@ +package com.casic.accessControl.app.domain; + +import javax.persistence.*; +import java.util.Date; + +/** + * app的版本信息 + */ +//工单 +@Entity +@Table(name = "apkVersion") +public class ApkVersion { + private String version; + private String path; + private Date ts;//时间戳 + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "version") + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + @Column(name = "path") + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + @Column(name = "ts") + public Date getTs() { + return ts; + } + + public void setTs(Date ts) { + this.ts = ts; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java new file mode 100644 index 0000000..1d0242a --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java @@ -0,0 +1,50 @@ +package com.casic.accessControl.app.dto; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.util.TimeFormat; + +/** + * Created by lenovo on 2016/4/13. + */ +public class ApkVersionDto { + private String version; + private String path; + private String ts; + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public String getTs() { + return ts; + } + + public void setTs(String ts) { + this.ts = ts; + } + + public static ApkVersionDto Convert(ApkVersion version) { + if (version == null) { + return null; + } + ApkVersionDto versionDto = new ApkVersionDto(); + versionDto.setVersion(version.getVersion()); + versionDto.setPath(version.getVersion()); + versionDto.setTs(TimeFormat.formatTimestamp(version.getTs())); + + return versionDto; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java b/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java new file mode 100644 index 0000000..28b12a7 --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java @@ -0,0 +1,27 @@ +package com.casic.accessControl.app.manager; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.core.hibernate.HibernateEntityDao; +import org.hibernate.Query; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * + */ +@Service("apkVersionManager") +public class ApkVersionManager extends HibernateEntityDao { + + public ApkVersion getLatestVersion() { + String sql = "from ApkVersion order by ts desc"; + Query query = getSession().createQuery(sql); + List list = query.list(); + if (null != list && list.isEmpty() == false) { + return list.get(0); + } + + return null; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java b/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java new file mode 100644 index 0000000..065d3cc --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java @@ -0,0 +1,66 @@ +package com.casic.accessControl.app.web; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.app.manager.ApkVersionManager; +import com.casic.accessControl.marker.domain.Marker; +import com.casic.accessControl.marker.manager.MarkerManager; +import com.casic.accessControl.task.domain.Task; +import com.casic.accessControl.task.domain.TaskDetail; +import com.casic.accessControl.task.dto.TaskDetailDto; +import com.casic.accessControl.task.dto.TaskDto; +import com.casic.accessControl.task.dto.TaskStatus; +import com.casic.accessControl.task.manager.TaskDetailManager; +import com.casic.accessControl.task.manager.TaskManager; +import com.casic.accessControl.user.domain.Company; +import com.casic.accessControl.user.domain.Role; +import com.casic.accessControl.user.domain.User; +import com.casic.accessControl.user.dto.UserDto; +import com.casic.accessControl.user.manager.RoleManager; +import com.casic.accessControl.user.manager.UserManager; +import com.casic.accessControl.util.DataTable; +import com.casic.accessControl.util.StringUtils; +import com.google.gson.Gson; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +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.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * Created by lenovo on 2016/4/13. + */ +@Controller +@RequestMapping("app") +public class ApkVersionController { + + @Resource + private ApkVersionManager apkVersionManager; + + @RequestMapping("get-latest-version") + @ResponseBody + public Map getLatestVersion(HttpServletResponse response, HttpSession session) { + Map result = new HashMap(); + try { + ApkVersion latest = apkVersionManager.getLatestVersion(); + if (null != latest) { + result.put("version", latest.getVersion()); + result.put("path", latest.getPath()); + } else { + result.put("version", "1.0.0"); + } + } catch (Exception e) { + e.printStackTrace(); + result.put("version", "1.0.0"); + } + + return result; + } + +} diff --git a/src/main/java/com/casic/accessControl/marker/domain/Marker.java b/src/main/java/com/casic/accessControl/marker/domain/Marker.java index 0575cfe..7d5b854 100644 --- a/src/main/java/com/casic/accessControl/marker/domain/Marker.java +++ b/src/main/java/com/casic/accessControl/marker/domain/Marker.java @@ -67,6 +67,10 @@ private String area; @Column(name = "line") private String line; + @Column(name = "colorType") + private String colorType; + @Column(name = "photos") + private String photos; @@ -315,4 +319,20 @@ public void setArea(String area) { this.area = area; } + + public String getColorType() { + return colorType; + } + + public void setColorType(String colorType) { + this.colorType = colorType; + } + + public String getPhotos() { + return photos; + } + + public void setPhotos(String photos) { + this.photos = photos; + } } diff --git a/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java b/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java index 506f31d..c5f8cf5 100644 --- a/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java +++ b/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java @@ -2,12 +2,12 @@ //import com.casic.accessControl.feature.domain.Feature; import com.casic.accessControl.marker.domain.Marker; +import com.casic.accessControl.util.StringUtils; +import com.casic.accessControl.util.TimeFormat; import org.apache.commons.collections.CollectionUtils; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.List; +import java.text.ParseException; +import java.util.*; /** * Created by lenovo on 2016/5/16. @@ -43,6 +43,8 @@ private Long userId; private String area; private String line; + private String colorType; + private String photos; private String btnEdit = "编辑"; private String btnDelete = "删除"; @@ -296,6 +298,23 @@ this.area = area; } + public String getColorType() { + if (StringUtils.isEmpty(colorType)) return "0"; + return colorType; + } + + public void setColorType(String colorType) { + this.colorType = colorType; + } + + public String getPhotos() { + return photos; + } + + public void setPhotos(String photos) { + this.photos = photos; + } + public String getLine() { return line; } @@ -335,6 +354,52 @@ result.setRoad(doNullChange(marker.getRoad())); result.setArea(doNullChange(marker.getArea())); result.setLine(doNullChange(marker.getLine())); + result.setColorType(marker.getColorType()); + result.setPhotos(marker.getPhotos()); + return result; + } + + public static Marker convert2Marker(MarkerDto markerDto) { + if (markerDto == null) return null; + Marker result = new Marker(); + if(markerDto.getLongitude()==null||markerDto.getLatitude()==null) return null; + if (null != markerDto.getCreateTime() && markerDto.getCreateTime().length() == 19) { + try { + result.setCreateTime(TimeFormat.parse(markerDto.getCreateTime(), "yyyy-MM-dd HH:mm:ss")); + } catch (ParseException pex) { + result.setCreateTime(Calendar.getInstance().getTime()); + } + } else { + result.setCreateTime(Calendar.getInstance().getTime()); + } + result.setDepth(doNullChange(markerDto.getDepth())); + result.setId(markerDto.getId()); + result.setLatitude(markerDto.getLatitude()); + result.setLongitude(markerDto.getLongitude()); + result.setMarkerId(markerDto.getMarkerId()); + result.setMarkerDepth(doNullChange(markerDto.getMarkerDepth())); + result.setMarkerObjectId(doNullChange(markerDto.getMarkerObjectId())); + result.setMarkerObjectType(doNullChange(markerDto.getMarkerObjectType())); + result.setOwnerComp(doNullChange(markerDto.getOwnerComp())); + result.setIsValid(markerDto.getIsValid()); + result.setMemo(doNullChange(markerDto.getMemo())); + result.setPipeDiameter(doNullChange(markerDto.getPipeDiameter())); + result.setPipeMaterial(doNullChange(markerDto.getPipeMaterial())); + result.setMarkerType(doNullChange(markerDto.getMarkerType())); + result.setCreator(doNullChange(markerDto.getCreator())); + + result.setLayStyle(doNullChange(markerDto.getLayStyle())); + result.setBelowDepth(doNullChange(markerDto.getBelowDepth())); + result.setBelowDiameter(doNullChange(markerDto.getBelowDiameter())); + result.setBelowMaterial(doNullChange(markerDto.getBelowMaterial())); + result.setBelowType(doNullChange(markerDto.getBelowType())); + result.setConstructTime(doNullChange(markerDto.getConstructTime())); + result.setRecordType(markerDto.getRecordType()); + result.setRoad(doNullChange(markerDto.getRoad())); + result.setArea(doNullChange(markerDto.getArea())); + result.setLine(doNullChange(markerDto.getLine())); + result.setColorType(markerDto.getColorType()); + result.setPhotos(markerDto.getPhotos()); return result; } diff --git a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java index dd0fa4b..ba5a1fb 100644 --- a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java +++ b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java @@ -9,10 +9,7 @@ import com.casic.accessControl.marker.domain.Marker; import com.casic.accessControl.user.domain.Company; import com.casic.accessControl.user.domain.User; -import com.casic.accessControl.util.DataTable; -import com.casic.accessControl.util.DataTableParameter; -import com.casic.accessControl.util.DataTableUtils; -import com.casic.accessControl.util.DateUtils; +import com.casic.accessControl.util.*; import com.google.gson.Gson; import jxl.*; import jxl.read.biff.BiffException; @@ -31,11 +28,15 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; +import sun.misc.BASE64Decoder; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.File; +import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.text.ParseException; @@ -183,6 +184,53 @@ } /** + * 保存标识器和图片信息 + * @param markerDto + * @param companyId + * @param fileNames + * @param fileBuffers + * @return + */ + public boolean saveMarkerAndPhotos(MarkerDto markerDto, Long companyId, String[] fileNames, String[] fileBuffers) { + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + String strDirPath = request.getSession().getServletContext().getRealPath(""); + FileOutputStream fos = null; + String month = TimeFormat.format(Calendar.getInstance().getTime(), "yyyyMM"); + String webPath = "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String toDir = strDirPath + "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String filePaths = ""; + try { + for (int i = 0; i < fileBuffers.length; i++) { + if (fileBuffers[i] != null && fileNames[i] != null) { +// filePaths += toDir+fileNames[i]+","; + filePaths += webPath + fileNames[i] + ","; + byte[] buffer = new BASE64Decoder().decodeBuffer(fileBuffers[i]); //对android传过来的图片字符串进行解码 + File destDir = new File(toDir); + if (!destDir.exists()) + destDir.mkdirs(); + File imageFile = new File(destDir, fileNames[i]); + fos = new FileOutputStream(imageFile); //保存图片 + fos.write(buffer); + fos.flush(); + fos.close(); + } + } + if (filePaths.endsWith(",")) { + filePaths = filePaths.substring(0, filePaths.length() - 1); + } + } catch (Exception e) { + return false; + } + Marker marker = MarkerDto.convert2Marker(markerDto); + marker.setIsValid(1); + marker.setCompanyId(companyId); + marker.setPhotos(filePaths); + save(marker); + return true; + + } + + /** * 新增标识器 8-9 * * @param markers @@ -582,7 +630,7 @@ "所属区域","所属线路","所属道路","建设年代","权属单位","标示对象ID", "标识器ID","标识器类型","标识器埋深","安装部门","经度", "纬度", "最后修改时间","备注","下层管种类", "下层管埋深", - "下层管直径", "下层管材料", "标识对象类别"}; + "下层管直径", "下层管材料", "标识对象类别", "标识点颜色", "图片地址"}; Label[][] labels = new Label[markerDtos.size() + 1][titleTxt.length]; for(int k=0;k { + + public ApkVersion getLatestVersion() { + String sql = "from ApkVersion order by ts desc"; + Query query = getSession().createQuery(sql); + List list = query.list(); + if (null != list && list.isEmpty() == false) { + return list.get(0); + } + + return null; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java b/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java new file mode 100644 index 0000000..065d3cc --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java @@ -0,0 +1,66 @@ +package com.casic.accessControl.app.web; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.app.manager.ApkVersionManager; +import com.casic.accessControl.marker.domain.Marker; +import com.casic.accessControl.marker.manager.MarkerManager; +import com.casic.accessControl.task.domain.Task; +import com.casic.accessControl.task.domain.TaskDetail; +import com.casic.accessControl.task.dto.TaskDetailDto; +import com.casic.accessControl.task.dto.TaskDto; +import com.casic.accessControl.task.dto.TaskStatus; +import com.casic.accessControl.task.manager.TaskDetailManager; +import com.casic.accessControl.task.manager.TaskManager; +import com.casic.accessControl.user.domain.Company; +import com.casic.accessControl.user.domain.Role; +import com.casic.accessControl.user.domain.User; +import com.casic.accessControl.user.dto.UserDto; +import com.casic.accessControl.user.manager.RoleManager; +import com.casic.accessControl.user.manager.UserManager; +import com.casic.accessControl.util.DataTable; +import com.casic.accessControl.util.StringUtils; +import com.google.gson.Gson; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +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.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * Created by lenovo on 2016/4/13. + */ +@Controller +@RequestMapping("app") +public class ApkVersionController { + + @Resource + private ApkVersionManager apkVersionManager; + + @RequestMapping("get-latest-version") + @ResponseBody + public Map getLatestVersion(HttpServletResponse response, HttpSession session) { + Map result = new HashMap(); + try { + ApkVersion latest = apkVersionManager.getLatestVersion(); + if (null != latest) { + result.put("version", latest.getVersion()); + result.put("path", latest.getPath()); + } else { + result.put("version", "1.0.0"); + } + } catch (Exception e) { + e.printStackTrace(); + result.put("version", "1.0.0"); + } + + return result; + } + +} diff --git a/src/main/java/com/casic/accessControl/marker/domain/Marker.java b/src/main/java/com/casic/accessControl/marker/domain/Marker.java index 0575cfe..7d5b854 100644 --- a/src/main/java/com/casic/accessControl/marker/domain/Marker.java +++ b/src/main/java/com/casic/accessControl/marker/domain/Marker.java @@ -67,6 +67,10 @@ private String area; @Column(name = "line") private String line; + @Column(name = "colorType") + private String colorType; + @Column(name = "photos") + private String photos; @@ -315,4 +319,20 @@ public void setArea(String area) { this.area = area; } + + public String getColorType() { + return colorType; + } + + public void setColorType(String colorType) { + this.colorType = colorType; + } + + public String getPhotos() { + return photos; + } + + public void setPhotos(String photos) { + this.photos = photos; + } } diff --git a/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java b/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java index 506f31d..c5f8cf5 100644 --- a/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java +++ b/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java @@ -2,12 +2,12 @@ //import com.casic.accessControl.feature.domain.Feature; import com.casic.accessControl.marker.domain.Marker; +import com.casic.accessControl.util.StringUtils; +import com.casic.accessControl.util.TimeFormat; import org.apache.commons.collections.CollectionUtils; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.List; +import java.text.ParseException; +import java.util.*; /** * Created by lenovo on 2016/5/16. @@ -43,6 +43,8 @@ private Long userId; private String area; private String line; + private String colorType; + private String photos; private String btnEdit = "编辑"; private String btnDelete = "删除"; @@ -296,6 +298,23 @@ this.area = area; } + public String getColorType() { + if (StringUtils.isEmpty(colorType)) return "0"; + return colorType; + } + + public void setColorType(String colorType) { + this.colorType = colorType; + } + + public String getPhotos() { + return photos; + } + + public void setPhotos(String photos) { + this.photos = photos; + } + public String getLine() { return line; } @@ -335,6 +354,52 @@ result.setRoad(doNullChange(marker.getRoad())); result.setArea(doNullChange(marker.getArea())); result.setLine(doNullChange(marker.getLine())); + result.setColorType(marker.getColorType()); + result.setPhotos(marker.getPhotos()); + return result; + } + + public static Marker convert2Marker(MarkerDto markerDto) { + if (markerDto == null) return null; + Marker result = new Marker(); + if(markerDto.getLongitude()==null||markerDto.getLatitude()==null) return null; + if (null != markerDto.getCreateTime() && markerDto.getCreateTime().length() == 19) { + try { + result.setCreateTime(TimeFormat.parse(markerDto.getCreateTime(), "yyyy-MM-dd HH:mm:ss")); + } catch (ParseException pex) { + result.setCreateTime(Calendar.getInstance().getTime()); + } + } else { + result.setCreateTime(Calendar.getInstance().getTime()); + } + result.setDepth(doNullChange(markerDto.getDepth())); + result.setId(markerDto.getId()); + result.setLatitude(markerDto.getLatitude()); + result.setLongitude(markerDto.getLongitude()); + result.setMarkerId(markerDto.getMarkerId()); + result.setMarkerDepth(doNullChange(markerDto.getMarkerDepth())); + result.setMarkerObjectId(doNullChange(markerDto.getMarkerObjectId())); + result.setMarkerObjectType(doNullChange(markerDto.getMarkerObjectType())); + result.setOwnerComp(doNullChange(markerDto.getOwnerComp())); + result.setIsValid(markerDto.getIsValid()); + result.setMemo(doNullChange(markerDto.getMemo())); + result.setPipeDiameter(doNullChange(markerDto.getPipeDiameter())); + result.setPipeMaterial(doNullChange(markerDto.getPipeMaterial())); + result.setMarkerType(doNullChange(markerDto.getMarkerType())); + result.setCreator(doNullChange(markerDto.getCreator())); + + result.setLayStyle(doNullChange(markerDto.getLayStyle())); + result.setBelowDepth(doNullChange(markerDto.getBelowDepth())); + result.setBelowDiameter(doNullChange(markerDto.getBelowDiameter())); + result.setBelowMaterial(doNullChange(markerDto.getBelowMaterial())); + result.setBelowType(doNullChange(markerDto.getBelowType())); + result.setConstructTime(doNullChange(markerDto.getConstructTime())); + result.setRecordType(markerDto.getRecordType()); + result.setRoad(doNullChange(markerDto.getRoad())); + result.setArea(doNullChange(markerDto.getArea())); + result.setLine(doNullChange(markerDto.getLine())); + result.setColorType(markerDto.getColorType()); + result.setPhotos(markerDto.getPhotos()); return result; } diff --git a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java index dd0fa4b..ba5a1fb 100644 --- a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java +++ b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java @@ -9,10 +9,7 @@ import com.casic.accessControl.marker.domain.Marker; import com.casic.accessControl.user.domain.Company; import com.casic.accessControl.user.domain.User; -import com.casic.accessControl.util.DataTable; -import com.casic.accessControl.util.DataTableParameter; -import com.casic.accessControl.util.DataTableUtils; -import com.casic.accessControl.util.DateUtils; +import com.casic.accessControl.util.*; import com.google.gson.Gson; import jxl.*; import jxl.read.biff.BiffException; @@ -31,11 +28,15 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; +import sun.misc.BASE64Decoder; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.File; +import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.text.ParseException; @@ -183,6 +184,53 @@ } /** + * 保存标识器和图片信息 + * @param markerDto + * @param companyId + * @param fileNames + * @param fileBuffers + * @return + */ + public boolean saveMarkerAndPhotos(MarkerDto markerDto, Long companyId, String[] fileNames, String[] fileBuffers) { + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + String strDirPath = request.getSession().getServletContext().getRealPath(""); + FileOutputStream fos = null; + String month = TimeFormat.format(Calendar.getInstance().getTime(), "yyyyMM"); + String webPath = "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String toDir = strDirPath + "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String filePaths = ""; + try { + for (int i = 0; i < fileBuffers.length; i++) { + if (fileBuffers[i] != null && fileNames[i] != null) { +// filePaths += toDir+fileNames[i]+","; + filePaths += webPath + fileNames[i] + ","; + byte[] buffer = new BASE64Decoder().decodeBuffer(fileBuffers[i]); //对android传过来的图片字符串进行解码 + File destDir = new File(toDir); + if (!destDir.exists()) + destDir.mkdirs(); + File imageFile = new File(destDir, fileNames[i]); + fos = new FileOutputStream(imageFile); //保存图片 + fos.write(buffer); + fos.flush(); + fos.close(); + } + } + if (filePaths.endsWith(",")) { + filePaths = filePaths.substring(0, filePaths.length() - 1); + } + } catch (Exception e) { + return false; + } + Marker marker = MarkerDto.convert2Marker(markerDto); + marker.setIsValid(1); + marker.setCompanyId(companyId); + marker.setPhotos(filePaths); + save(marker); + return true; + + } + + /** * 新增标识器 8-9 * * @param markers @@ -582,7 +630,7 @@ "所属区域","所属线路","所属道路","建设年代","权属单位","标示对象ID", "标识器ID","标识器类型","标识器埋深","安装部门","经度", "纬度", "最后修改时间","备注","下层管种类", "下层管埋深", - "下层管直径", "下层管材料", "标识对象类别"}; + "下层管直径", "下层管材料", "标识对象类别", "标识点颜色", "图片地址"}; Label[][] labels = new Label[markerDtos.size() + 1][titleTxt.length]; for(int k=0;k saveMarkerAndPhotos(@RequestParam(value = "fileBuffer1", required = false) MultipartFile fileBuffer1, + @RequestParam(value = "fileBuffer2", required = false) MultipartFile fileBuffer2, + @RequestParam(value = "fileBuffer3", required = false) MultipartFile fileBuffer3, + @RequestParam(value = "jsonMarker", required = true) String jsonMarker) { + Map map = new HashMap(); + map.put("message", "安装无标识器信息"); + Gson gson = new Gson(); + try { + MarkerDto marker = gson.fromJson(jsonMarker, MarkerDto.class); + + if (null == marker.getMarkerId()) { + map.put("message", "无标识器ID"); + map.put("success", "false"); + return map; + } else if (markerManager.getMarkerByMarkerId(marker.getMarkerId()).size() > 0) { + map.put("message", "已安装过该标识器[" + marker.getMarkerId() + "]"); + map.put("success", "false"); + return map; + } else { + String[] fileNames = new String[3]; + String[] fileBuffers = new String[3]; + if (fileBuffer1 != null) { + fileNames[0] = marker.getMarkerId() + "_" + fileBuffer1.getOriginalFilename(); + byte[] fis = fileBuffer1.getBytes(); + fileBuffers[0] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, com.sun.org.apache.xml.internal.security.utils.Base64.BASE64DEFAULTLENGTH)); + } + if (fileBuffer2 != null) { + fileNames[1] = marker.getMarkerId() + "_" + fileBuffer2.getOriginalFilename(); + byte[] fis = fileBuffer2.getBytes(); + fileBuffers[1] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, com.sun.org.apache.xml.internal.security.utils.Base64.BASE64DEFAULTLENGTH)); + } + if (fileBuffer3 != null) { + fileNames[2] = marker.getMarkerId() + "_" + fileBuffer3.getOriginalFilename(); + byte[] fis = fileBuffer3.getBytes(); + fileBuffers[2] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, Base64.BASE64DEFAULTLENGTH)); + } + Long companyId = marker.getCompanyId(); + if (companyId == null) { + return map; + } + boolean result = markerManager.saveMarkerAndPhotos(marker, companyId, fileNames, fileBuffers); + if (!result) { + return map; + } + } + } catch (Exception e) { + return map; + } + map.put("success", "true"); + map.put("message", "保存成功"); + return map; + } + + @RequestMapping("marker-info-delete") @ResponseBody public Map delete(@RequestParam(value = "id", required = true) Long id) { @@ -144,6 +208,9 @@ map.put("message", "删除需要ID信息"); return map; } + + System.out.println(ids); + markerManager.delMarkerByIds(ids); map.put("success", true); map.put("message", "删除成功"); @@ -240,6 +307,54 @@ return map; } + /** + * 批量上传标识点,用于无信号地区标识器信息统一上传,不修改已有标识点信息 + * @param strMarkers + * @return + */ + @RequestMapping("batch-save-no-update") + @ResponseBody + public Map batchSaveOrUpdate(@RequestParam(value = "markers", required = true) String strMarkers) { + strMarkers = strMarkers.replace('\n',' '); + Map map = new HashMap(); + map.put("message", "批量导入失败,或无导入标识器信息"); + Gson gson = new Gson(); + try { + List markers = gson.fromJson(strMarkers, new TypeToken>() { + }.getType()); + if (CollectionUtils.isEmpty(markers)) {//批量导入数据不存在,直接返回 + map.put("message", "批量导入数据不存在"); + return map; + } + + Long companyId = markers.get(0).getCompanyId(); + if (companyId == null) { + map.put("message", "未找到所属公司属性"); + return map; + } + + List markerDtoForSave = new ArrayList(); + for (MarkerDto markerDto : markers) { + // 上传marker的Id不为空且数据库中不存在记录,经纬度不为空,允许保存 + if (StringUtils.isNotBlank(markerDto.getMarkerId()) && markerManager.getMarkerByMarkerId(markerDto.getMarkerId()).size() <= 0) { + if (null != markerDto.getLongitude() && null != markerDto.getLatitude()) { + markerDtoForSave.add(markerDto); + } + } + } + boolean result = markerManager.batchSave(markerDtoForSave, companyId); + if (!result) { + return map; + } + } catch (Exception e) { + e.printStackTrace(); + return map; + } + map.put("success", true); + map.put("message", "保存成功"); + return map; + } + @RequestMapping("getMarkerListByCondition") @ResponseBody @POST diff --git a/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java new file mode 100644 index 0000000..634ceae --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java @@ -0,0 +1,46 @@ +package com.casic.accessControl.app.domain; + +import javax.persistence.*; +import java.util.Date; + +/** + * app的版本信息 + */ +//工单 +@Entity +@Table(name = "apkVersion") +public class ApkVersion { + private String version; + private String path; + private Date ts;//时间戳 + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "version") + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + @Column(name = "path") + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + @Column(name = "ts") + public Date getTs() { + return ts; + } + + public void setTs(Date ts) { + this.ts = ts; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java new file mode 100644 index 0000000..1d0242a --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java @@ -0,0 +1,50 @@ +package com.casic.accessControl.app.dto; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.util.TimeFormat; + +/** + * Created by lenovo on 2016/4/13. + */ +public class ApkVersionDto { + private String version; + private String path; + private String ts; + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public String getTs() { + return ts; + } + + public void setTs(String ts) { + this.ts = ts; + } + + public static ApkVersionDto Convert(ApkVersion version) { + if (version == null) { + return null; + } + ApkVersionDto versionDto = new ApkVersionDto(); + versionDto.setVersion(version.getVersion()); + versionDto.setPath(version.getVersion()); + versionDto.setTs(TimeFormat.formatTimestamp(version.getTs())); + + return versionDto; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java b/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java new file mode 100644 index 0000000..28b12a7 --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java @@ -0,0 +1,27 @@ +package com.casic.accessControl.app.manager; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.core.hibernate.HibernateEntityDao; +import org.hibernate.Query; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * + */ +@Service("apkVersionManager") +public class ApkVersionManager extends HibernateEntityDao { + + public ApkVersion getLatestVersion() { + String sql = "from ApkVersion order by ts desc"; + Query query = getSession().createQuery(sql); + List list = query.list(); + if (null != list && list.isEmpty() == false) { + return list.get(0); + } + + return null; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java b/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java new file mode 100644 index 0000000..065d3cc --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java @@ -0,0 +1,66 @@ +package com.casic.accessControl.app.web; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.app.manager.ApkVersionManager; +import com.casic.accessControl.marker.domain.Marker; +import com.casic.accessControl.marker.manager.MarkerManager; +import com.casic.accessControl.task.domain.Task; +import com.casic.accessControl.task.domain.TaskDetail; +import com.casic.accessControl.task.dto.TaskDetailDto; +import com.casic.accessControl.task.dto.TaskDto; +import com.casic.accessControl.task.dto.TaskStatus; +import com.casic.accessControl.task.manager.TaskDetailManager; +import com.casic.accessControl.task.manager.TaskManager; +import com.casic.accessControl.user.domain.Company; +import com.casic.accessControl.user.domain.Role; +import com.casic.accessControl.user.domain.User; +import com.casic.accessControl.user.dto.UserDto; +import com.casic.accessControl.user.manager.RoleManager; +import com.casic.accessControl.user.manager.UserManager; +import com.casic.accessControl.util.DataTable; +import com.casic.accessControl.util.StringUtils; +import com.google.gson.Gson; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +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.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * Created by lenovo on 2016/4/13. + */ +@Controller +@RequestMapping("app") +public class ApkVersionController { + + @Resource + private ApkVersionManager apkVersionManager; + + @RequestMapping("get-latest-version") + @ResponseBody + public Map getLatestVersion(HttpServletResponse response, HttpSession session) { + Map result = new HashMap(); + try { + ApkVersion latest = apkVersionManager.getLatestVersion(); + if (null != latest) { + result.put("version", latest.getVersion()); + result.put("path", latest.getPath()); + } else { + result.put("version", "1.0.0"); + } + } catch (Exception e) { + e.printStackTrace(); + result.put("version", "1.0.0"); + } + + return result; + } + +} diff --git a/src/main/java/com/casic/accessControl/marker/domain/Marker.java b/src/main/java/com/casic/accessControl/marker/domain/Marker.java index 0575cfe..7d5b854 100644 --- a/src/main/java/com/casic/accessControl/marker/domain/Marker.java +++ b/src/main/java/com/casic/accessControl/marker/domain/Marker.java @@ -67,6 +67,10 @@ private String area; @Column(name = "line") private String line; + @Column(name = "colorType") + private String colorType; + @Column(name = "photos") + private String photos; @@ -315,4 +319,20 @@ public void setArea(String area) { this.area = area; } + + public String getColorType() { + return colorType; + } + + public void setColorType(String colorType) { + this.colorType = colorType; + } + + public String getPhotos() { + return photos; + } + + public void setPhotos(String photos) { + this.photos = photos; + } } diff --git a/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java b/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java index 506f31d..c5f8cf5 100644 --- a/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java +++ b/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java @@ -2,12 +2,12 @@ //import com.casic.accessControl.feature.domain.Feature; import com.casic.accessControl.marker.domain.Marker; +import com.casic.accessControl.util.StringUtils; +import com.casic.accessControl.util.TimeFormat; import org.apache.commons.collections.CollectionUtils; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.List; +import java.text.ParseException; +import java.util.*; /** * Created by lenovo on 2016/5/16. @@ -43,6 +43,8 @@ private Long userId; private String area; private String line; + private String colorType; + private String photos; private String btnEdit = "编辑"; private String btnDelete = "删除"; @@ -296,6 +298,23 @@ this.area = area; } + public String getColorType() { + if (StringUtils.isEmpty(colorType)) return "0"; + return colorType; + } + + public void setColorType(String colorType) { + this.colorType = colorType; + } + + public String getPhotos() { + return photos; + } + + public void setPhotos(String photos) { + this.photos = photos; + } + public String getLine() { return line; } @@ -335,6 +354,52 @@ result.setRoad(doNullChange(marker.getRoad())); result.setArea(doNullChange(marker.getArea())); result.setLine(doNullChange(marker.getLine())); + result.setColorType(marker.getColorType()); + result.setPhotos(marker.getPhotos()); + return result; + } + + public static Marker convert2Marker(MarkerDto markerDto) { + if (markerDto == null) return null; + Marker result = new Marker(); + if(markerDto.getLongitude()==null||markerDto.getLatitude()==null) return null; + if (null != markerDto.getCreateTime() && markerDto.getCreateTime().length() == 19) { + try { + result.setCreateTime(TimeFormat.parse(markerDto.getCreateTime(), "yyyy-MM-dd HH:mm:ss")); + } catch (ParseException pex) { + result.setCreateTime(Calendar.getInstance().getTime()); + } + } else { + result.setCreateTime(Calendar.getInstance().getTime()); + } + result.setDepth(doNullChange(markerDto.getDepth())); + result.setId(markerDto.getId()); + result.setLatitude(markerDto.getLatitude()); + result.setLongitude(markerDto.getLongitude()); + result.setMarkerId(markerDto.getMarkerId()); + result.setMarkerDepth(doNullChange(markerDto.getMarkerDepth())); + result.setMarkerObjectId(doNullChange(markerDto.getMarkerObjectId())); + result.setMarkerObjectType(doNullChange(markerDto.getMarkerObjectType())); + result.setOwnerComp(doNullChange(markerDto.getOwnerComp())); + result.setIsValid(markerDto.getIsValid()); + result.setMemo(doNullChange(markerDto.getMemo())); + result.setPipeDiameter(doNullChange(markerDto.getPipeDiameter())); + result.setPipeMaterial(doNullChange(markerDto.getPipeMaterial())); + result.setMarkerType(doNullChange(markerDto.getMarkerType())); + result.setCreator(doNullChange(markerDto.getCreator())); + + result.setLayStyle(doNullChange(markerDto.getLayStyle())); + result.setBelowDepth(doNullChange(markerDto.getBelowDepth())); + result.setBelowDiameter(doNullChange(markerDto.getBelowDiameter())); + result.setBelowMaterial(doNullChange(markerDto.getBelowMaterial())); + result.setBelowType(doNullChange(markerDto.getBelowType())); + result.setConstructTime(doNullChange(markerDto.getConstructTime())); + result.setRecordType(markerDto.getRecordType()); + result.setRoad(doNullChange(markerDto.getRoad())); + result.setArea(doNullChange(markerDto.getArea())); + result.setLine(doNullChange(markerDto.getLine())); + result.setColorType(markerDto.getColorType()); + result.setPhotos(markerDto.getPhotos()); return result; } diff --git a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java index dd0fa4b..ba5a1fb 100644 --- a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java +++ b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java @@ -9,10 +9,7 @@ import com.casic.accessControl.marker.domain.Marker; import com.casic.accessControl.user.domain.Company; import com.casic.accessControl.user.domain.User; -import com.casic.accessControl.util.DataTable; -import com.casic.accessControl.util.DataTableParameter; -import com.casic.accessControl.util.DataTableUtils; -import com.casic.accessControl.util.DateUtils; +import com.casic.accessControl.util.*; import com.google.gson.Gson; import jxl.*; import jxl.read.biff.BiffException; @@ -31,11 +28,15 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; +import sun.misc.BASE64Decoder; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.File; +import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.text.ParseException; @@ -183,6 +184,53 @@ } /** + * 保存标识器和图片信息 + * @param markerDto + * @param companyId + * @param fileNames + * @param fileBuffers + * @return + */ + public boolean saveMarkerAndPhotos(MarkerDto markerDto, Long companyId, String[] fileNames, String[] fileBuffers) { + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + String strDirPath = request.getSession().getServletContext().getRealPath(""); + FileOutputStream fos = null; + String month = TimeFormat.format(Calendar.getInstance().getTime(), "yyyyMM"); + String webPath = "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String toDir = strDirPath + "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String filePaths = ""; + try { + for (int i = 0; i < fileBuffers.length; i++) { + if (fileBuffers[i] != null && fileNames[i] != null) { +// filePaths += toDir+fileNames[i]+","; + filePaths += webPath + fileNames[i] + ","; + byte[] buffer = new BASE64Decoder().decodeBuffer(fileBuffers[i]); //对android传过来的图片字符串进行解码 + File destDir = new File(toDir); + if (!destDir.exists()) + destDir.mkdirs(); + File imageFile = new File(destDir, fileNames[i]); + fos = new FileOutputStream(imageFile); //保存图片 + fos.write(buffer); + fos.flush(); + fos.close(); + } + } + if (filePaths.endsWith(",")) { + filePaths = filePaths.substring(0, filePaths.length() - 1); + } + } catch (Exception e) { + return false; + } + Marker marker = MarkerDto.convert2Marker(markerDto); + marker.setIsValid(1); + marker.setCompanyId(companyId); + marker.setPhotos(filePaths); + save(marker); + return true; + + } + + /** * 新增标识器 8-9 * * @param markers @@ -582,7 +630,7 @@ "所属区域","所属线路","所属道路","建设年代","权属单位","标示对象ID", "标识器ID","标识器类型","标识器埋深","安装部门","经度", "纬度", "最后修改时间","备注","下层管种类", "下层管埋深", - "下层管直径", "下层管材料", "标识对象类别"}; + "下层管直径", "下层管材料", "标识对象类别", "标识点颜色", "图片地址"}; Label[][] labels = new Label[markerDtos.size() + 1][titleTxt.length]; for(int k=0;k saveMarkerAndPhotos(@RequestParam(value = "fileBuffer1", required = false) MultipartFile fileBuffer1, + @RequestParam(value = "fileBuffer2", required = false) MultipartFile fileBuffer2, + @RequestParam(value = "fileBuffer3", required = false) MultipartFile fileBuffer3, + @RequestParam(value = "jsonMarker", required = true) String jsonMarker) { + Map map = new HashMap(); + map.put("message", "安装无标识器信息"); + Gson gson = new Gson(); + try { + MarkerDto marker = gson.fromJson(jsonMarker, MarkerDto.class); + + if (null == marker.getMarkerId()) { + map.put("message", "无标识器ID"); + map.put("success", "false"); + return map; + } else if (markerManager.getMarkerByMarkerId(marker.getMarkerId()).size() > 0) { + map.put("message", "已安装过该标识器[" + marker.getMarkerId() + "]"); + map.put("success", "false"); + return map; + } else { + String[] fileNames = new String[3]; + String[] fileBuffers = new String[3]; + if (fileBuffer1 != null) { + fileNames[0] = marker.getMarkerId() + "_" + fileBuffer1.getOriginalFilename(); + byte[] fis = fileBuffer1.getBytes(); + fileBuffers[0] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, com.sun.org.apache.xml.internal.security.utils.Base64.BASE64DEFAULTLENGTH)); + } + if (fileBuffer2 != null) { + fileNames[1] = marker.getMarkerId() + "_" + fileBuffer2.getOriginalFilename(); + byte[] fis = fileBuffer2.getBytes(); + fileBuffers[1] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, com.sun.org.apache.xml.internal.security.utils.Base64.BASE64DEFAULTLENGTH)); + } + if (fileBuffer3 != null) { + fileNames[2] = marker.getMarkerId() + "_" + fileBuffer3.getOriginalFilename(); + byte[] fis = fileBuffer3.getBytes(); + fileBuffers[2] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, Base64.BASE64DEFAULTLENGTH)); + } + Long companyId = marker.getCompanyId(); + if (companyId == null) { + return map; + } + boolean result = markerManager.saveMarkerAndPhotos(marker, companyId, fileNames, fileBuffers); + if (!result) { + return map; + } + } + } catch (Exception e) { + return map; + } + map.put("success", "true"); + map.put("message", "保存成功"); + return map; + } + + @RequestMapping("marker-info-delete") @ResponseBody public Map delete(@RequestParam(value = "id", required = true) Long id) { @@ -144,6 +208,9 @@ map.put("message", "删除需要ID信息"); return map; } + + System.out.println(ids); + markerManager.delMarkerByIds(ids); map.put("success", true); map.put("message", "删除成功"); @@ -240,6 +307,54 @@ return map; } + /** + * 批量上传标识点,用于无信号地区标识器信息统一上传,不修改已有标识点信息 + * @param strMarkers + * @return + */ + @RequestMapping("batch-save-no-update") + @ResponseBody + public Map batchSaveOrUpdate(@RequestParam(value = "markers", required = true) String strMarkers) { + strMarkers = strMarkers.replace('\n',' '); + Map map = new HashMap(); + map.put("message", "批量导入失败,或无导入标识器信息"); + Gson gson = new Gson(); + try { + List markers = gson.fromJson(strMarkers, new TypeToken>() { + }.getType()); + if (CollectionUtils.isEmpty(markers)) {//批量导入数据不存在,直接返回 + map.put("message", "批量导入数据不存在"); + return map; + } + + Long companyId = markers.get(0).getCompanyId(); + if (companyId == null) { + map.put("message", "未找到所属公司属性"); + return map; + } + + List markerDtoForSave = new ArrayList(); + for (MarkerDto markerDto : markers) { + // 上传marker的Id不为空且数据库中不存在记录,经纬度不为空,允许保存 + if (StringUtils.isNotBlank(markerDto.getMarkerId()) && markerManager.getMarkerByMarkerId(markerDto.getMarkerId()).size() <= 0) { + if (null != markerDto.getLongitude() && null != markerDto.getLatitude()) { + markerDtoForSave.add(markerDto); + } + } + } + boolean result = markerManager.batchSave(markerDtoForSave, companyId); + if (!result) { + return map; + } + } catch (Exception e) { + e.printStackTrace(); + return map; + } + map.put("success", true); + map.put("message", "保存成功"); + return map; + } + @RequestMapping("getMarkerListByCondition") @ResponseBody @POST diff --git a/src/main/java/com/casic/accessControl/user/web/UserController.java b/src/main/java/com/casic/accessControl/user/web/UserController.java index feab678..3534a97 100644 --- a/src/main/java/com/casic/accessControl/user/web/UserController.java +++ b/src/main/java/com/casic/accessControl/user/web/UserController.java @@ -46,6 +46,7 @@ @ResponseBody public Map login(@ModelAttribute User userInfo, HttpSession session) { Map result = new HashMap(); + User user = null; try{ user = userManager.login(userInfo); diff --git a/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java new file mode 100644 index 0000000..634ceae --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java @@ -0,0 +1,46 @@ +package com.casic.accessControl.app.domain; + +import javax.persistence.*; +import java.util.Date; + +/** + * app的版本信息 + */ +//工单 +@Entity +@Table(name = "apkVersion") +public class ApkVersion { + private String version; + private String path; + private Date ts;//时间戳 + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "version") + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + @Column(name = "path") + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + @Column(name = "ts") + public Date getTs() { + return ts; + } + + public void setTs(Date ts) { + this.ts = ts; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java new file mode 100644 index 0000000..1d0242a --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java @@ -0,0 +1,50 @@ +package com.casic.accessControl.app.dto; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.util.TimeFormat; + +/** + * Created by lenovo on 2016/4/13. + */ +public class ApkVersionDto { + private String version; + private String path; + private String ts; + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public String getTs() { + return ts; + } + + public void setTs(String ts) { + this.ts = ts; + } + + public static ApkVersionDto Convert(ApkVersion version) { + if (version == null) { + return null; + } + ApkVersionDto versionDto = new ApkVersionDto(); + versionDto.setVersion(version.getVersion()); + versionDto.setPath(version.getVersion()); + versionDto.setTs(TimeFormat.formatTimestamp(version.getTs())); + + return versionDto; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java b/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java new file mode 100644 index 0000000..28b12a7 --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java @@ -0,0 +1,27 @@ +package com.casic.accessControl.app.manager; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.core.hibernate.HibernateEntityDao; +import org.hibernate.Query; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * + */ +@Service("apkVersionManager") +public class ApkVersionManager extends HibernateEntityDao { + + public ApkVersion getLatestVersion() { + String sql = "from ApkVersion order by ts desc"; + Query query = getSession().createQuery(sql); + List list = query.list(); + if (null != list && list.isEmpty() == false) { + return list.get(0); + } + + return null; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java b/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java new file mode 100644 index 0000000..065d3cc --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java @@ -0,0 +1,66 @@ +package com.casic.accessControl.app.web; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.app.manager.ApkVersionManager; +import com.casic.accessControl.marker.domain.Marker; +import com.casic.accessControl.marker.manager.MarkerManager; +import com.casic.accessControl.task.domain.Task; +import com.casic.accessControl.task.domain.TaskDetail; +import com.casic.accessControl.task.dto.TaskDetailDto; +import com.casic.accessControl.task.dto.TaskDto; +import com.casic.accessControl.task.dto.TaskStatus; +import com.casic.accessControl.task.manager.TaskDetailManager; +import com.casic.accessControl.task.manager.TaskManager; +import com.casic.accessControl.user.domain.Company; +import com.casic.accessControl.user.domain.Role; +import com.casic.accessControl.user.domain.User; +import com.casic.accessControl.user.dto.UserDto; +import com.casic.accessControl.user.manager.RoleManager; +import com.casic.accessControl.user.manager.UserManager; +import com.casic.accessControl.util.DataTable; +import com.casic.accessControl.util.StringUtils; +import com.google.gson.Gson; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +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.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * Created by lenovo on 2016/4/13. + */ +@Controller +@RequestMapping("app") +public class ApkVersionController { + + @Resource + private ApkVersionManager apkVersionManager; + + @RequestMapping("get-latest-version") + @ResponseBody + public Map getLatestVersion(HttpServletResponse response, HttpSession session) { + Map result = new HashMap(); + try { + ApkVersion latest = apkVersionManager.getLatestVersion(); + if (null != latest) { + result.put("version", latest.getVersion()); + result.put("path", latest.getPath()); + } else { + result.put("version", "1.0.0"); + } + } catch (Exception e) { + e.printStackTrace(); + result.put("version", "1.0.0"); + } + + return result; + } + +} diff --git a/src/main/java/com/casic/accessControl/marker/domain/Marker.java b/src/main/java/com/casic/accessControl/marker/domain/Marker.java index 0575cfe..7d5b854 100644 --- a/src/main/java/com/casic/accessControl/marker/domain/Marker.java +++ b/src/main/java/com/casic/accessControl/marker/domain/Marker.java @@ -67,6 +67,10 @@ private String area; @Column(name = "line") private String line; + @Column(name = "colorType") + private String colorType; + @Column(name = "photos") + private String photos; @@ -315,4 +319,20 @@ public void setArea(String area) { this.area = area; } + + public String getColorType() { + return colorType; + } + + public void setColorType(String colorType) { + this.colorType = colorType; + } + + public String getPhotos() { + return photos; + } + + public void setPhotos(String photos) { + this.photos = photos; + } } diff --git a/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java b/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java index 506f31d..c5f8cf5 100644 --- a/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java +++ b/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java @@ -2,12 +2,12 @@ //import com.casic.accessControl.feature.domain.Feature; import com.casic.accessControl.marker.domain.Marker; +import com.casic.accessControl.util.StringUtils; +import com.casic.accessControl.util.TimeFormat; import org.apache.commons.collections.CollectionUtils; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.List; +import java.text.ParseException; +import java.util.*; /** * Created by lenovo on 2016/5/16. @@ -43,6 +43,8 @@ private Long userId; private String area; private String line; + private String colorType; + private String photos; private String btnEdit = "编辑"; private String btnDelete = "删除"; @@ -296,6 +298,23 @@ this.area = area; } + public String getColorType() { + if (StringUtils.isEmpty(colorType)) return "0"; + return colorType; + } + + public void setColorType(String colorType) { + this.colorType = colorType; + } + + public String getPhotos() { + return photos; + } + + public void setPhotos(String photos) { + this.photos = photos; + } + public String getLine() { return line; } @@ -335,6 +354,52 @@ result.setRoad(doNullChange(marker.getRoad())); result.setArea(doNullChange(marker.getArea())); result.setLine(doNullChange(marker.getLine())); + result.setColorType(marker.getColorType()); + result.setPhotos(marker.getPhotos()); + return result; + } + + public static Marker convert2Marker(MarkerDto markerDto) { + if (markerDto == null) return null; + Marker result = new Marker(); + if(markerDto.getLongitude()==null||markerDto.getLatitude()==null) return null; + if (null != markerDto.getCreateTime() && markerDto.getCreateTime().length() == 19) { + try { + result.setCreateTime(TimeFormat.parse(markerDto.getCreateTime(), "yyyy-MM-dd HH:mm:ss")); + } catch (ParseException pex) { + result.setCreateTime(Calendar.getInstance().getTime()); + } + } else { + result.setCreateTime(Calendar.getInstance().getTime()); + } + result.setDepth(doNullChange(markerDto.getDepth())); + result.setId(markerDto.getId()); + result.setLatitude(markerDto.getLatitude()); + result.setLongitude(markerDto.getLongitude()); + result.setMarkerId(markerDto.getMarkerId()); + result.setMarkerDepth(doNullChange(markerDto.getMarkerDepth())); + result.setMarkerObjectId(doNullChange(markerDto.getMarkerObjectId())); + result.setMarkerObjectType(doNullChange(markerDto.getMarkerObjectType())); + result.setOwnerComp(doNullChange(markerDto.getOwnerComp())); + result.setIsValid(markerDto.getIsValid()); + result.setMemo(doNullChange(markerDto.getMemo())); + result.setPipeDiameter(doNullChange(markerDto.getPipeDiameter())); + result.setPipeMaterial(doNullChange(markerDto.getPipeMaterial())); + result.setMarkerType(doNullChange(markerDto.getMarkerType())); + result.setCreator(doNullChange(markerDto.getCreator())); + + result.setLayStyle(doNullChange(markerDto.getLayStyle())); + result.setBelowDepth(doNullChange(markerDto.getBelowDepth())); + result.setBelowDiameter(doNullChange(markerDto.getBelowDiameter())); + result.setBelowMaterial(doNullChange(markerDto.getBelowMaterial())); + result.setBelowType(doNullChange(markerDto.getBelowType())); + result.setConstructTime(doNullChange(markerDto.getConstructTime())); + result.setRecordType(markerDto.getRecordType()); + result.setRoad(doNullChange(markerDto.getRoad())); + result.setArea(doNullChange(markerDto.getArea())); + result.setLine(doNullChange(markerDto.getLine())); + result.setColorType(markerDto.getColorType()); + result.setPhotos(markerDto.getPhotos()); return result; } diff --git a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java index dd0fa4b..ba5a1fb 100644 --- a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java +++ b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java @@ -9,10 +9,7 @@ import com.casic.accessControl.marker.domain.Marker; import com.casic.accessControl.user.domain.Company; import com.casic.accessControl.user.domain.User; -import com.casic.accessControl.util.DataTable; -import com.casic.accessControl.util.DataTableParameter; -import com.casic.accessControl.util.DataTableUtils; -import com.casic.accessControl.util.DateUtils; +import com.casic.accessControl.util.*; import com.google.gson.Gson; import jxl.*; import jxl.read.biff.BiffException; @@ -31,11 +28,15 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; +import sun.misc.BASE64Decoder; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.File; +import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.text.ParseException; @@ -183,6 +184,53 @@ } /** + * 保存标识器和图片信息 + * @param markerDto + * @param companyId + * @param fileNames + * @param fileBuffers + * @return + */ + public boolean saveMarkerAndPhotos(MarkerDto markerDto, Long companyId, String[] fileNames, String[] fileBuffers) { + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + String strDirPath = request.getSession().getServletContext().getRealPath(""); + FileOutputStream fos = null; + String month = TimeFormat.format(Calendar.getInstance().getTime(), "yyyyMM"); + String webPath = "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String toDir = strDirPath + "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String filePaths = ""; + try { + for (int i = 0; i < fileBuffers.length; i++) { + if (fileBuffers[i] != null && fileNames[i] != null) { +// filePaths += toDir+fileNames[i]+","; + filePaths += webPath + fileNames[i] + ","; + byte[] buffer = new BASE64Decoder().decodeBuffer(fileBuffers[i]); //对android传过来的图片字符串进行解码 + File destDir = new File(toDir); + if (!destDir.exists()) + destDir.mkdirs(); + File imageFile = new File(destDir, fileNames[i]); + fos = new FileOutputStream(imageFile); //保存图片 + fos.write(buffer); + fos.flush(); + fos.close(); + } + } + if (filePaths.endsWith(",")) { + filePaths = filePaths.substring(0, filePaths.length() - 1); + } + } catch (Exception e) { + return false; + } + Marker marker = MarkerDto.convert2Marker(markerDto); + marker.setIsValid(1); + marker.setCompanyId(companyId); + marker.setPhotos(filePaths); + save(marker); + return true; + + } + + /** * 新增标识器 8-9 * * @param markers @@ -582,7 +630,7 @@ "所属区域","所属线路","所属道路","建设年代","权属单位","标示对象ID", "标识器ID","标识器类型","标识器埋深","安装部门","经度", "纬度", "最后修改时间","备注","下层管种类", "下层管埋深", - "下层管直径", "下层管材料", "标识对象类别"}; + "下层管直径", "下层管材料", "标识对象类别", "标识点颜色", "图片地址"}; Label[][] labels = new Label[markerDtos.size() + 1][titleTxt.length]; for(int k=0;k saveMarkerAndPhotos(@RequestParam(value = "fileBuffer1", required = false) MultipartFile fileBuffer1, + @RequestParam(value = "fileBuffer2", required = false) MultipartFile fileBuffer2, + @RequestParam(value = "fileBuffer3", required = false) MultipartFile fileBuffer3, + @RequestParam(value = "jsonMarker", required = true) String jsonMarker) { + Map map = new HashMap(); + map.put("message", "安装无标识器信息"); + Gson gson = new Gson(); + try { + MarkerDto marker = gson.fromJson(jsonMarker, MarkerDto.class); + + if (null == marker.getMarkerId()) { + map.put("message", "无标识器ID"); + map.put("success", "false"); + return map; + } else if (markerManager.getMarkerByMarkerId(marker.getMarkerId()).size() > 0) { + map.put("message", "已安装过该标识器[" + marker.getMarkerId() + "]"); + map.put("success", "false"); + return map; + } else { + String[] fileNames = new String[3]; + String[] fileBuffers = new String[3]; + if (fileBuffer1 != null) { + fileNames[0] = marker.getMarkerId() + "_" + fileBuffer1.getOriginalFilename(); + byte[] fis = fileBuffer1.getBytes(); + fileBuffers[0] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, com.sun.org.apache.xml.internal.security.utils.Base64.BASE64DEFAULTLENGTH)); + } + if (fileBuffer2 != null) { + fileNames[1] = marker.getMarkerId() + "_" + fileBuffer2.getOriginalFilename(); + byte[] fis = fileBuffer2.getBytes(); + fileBuffers[1] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, com.sun.org.apache.xml.internal.security.utils.Base64.BASE64DEFAULTLENGTH)); + } + if (fileBuffer3 != null) { + fileNames[2] = marker.getMarkerId() + "_" + fileBuffer3.getOriginalFilename(); + byte[] fis = fileBuffer3.getBytes(); + fileBuffers[2] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, Base64.BASE64DEFAULTLENGTH)); + } + Long companyId = marker.getCompanyId(); + if (companyId == null) { + return map; + } + boolean result = markerManager.saveMarkerAndPhotos(marker, companyId, fileNames, fileBuffers); + if (!result) { + return map; + } + } + } catch (Exception e) { + return map; + } + map.put("success", "true"); + map.put("message", "保存成功"); + return map; + } + + @RequestMapping("marker-info-delete") @ResponseBody public Map delete(@RequestParam(value = "id", required = true) Long id) { @@ -144,6 +208,9 @@ map.put("message", "删除需要ID信息"); return map; } + + System.out.println(ids); + markerManager.delMarkerByIds(ids); map.put("success", true); map.put("message", "删除成功"); @@ -240,6 +307,54 @@ return map; } + /** + * 批量上传标识点,用于无信号地区标识器信息统一上传,不修改已有标识点信息 + * @param strMarkers + * @return + */ + @RequestMapping("batch-save-no-update") + @ResponseBody + public Map batchSaveOrUpdate(@RequestParam(value = "markers", required = true) String strMarkers) { + strMarkers = strMarkers.replace('\n',' '); + Map map = new HashMap(); + map.put("message", "批量导入失败,或无导入标识器信息"); + Gson gson = new Gson(); + try { + List markers = gson.fromJson(strMarkers, new TypeToken>() { + }.getType()); + if (CollectionUtils.isEmpty(markers)) {//批量导入数据不存在,直接返回 + map.put("message", "批量导入数据不存在"); + return map; + } + + Long companyId = markers.get(0).getCompanyId(); + if (companyId == null) { + map.put("message", "未找到所属公司属性"); + return map; + } + + List markerDtoForSave = new ArrayList(); + for (MarkerDto markerDto : markers) { + // 上传marker的Id不为空且数据库中不存在记录,经纬度不为空,允许保存 + if (StringUtils.isNotBlank(markerDto.getMarkerId()) && markerManager.getMarkerByMarkerId(markerDto.getMarkerId()).size() <= 0) { + if (null != markerDto.getLongitude() && null != markerDto.getLatitude()) { + markerDtoForSave.add(markerDto); + } + } + } + boolean result = markerManager.batchSave(markerDtoForSave, companyId); + if (!result) { + return map; + } + } catch (Exception e) { + e.printStackTrace(); + return map; + } + map.put("success", true); + map.put("message", "保存成功"); + return map; + } + @RequestMapping("getMarkerListByCondition") @ResponseBody @POST diff --git a/src/main/java/com/casic/accessControl/user/web/UserController.java b/src/main/java/com/casic/accessControl/user/web/UserController.java index feab678..3534a97 100644 --- a/src/main/java/com/casic/accessControl/user/web/UserController.java +++ b/src/main/java/com/casic/accessControl/user/web/UserController.java @@ -46,6 +46,7 @@ @ResponseBody public Map login(@ModelAttribute User userInfo, HttpSession session) { Map result = new HashMap(); + User user = null; try{ user = userManager.login(userInfo); diff --git a/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java b/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java new file mode 100644 index 0000000..582120f --- /dev/null +++ b/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java @@ -0,0 +1,129 @@ +package com.casic.accessControl.util; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.net.URL; +import java.net.URLConnection; +import java.util.List; +import java.util.Map; + +/** + * Created by lenovo on 2016/8/31. + */ +public class HttpRequestUtils { + + /** + * 向指定URL发送GET方法的请求 + * + * @param url + * 发送请求的URL + * @param param + * 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 + * @return URL 所代表远程资源的响应结果 + */ + public static String sendGet(String url, String param) { + String result = ""; + BufferedReader in = null; + try { + String urlNameString = url + "?" + param; + URL realUrl = new URL(urlNameString); + // 打开和URL之间的连接 + URLConnection connection = realUrl.openConnection(); + // 设置通用的请求属性 + connection.setRequestProperty("accept", "*/*"); + connection.setRequestProperty("connection", "Keep-Alive"); + connection.setRequestProperty("user-agent", + "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + // 建立实际的连接 + connection.connect(); + // 获取所有响应头字段 + Map> map = connection.getHeaderFields(); + // 遍历所有的响应头字段 + for (String key : map.keySet()) { + System.out.println(key + "--->" + map.get(key)); + } + // 定义 BufferedReader输入流来读取URL的响应 + in = new BufferedReader(new InputStreamReader( + connection.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + result += line; + } + } catch (Exception e) { + System.out.println("发送GET请求出现异常!" + e); + e.printStackTrace(); + } + // 使用finally块来关闭输入流 + finally { + try { + if (in != null) { + in.close(); + } + } catch (Exception e2) { + e2.printStackTrace(); + } + } + return result; + } + + /** + * 向指定 URL 发送POST方法的请求 + * + * @param url + * 发送请求的 URL + * @param param + * 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 + * @return 所代表远程资源的响应结果 + */ + public static String sendPost(String url, String param) { + PrintWriter out = null; + BufferedReader in = null; + String result = ""; + try { + URL realUrl = new URL(url); + // 打开和URL之间的连接 + URLConnection conn = realUrl.openConnection(); + // 设置通用的请求属性 + conn.setRequestProperty("accept", "*/*"); + conn.setRequestProperty("connection", "Keep-Alive"); + conn.setRequestProperty("user-agent", + "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + // 发送POST请求必须设置如下两行 + conn.setDoOutput(true); + conn.setDoInput(true); + // 获取URLConnection对象对应的输出流 + out = new PrintWriter(conn.getOutputStream()); + // 发送请求参数 + out.print(param); + // flush输出流的缓冲 + out.flush(); + // 定义BufferedReader输入流来读取URL的响应 + in = new BufferedReader( + new InputStreamReader(conn.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + result += line; + } + } catch (Exception e) { + System.out.println("发送 POST 请求出现异常!"+e); + e.printStackTrace(); + } + //使用finally块来关闭输出流、输入流 + finally{ + try{ + if(out!=null){ + out.close(); + } + if(in!=null){ + in.close(); + } + } + catch(IOException ex){ + ex.printStackTrace(); + } + } + return result; + } + } \ No newline at end of file diff --git a/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java new file mode 100644 index 0000000..634ceae --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java @@ -0,0 +1,46 @@ +package com.casic.accessControl.app.domain; + +import javax.persistence.*; +import java.util.Date; + +/** + * app的版本信息 + */ +//工单 +@Entity +@Table(name = "apkVersion") +public class ApkVersion { + private String version; + private String path; + private Date ts;//时间戳 + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "version") + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + @Column(name = "path") + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + @Column(name = "ts") + public Date getTs() { + return ts; + } + + public void setTs(Date ts) { + this.ts = ts; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java new file mode 100644 index 0000000..1d0242a --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java @@ -0,0 +1,50 @@ +package com.casic.accessControl.app.dto; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.util.TimeFormat; + +/** + * Created by lenovo on 2016/4/13. + */ +public class ApkVersionDto { + private String version; + private String path; + private String ts; + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public String getTs() { + return ts; + } + + public void setTs(String ts) { + this.ts = ts; + } + + public static ApkVersionDto Convert(ApkVersion version) { + if (version == null) { + return null; + } + ApkVersionDto versionDto = new ApkVersionDto(); + versionDto.setVersion(version.getVersion()); + versionDto.setPath(version.getVersion()); + versionDto.setTs(TimeFormat.formatTimestamp(version.getTs())); + + return versionDto; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java b/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java new file mode 100644 index 0000000..28b12a7 --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java @@ -0,0 +1,27 @@ +package com.casic.accessControl.app.manager; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.core.hibernate.HibernateEntityDao; +import org.hibernate.Query; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * + */ +@Service("apkVersionManager") +public class ApkVersionManager extends HibernateEntityDao { + + public ApkVersion getLatestVersion() { + String sql = "from ApkVersion order by ts desc"; + Query query = getSession().createQuery(sql); + List list = query.list(); + if (null != list && list.isEmpty() == false) { + return list.get(0); + } + + return null; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java b/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java new file mode 100644 index 0000000..065d3cc --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java @@ -0,0 +1,66 @@ +package com.casic.accessControl.app.web; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.app.manager.ApkVersionManager; +import com.casic.accessControl.marker.domain.Marker; +import com.casic.accessControl.marker.manager.MarkerManager; +import com.casic.accessControl.task.domain.Task; +import com.casic.accessControl.task.domain.TaskDetail; +import com.casic.accessControl.task.dto.TaskDetailDto; +import com.casic.accessControl.task.dto.TaskDto; +import com.casic.accessControl.task.dto.TaskStatus; +import com.casic.accessControl.task.manager.TaskDetailManager; +import com.casic.accessControl.task.manager.TaskManager; +import com.casic.accessControl.user.domain.Company; +import com.casic.accessControl.user.domain.Role; +import com.casic.accessControl.user.domain.User; +import com.casic.accessControl.user.dto.UserDto; +import com.casic.accessControl.user.manager.RoleManager; +import com.casic.accessControl.user.manager.UserManager; +import com.casic.accessControl.util.DataTable; +import com.casic.accessControl.util.StringUtils; +import com.google.gson.Gson; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +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.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * Created by lenovo on 2016/4/13. + */ +@Controller +@RequestMapping("app") +public class ApkVersionController { + + @Resource + private ApkVersionManager apkVersionManager; + + @RequestMapping("get-latest-version") + @ResponseBody + public Map getLatestVersion(HttpServletResponse response, HttpSession session) { + Map result = new HashMap(); + try { + ApkVersion latest = apkVersionManager.getLatestVersion(); + if (null != latest) { + result.put("version", latest.getVersion()); + result.put("path", latest.getPath()); + } else { + result.put("version", "1.0.0"); + } + } catch (Exception e) { + e.printStackTrace(); + result.put("version", "1.0.0"); + } + + return result; + } + +} diff --git a/src/main/java/com/casic/accessControl/marker/domain/Marker.java b/src/main/java/com/casic/accessControl/marker/domain/Marker.java index 0575cfe..7d5b854 100644 --- a/src/main/java/com/casic/accessControl/marker/domain/Marker.java +++ b/src/main/java/com/casic/accessControl/marker/domain/Marker.java @@ -67,6 +67,10 @@ private String area; @Column(name = "line") private String line; + @Column(name = "colorType") + private String colorType; + @Column(name = "photos") + private String photos; @@ -315,4 +319,20 @@ public void setArea(String area) { this.area = area; } + + public String getColorType() { + return colorType; + } + + public void setColorType(String colorType) { + this.colorType = colorType; + } + + public String getPhotos() { + return photos; + } + + public void setPhotos(String photos) { + this.photos = photos; + } } diff --git a/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java b/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java index 506f31d..c5f8cf5 100644 --- a/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java +++ b/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java @@ -2,12 +2,12 @@ //import com.casic.accessControl.feature.domain.Feature; import com.casic.accessControl.marker.domain.Marker; +import com.casic.accessControl.util.StringUtils; +import com.casic.accessControl.util.TimeFormat; import org.apache.commons.collections.CollectionUtils; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.List; +import java.text.ParseException; +import java.util.*; /** * Created by lenovo on 2016/5/16. @@ -43,6 +43,8 @@ private Long userId; private String area; private String line; + private String colorType; + private String photos; private String btnEdit = "编辑"; private String btnDelete = "删除"; @@ -296,6 +298,23 @@ this.area = area; } + public String getColorType() { + if (StringUtils.isEmpty(colorType)) return "0"; + return colorType; + } + + public void setColorType(String colorType) { + this.colorType = colorType; + } + + public String getPhotos() { + return photos; + } + + public void setPhotos(String photos) { + this.photos = photos; + } + public String getLine() { return line; } @@ -335,6 +354,52 @@ result.setRoad(doNullChange(marker.getRoad())); result.setArea(doNullChange(marker.getArea())); result.setLine(doNullChange(marker.getLine())); + result.setColorType(marker.getColorType()); + result.setPhotos(marker.getPhotos()); + return result; + } + + public static Marker convert2Marker(MarkerDto markerDto) { + if (markerDto == null) return null; + Marker result = new Marker(); + if(markerDto.getLongitude()==null||markerDto.getLatitude()==null) return null; + if (null != markerDto.getCreateTime() && markerDto.getCreateTime().length() == 19) { + try { + result.setCreateTime(TimeFormat.parse(markerDto.getCreateTime(), "yyyy-MM-dd HH:mm:ss")); + } catch (ParseException pex) { + result.setCreateTime(Calendar.getInstance().getTime()); + } + } else { + result.setCreateTime(Calendar.getInstance().getTime()); + } + result.setDepth(doNullChange(markerDto.getDepth())); + result.setId(markerDto.getId()); + result.setLatitude(markerDto.getLatitude()); + result.setLongitude(markerDto.getLongitude()); + result.setMarkerId(markerDto.getMarkerId()); + result.setMarkerDepth(doNullChange(markerDto.getMarkerDepth())); + result.setMarkerObjectId(doNullChange(markerDto.getMarkerObjectId())); + result.setMarkerObjectType(doNullChange(markerDto.getMarkerObjectType())); + result.setOwnerComp(doNullChange(markerDto.getOwnerComp())); + result.setIsValid(markerDto.getIsValid()); + result.setMemo(doNullChange(markerDto.getMemo())); + result.setPipeDiameter(doNullChange(markerDto.getPipeDiameter())); + result.setPipeMaterial(doNullChange(markerDto.getPipeMaterial())); + result.setMarkerType(doNullChange(markerDto.getMarkerType())); + result.setCreator(doNullChange(markerDto.getCreator())); + + result.setLayStyle(doNullChange(markerDto.getLayStyle())); + result.setBelowDepth(doNullChange(markerDto.getBelowDepth())); + result.setBelowDiameter(doNullChange(markerDto.getBelowDiameter())); + result.setBelowMaterial(doNullChange(markerDto.getBelowMaterial())); + result.setBelowType(doNullChange(markerDto.getBelowType())); + result.setConstructTime(doNullChange(markerDto.getConstructTime())); + result.setRecordType(markerDto.getRecordType()); + result.setRoad(doNullChange(markerDto.getRoad())); + result.setArea(doNullChange(markerDto.getArea())); + result.setLine(doNullChange(markerDto.getLine())); + result.setColorType(markerDto.getColorType()); + result.setPhotos(markerDto.getPhotos()); return result; } diff --git a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java index dd0fa4b..ba5a1fb 100644 --- a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java +++ b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java @@ -9,10 +9,7 @@ import com.casic.accessControl.marker.domain.Marker; import com.casic.accessControl.user.domain.Company; import com.casic.accessControl.user.domain.User; -import com.casic.accessControl.util.DataTable; -import com.casic.accessControl.util.DataTableParameter; -import com.casic.accessControl.util.DataTableUtils; -import com.casic.accessControl.util.DateUtils; +import com.casic.accessControl.util.*; import com.google.gson.Gson; import jxl.*; import jxl.read.biff.BiffException; @@ -31,11 +28,15 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; +import sun.misc.BASE64Decoder; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.File; +import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.text.ParseException; @@ -183,6 +184,53 @@ } /** + * 保存标识器和图片信息 + * @param markerDto + * @param companyId + * @param fileNames + * @param fileBuffers + * @return + */ + public boolean saveMarkerAndPhotos(MarkerDto markerDto, Long companyId, String[] fileNames, String[] fileBuffers) { + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + String strDirPath = request.getSession().getServletContext().getRealPath(""); + FileOutputStream fos = null; + String month = TimeFormat.format(Calendar.getInstance().getTime(), "yyyyMM"); + String webPath = "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String toDir = strDirPath + "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String filePaths = ""; + try { + for (int i = 0; i < fileBuffers.length; i++) { + if (fileBuffers[i] != null && fileNames[i] != null) { +// filePaths += toDir+fileNames[i]+","; + filePaths += webPath + fileNames[i] + ","; + byte[] buffer = new BASE64Decoder().decodeBuffer(fileBuffers[i]); //对android传过来的图片字符串进行解码 + File destDir = new File(toDir); + if (!destDir.exists()) + destDir.mkdirs(); + File imageFile = new File(destDir, fileNames[i]); + fos = new FileOutputStream(imageFile); //保存图片 + fos.write(buffer); + fos.flush(); + fos.close(); + } + } + if (filePaths.endsWith(",")) { + filePaths = filePaths.substring(0, filePaths.length() - 1); + } + } catch (Exception e) { + return false; + } + Marker marker = MarkerDto.convert2Marker(markerDto); + marker.setIsValid(1); + marker.setCompanyId(companyId); + marker.setPhotos(filePaths); + save(marker); + return true; + + } + + /** * 新增标识器 8-9 * * @param markers @@ -582,7 +630,7 @@ "所属区域","所属线路","所属道路","建设年代","权属单位","标示对象ID", "标识器ID","标识器类型","标识器埋深","安装部门","经度", "纬度", "最后修改时间","备注","下层管种类", "下层管埋深", - "下层管直径", "下层管材料", "标识对象类别"}; + "下层管直径", "下层管材料", "标识对象类别", "标识点颜色", "图片地址"}; Label[][] labels = new Label[markerDtos.size() + 1][titleTxt.length]; for(int k=0;k saveMarkerAndPhotos(@RequestParam(value = "fileBuffer1", required = false) MultipartFile fileBuffer1, + @RequestParam(value = "fileBuffer2", required = false) MultipartFile fileBuffer2, + @RequestParam(value = "fileBuffer3", required = false) MultipartFile fileBuffer3, + @RequestParam(value = "jsonMarker", required = true) String jsonMarker) { + Map map = new HashMap(); + map.put("message", "安装无标识器信息"); + Gson gson = new Gson(); + try { + MarkerDto marker = gson.fromJson(jsonMarker, MarkerDto.class); + + if (null == marker.getMarkerId()) { + map.put("message", "无标识器ID"); + map.put("success", "false"); + return map; + } else if (markerManager.getMarkerByMarkerId(marker.getMarkerId()).size() > 0) { + map.put("message", "已安装过该标识器[" + marker.getMarkerId() + "]"); + map.put("success", "false"); + return map; + } else { + String[] fileNames = new String[3]; + String[] fileBuffers = new String[3]; + if (fileBuffer1 != null) { + fileNames[0] = marker.getMarkerId() + "_" + fileBuffer1.getOriginalFilename(); + byte[] fis = fileBuffer1.getBytes(); + fileBuffers[0] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, com.sun.org.apache.xml.internal.security.utils.Base64.BASE64DEFAULTLENGTH)); + } + if (fileBuffer2 != null) { + fileNames[1] = marker.getMarkerId() + "_" + fileBuffer2.getOriginalFilename(); + byte[] fis = fileBuffer2.getBytes(); + fileBuffers[1] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, com.sun.org.apache.xml.internal.security.utils.Base64.BASE64DEFAULTLENGTH)); + } + if (fileBuffer3 != null) { + fileNames[2] = marker.getMarkerId() + "_" + fileBuffer3.getOriginalFilename(); + byte[] fis = fileBuffer3.getBytes(); + fileBuffers[2] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, Base64.BASE64DEFAULTLENGTH)); + } + Long companyId = marker.getCompanyId(); + if (companyId == null) { + return map; + } + boolean result = markerManager.saveMarkerAndPhotos(marker, companyId, fileNames, fileBuffers); + if (!result) { + return map; + } + } + } catch (Exception e) { + return map; + } + map.put("success", "true"); + map.put("message", "保存成功"); + return map; + } + + @RequestMapping("marker-info-delete") @ResponseBody public Map delete(@RequestParam(value = "id", required = true) Long id) { @@ -144,6 +208,9 @@ map.put("message", "删除需要ID信息"); return map; } + + System.out.println(ids); + markerManager.delMarkerByIds(ids); map.put("success", true); map.put("message", "删除成功"); @@ -240,6 +307,54 @@ return map; } + /** + * 批量上传标识点,用于无信号地区标识器信息统一上传,不修改已有标识点信息 + * @param strMarkers + * @return + */ + @RequestMapping("batch-save-no-update") + @ResponseBody + public Map batchSaveOrUpdate(@RequestParam(value = "markers", required = true) String strMarkers) { + strMarkers = strMarkers.replace('\n',' '); + Map map = new HashMap(); + map.put("message", "批量导入失败,或无导入标识器信息"); + Gson gson = new Gson(); + try { + List markers = gson.fromJson(strMarkers, new TypeToken>() { + }.getType()); + if (CollectionUtils.isEmpty(markers)) {//批量导入数据不存在,直接返回 + map.put("message", "批量导入数据不存在"); + return map; + } + + Long companyId = markers.get(0).getCompanyId(); + if (companyId == null) { + map.put("message", "未找到所属公司属性"); + return map; + } + + List markerDtoForSave = new ArrayList(); + for (MarkerDto markerDto : markers) { + // 上传marker的Id不为空且数据库中不存在记录,经纬度不为空,允许保存 + if (StringUtils.isNotBlank(markerDto.getMarkerId()) && markerManager.getMarkerByMarkerId(markerDto.getMarkerId()).size() <= 0) { + if (null != markerDto.getLongitude() && null != markerDto.getLatitude()) { + markerDtoForSave.add(markerDto); + } + } + } + boolean result = markerManager.batchSave(markerDtoForSave, companyId); + if (!result) { + return map; + } + } catch (Exception e) { + e.printStackTrace(); + return map; + } + map.put("success", true); + map.put("message", "保存成功"); + return map; + } + @RequestMapping("getMarkerListByCondition") @ResponseBody @POST diff --git a/src/main/java/com/casic/accessControl/user/web/UserController.java b/src/main/java/com/casic/accessControl/user/web/UserController.java index feab678..3534a97 100644 --- a/src/main/java/com/casic/accessControl/user/web/UserController.java +++ b/src/main/java/com/casic/accessControl/user/web/UserController.java @@ -46,6 +46,7 @@ @ResponseBody public Map login(@ModelAttribute User userInfo, HttpSession session) { Map result = new HashMap(); + User user = null; try{ user = userManager.login(userInfo); diff --git a/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java b/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java new file mode 100644 index 0000000..582120f --- /dev/null +++ b/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java @@ -0,0 +1,129 @@ +package com.casic.accessControl.util; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.net.URL; +import java.net.URLConnection; +import java.util.List; +import java.util.Map; + +/** + * Created by lenovo on 2016/8/31. + */ +public class HttpRequestUtils { + + /** + * 向指定URL发送GET方法的请求 + * + * @param url + * 发送请求的URL + * @param param + * 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 + * @return URL 所代表远程资源的响应结果 + */ + public static String sendGet(String url, String param) { + String result = ""; + BufferedReader in = null; + try { + String urlNameString = url + "?" + param; + URL realUrl = new URL(urlNameString); + // 打开和URL之间的连接 + URLConnection connection = realUrl.openConnection(); + // 设置通用的请求属性 + connection.setRequestProperty("accept", "*/*"); + connection.setRequestProperty("connection", "Keep-Alive"); + connection.setRequestProperty("user-agent", + "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + // 建立实际的连接 + connection.connect(); + // 获取所有响应头字段 + Map> map = connection.getHeaderFields(); + // 遍历所有的响应头字段 + for (String key : map.keySet()) { + System.out.println(key + "--->" + map.get(key)); + } + // 定义 BufferedReader输入流来读取URL的响应 + in = new BufferedReader(new InputStreamReader( + connection.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + result += line; + } + } catch (Exception e) { + System.out.println("发送GET请求出现异常!" + e); + e.printStackTrace(); + } + // 使用finally块来关闭输入流 + finally { + try { + if (in != null) { + in.close(); + } + } catch (Exception e2) { + e2.printStackTrace(); + } + } + return result; + } + + /** + * 向指定 URL 发送POST方法的请求 + * + * @param url + * 发送请求的 URL + * @param param + * 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 + * @return 所代表远程资源的响应结果 + */ + public static String sendPost(String url, String param) { + PrintWriter out = null; + BufferedReader in = null; + String result = ""; + try { + URL realUrl = new URL(url); + // 打开和URL之间的连接 + URLConnection conn = realUrl.openConnection(); + // 设置通用的请求属性 + conn.setRequestProperty("accept", "*/*"); + conn.setRequestProperty("connection", "Keep-Alive"); + conn.setRequestProperty("user-agent", + "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + // 发送POST请求必须设置如下两行 + conn.setDoOutput(true); + conn.setDoInput(true); + // 获取URLConnection对象对应的输出流 + out = new PrintWriter(conn.getOutputStream()); + // 发送请求参数 + out.print(param); + // flush输出流的缓冲 + out.flush(); + // 定义BufferedReader输入流来读取URL的响应 + in = new BufferedReader( + new InputStreamReader(conn.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + result += line; + } + } catch (Exception e) { + System.out.println("发送 POST 请求出现异常!"+e); + e.printStackTrace(); + } + //使用finally块来关闭输出流、输入流 + finally{ + try{ + if(out!=null){ + out.close(); + } + if(in!=null){ + in.close(); + } + } + catch(IOException ex){ + ex.printStackTrace(); + } + } + return result; + } + } \ No newline at end of file diff --git a/src/main/java/com/casic/accessControl/util/TimeFormat.java b/src/main/java/com/casic/accessControl/util/TimeFormat.java new file mode 100644 index 0000000..e9168d5 --- /dev/null +++ b/src/main/java/com/casic/accessControl/util/TimeFormat.java @@ -0,0 +1,148 @@ +package com.casic.accessControl.util; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +/** + * 格式化日期工具类 + * 默认模式yyyy-MM-dd HH:mm:ss + * @author Administrator + * + */ +public class TimeFormat { + + private static final String DATE_FORMAT_STRING = "yyyy-MM-dd"; + private static final String TIME_FORMAT_STRING = "HH:mm:ss"; + private static final String TIMESTAMP_FORMAT_STRING = "yyyy-MM-dd HH:mm:ss"; + + // 默认格式化格式 + private static SimpleDateFormat defaultFormat = new SimpleDateFormat(TIMESTAMP_FORMAT_STRING); + + public static void setFormatString(String pattern) { + defaultFormat.applyPattern(pattern); + } + + /** + * 默认格式化日期 + * + * @param Date date + * @return String + */ + public static String format(Date date) { + return defaultFormat.format(date); + } + + /** + * 日期格式化 + * + * @param date + * @return + */ + public static String formatDate(Date date) { + return TimeFormat.format(date, DATE_FORMAT_STRING); + } + + /** + * 时间格式化 + * + * @param date + * @return + */ + public static String formatTime(Date date) { + return TimeFormat.format(date, TIME_FORMAT_STRING); + } + + /** + * 时间戳格式化 + * + * @param date + * @return + */ + public static String formatTimestamp(Date date) { + return TimeFormat.format(date, TIMESTAMP_FORMAT_STRING); + } + + /** + * 以指定模式格式化日期 + * + * @param Date date + * @param String pattern + * @return String + */ + public static String format(Date date, String pattern) { + SimpleDateFormat formatter = new SimpleDateFormat(pattern); + return formatter.format(date); + } + + /** + * 根据起止日期生成日期序列 + * 包括start和end的日期 + * + * @param start + * @param end + * @return + */ + public static List generateDates(String start, String end) throws ParseException { + List dates = new ArrayList(); + Calendar s = Calendar.getInstance(); + Calendar e = Calendar.getInstance(); + s.setTime(TimeFormat.parse(start, DATE_FORMAT_STRING)); + s.set(Calendar.HOUR_OF_DAY, 0); + s.set(Calendar.MINUTE, 0); + s.set(Calendar.SECOND, 0); + e.setTime(TimeFormat.parse(end, DATE_FORMAT_STRING)); + e.set(Calendar.HOUR_OF_DAY, 0); + e.set(Calendar.MINUTE, 0); + e.set(Calendar.SECOND, 0); + while (s.before(e) == true) { + dates.add(TimeFormat.formatDate(s.getTime())); + s.add(Calendar.DATE, 1); + } + + dates.add(end); + return dates; + } + + + /** + * 解析日期字符串 + * + * @param String source + * @return Date + * + * @throws ParseException + */ + public static Date parse(String source) throws ParseException { + return defaultFormat.parse(source); + } + + /** + * 以指定模式解析日期 + * + * @param String source + * @param String pattern + * @return Date + * + * @throws ParseException + */ + public static Date parse(String source, String pattern) throws ParseException { + SimpleDateFormat formatter = new SimpleDateFormat(pattern); + return formatter.parse(source); + } + + + public static Date parseDateWithoutTime(String source) throws ParseException { + SimpleDateFormat formatter = new SimpleDateFormat(DATE_FORMAT_STRING); + Calendar date = Calendar.getInstance(); + date.setTime(formatter.parse(source)); + date.set(Calendar.HOUR, 0); + date.set(Calendar.HOUR, 0); + date.set(Calendar.MINUTE, 0); + return date.getTime(); + } + +} diff --git a/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java new file mode 100644 index 0000000..634ceae --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java @@ -0,0 +1,46 @@ +package com.casic.accessControl.app.domain; + +import javax.persistence.*; +import java.util.Date; + +/** + * app的版本信息 + */ +//工单 +@Entity +@Table(name = "apkVersion") +public class ApkVersion { + private String version; + private String path; + private Date ts;//时间戳 + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "version") + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + @Column(name = "path") + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + @Column(name = "ts") + public Date getTs() { + return ts; + } + + public void setTs(Date ts) { + this.ts = ts; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java new file mode 100644 index 0000000..1d0242a --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java @@ -0,0 +1,50 @@ +package com.casic.accessControl.app.dto; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.util.TimeFormat; + +/** + * Created by lenovo on 2016/4/13. + */ +public class ApkVersionDto { + private String version; + private String path; + private String ts; + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public String getTs() { + return ts; + } + + public void setTs(String ts) { + this.ts = ts; + } + + public static ApkVersionDto Convert(ApkVersion version) { + if (version == null) { + return null; + } + ApkVersionDto versionDto = new ApkVersionDto(); + versionDto.setVersion(version.getVersion()); + versionDto.setPath(version.getVersion()); + versionDto.setTs(TimeFormat.formatTimestamp(version.getTs())); + + return versionDto; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java b/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java new file mode 100644 index 0000000..28b12a7 --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java @@ -0,0 +1,27 @@ +package com.casic.accessControl.app.manager; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.core.hibernate.HibernateEntityDao; +import org.hibernate.Query; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * + */ +@Service("apkVersionManager") +public class ApkVersionManager extends HibernateEntityDao { + + public ApkVersion getLatestVersion() { + String sql = "from ApkVersion order by ts desc"; + Query query = getSession().createQuery(sql); + List list = query.list(); + if (null != list && list.isEmpty() == false) { + return list.get(0); + } + + return null; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java b/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java new file mode 100644 index 0000000..065d3cc --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java @@ -0,0 +1,66 @@ +package com.casic.accessControl.app.web; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.app.manager.ApkVersionManager; +import com.casic.accessControl.marker.domain.Marker; +import com.casic.accessControl.marker.manager.MarkerManager; +import com.casic.accessControl.task.domain.Task; +import com.casic.accessControl.task.domain.TaskDetail; +import com.casic.accessControl.task.dto.TaskDetailDto; +import com.casic.accessControl.task.dto.TaskDto; +import com.casic.accessControl.task.dto.TaskStatus; +import com.casic.accessControl.task.manager.TaskDetailManager; +import com.casic.accessControl.task.manager.TaskManager; +import com.casic.accessControl.user.domain.Company; +import com.casic.accessControl.user.domain.Role; +import com.casic.accessControl.user.domain.User; +import com.casic.accessControl.user.dto.UserDto; +import com.casic.accessControl.user.manager.RoleManager; +import com.casic.accessControl.user.manager.UserManager; +import com.casic.accessControl.util.DataTable; +import com.casic.accessControl.util.StringUtils; +import com.google.gson.Gson; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +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.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * Created by lenovo on 2016/4/13. + */ +@Controller +@RequestMapping("app") +public class ApkVersionController { + + @Resource + private ApkVersionManager apkVersionManager; + + @RequestMapping("get-latest-version") + @ResponseBody + public Map getLatestVersion(HttpServletResponse response, HttpSession session) { + Map result = new HashMap(); + try { + ApkVersion latest = apkVersionManager.getLatestVersion(); + if (null != latest) { + result.put("version", latest.getVersion()); + result.put("path", latest.getPath()); + } else { + result.put("version", "1.0.0"); + } + } catch (Exception e) { + e.printStackTrace(); + result.put("version", "1.0.0"); + } + + return result; + } + +} diff --git a/src/main/java/com/casic/accessControl/marker/domain/Marker.java b/src/main/java/com/casic/accessControl/marker/domain/Marker.java index 0575cfe..7d5b854 100644 --- a/src/main/java/com/casic/accessControl/marker/domain/Marker.java +++ b/src/main/java/com/casic/accessControl/marker/domain/Marker.java @@ -67,6 +67,10 @@ private String area; @Column(name = "line") private String line; + @Column(name = "colorType") + private String colorType; + @Column(name = "photos") + private String photos; @@ -315,4 +319,20 @@ public void setArea(String area) { this.area = area; } + + public String getColorType() { + return colorType; + } + + public void setColorType(String colorType) { + this.colorType = colorType; + } + + public String getPhotos() { + return photos; + } + + public void setPhotos(String photos) { + this.photos = photos; + } } diff --git a/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java b/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java index 506f31d..c5f8cf5 100644 --- a/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java +++ b/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java @@ -2,12 +2,12 @@ //import com.casic.accessControl.feature.domain.Feature; import com.casic.accessControl.marker.domain.Marker; +import com.casic.accessControl.util.StringUtils; +import com.casic.accessControl.util.TimeFormat; import org.apache.commons.collections.CollectionUtils; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.List; +import java.text.ParseException; +import java.util.*; /** * Created by lenovo on 2016/5/16. @@ -43,6 +43,8 @@ private Long userId; private String area; private String line; + private String colorType; + private String photos; private String btnEdit = "编辑"; private String btnDelete = "删除"; @@ -296,6 +298,23 @@ this.area = area; } + public String getColorType() { + if (StringUtils.isEmpty(colorType)) return "0"; + return colorType; + } + + public void setColorType(String colorType) { + this.colorType = colorType; + } + + public String getPhotos() { + return photos; + } + + public void setPhotos(String photos) { + this.photos = photos; + } + public String getLine() { return line; } @@ -335,6 +354,52 @@ result.setRoad(doNullChange(marker.getRoad())); result.setArea(doNullChange(marker.getArea())); result.setLine(doNullChange(marker.getLine())); + result.setColorType(marker.getColorType()); + result.setPhotos(marker.getPhotos()); + return result; + } + + public static Marker convert2Marker(MarkerDto markerDto) { + if (markerDto == null) return null; + Marker result = new Marker(); + if(markerDto.getLongitude()==null||markerDto.getLatitude()==null) return null; + if (null != markerDto.getCreateTime() && markerDto.getCreateTime().length() == 19) { + try { + result.setCreateTime(TimeFormat.parse(markerDto.getCreateTime(), "yyyy-MM-dd HH:mm:ss")); + } catch (ParseException pex) { + result.setCreateTime(Calendar.getInstance().getTime()); + } + } else { + result.setCreateTime(Calendar.getInstance().getTime()); + } + result.setDepth(doNullChange(markerDto.getDepth())); + result.setId(markerDto.getId()); + result.setLatitude(markerDto.getLatitude()); + result.setLongitude(markerDto.getLongitude()); + result.setMarkerId(markerDto.getMarkerId()); + result.setMarkerDepth(doNullChange(markerDto.getMarkerDepth())); + result.setMarkerObjectId(doNullChange(markerDto.getMarkerObjectId())); + result.setMarkerObjectType(doNullChange(markerDto.getMarkerObjectType())); + result.setOwnerComp(doNullChange(markerDto.getOwnerComp())); + result.setIsValid(markerDto.getIsValid()); + result.setMemo(doNullChange(markerDto.getMemo())); + result.setPipeDiameter(doNullChange(markerDto.getPipeDiameter())); + result.setPipeMaterial(doNullChange(markerDto.getPipeMaterial())); + result.setMarkerType(doNullChange(markerDto.getMarkerType())); + result.setCreator(doNullChange(markerDto.getCreator())); + + result.setLayStyle(doNullChange(markerDto.getLayStyle())); + result.setBelowDepth(doNullChange(markerDto.getBelowDepth())); + result.setBelowDiameter(doNullChange(markerDto.getBelowDiameter())); + result.setBelowMaterial(doNullChange(markerDto.getBelowMaterial())); + result.setBelowType(doNullChange(markerDto.getBelowType())); + result.setConstructTime(doNullChange(markerDto.getConstructTime())); + result.setRecordType(markerDto.getRecordType()); + result.setRoad(doNullChange(markerDto.getRoad())); + result.setArea(doNullChange(markerDto.getArea())); + result.setLine(doNullChange(markerDto.getLine())); + result.setColorType(markerDto.getColorType()); + result.setPhotos(markerDto.getPhotos()); return result; } diff --git a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java index dd0fa4b..ba5a1fb 100644 --- a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java +++ b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java @@ -9,10 +9,7 @@ import com.casic.accessControl.marker.domain.Marker; import com.casic.accessControl.user.domain.Company; import com.casic.accessControl.user.domain.User; -import com.casic.accessControl.util.DataTable; -import com.casic.accessControl.util.DataTableParameter; -import com.casic.accessControl.util.DataTableUtils; -import com.casic.accessControl.util.DateUtils; +import com.casic.accessControl.util.*; import com.google.gson.Gson; import jxl.*; import jxl.read.biff.BiffException; @@ -31,11 +28,15 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; +import sun.misc.BASE64Decoder; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.File; +import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.text.ParseException; @@ -183,6 +184,53 @@ } /** + * 保存标识器和图片信息 + * @param markerDto + * @param companyId + * @param fileNames + * @param fileBuffers + * @return + */ + public boolean saveMarkerAndPhotos(MarkerDto markerDto, Long companyId, String[] fileNames, String[] fileBuffers) { + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + String strDirPath = request.getSession().getServletContext().getRealPath(""); + FileOutputStream fos = null; + String month = TimeFormat.format(Calendar.getInstance().getTime(), "yyyyMM"); + String webPath = "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String toDir = strDirPath + "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String filePaths = ""; + try { + for (int i = 0; i < fileBuffers.length; i++) { + if (fileBuffers[i] != null && fileNames[i] != null) { +// filePaths += toDir+fileNames[i]+","; + filePaths += webPath + fileNames[i] + ","; + byte[] buffer = new BASE64Decoder().decodeBuffer(fileBuffers[i]); //对android传过来的图片字符串进行解码 + File destDir = new File(toDir); + if (!destDir.exists()) + destDir.mkdirs(); + File imageFile = new File(destDir, fileNames[i]); + fos = new FileOutputStream(imageFile); //保存图片 + fos.write(buffer); + fos.flush(); + fos.close(); + } + } + if (filePaths.endsWith(",")) { + filePaths = filePaths.substring(0, filePaths.length() - 1); + } + } catch (Exception e) { + return false; + } + Marker marker = MarkerDto.convert2Marker(markerDto); + marker.setIsValid(1); + marker.setCompanyId(companyId); + marker.setPhotos(filePaths); + save(marker); + return true; + + } + + /** * 新增标识器 8-9 * * @param markers @@ -582,7 +630,7 @@ "所属区域","所属线路","所属道路","建设年代","权属单位","标示对象ID", "标识器ID","标识器类型","标识器埋深","安装部门","经度", "纬度", "最后修改时间","备注","下层管种类", "下层管埋深", - "下层管直径", "下层管材料", "标识对象类别"}; + "下层管直径", "下层管材料", "标识对象类别", "标识点颜色", "图片地址"}; Label[][] labels = new Label[markerDtos.size() + 1][titleTxt.length]; for(int k=0;k saveMarkerAndPhotos(@RequestParam(value = "fileBuffer1", required = false) MultipartFile fileBuffer1, + @RequestParam(value = "fileBuffer2", required = false) MultipartFile fileBuffer2, + @RequestParam(value = "fileBuffer3", required = false) MultipartFile fileBuffer3, + @RequestParam(value = "jsonMarker", required = true) String jsonMarker) { + Map map = new HashMap(); + map.put("message", "安装无标识器信息"); + Gson gson = new Gson(); + try { + MarkerDto marker = gson.fromJson(jsonMarker, MarkerDto.class); + + if (null == marker.getMarkerId()) { + map.put("message", "无标识器ID"); + map.put("success", "false"); + return map; + } else if (markerManager.getMarkerByMarkerId(marker.getMarkerId()).size() > 0) { + map.put("message", "已安装过该标识器[" + marker.getMarkerId() + "]"); + map.put("success", "false"); + return map; + } else { + String[] fileNames = new String[3]; + String[] fileBuffers = new String[3]; + if (fileBuffer1 != null) { + fileNames[0] = marker.getMarkerId() + "_" + fileBuffer1.getOriginalFilename(); + byte[] fis = fileBuffer1.getBytes(); + fileBuffers[0] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, com.sun.org.apache.xml.internal.security.utils.Base64.BASE64DEFAULTLENGTH)); + } + if (fileBuffer2 != null) { + fileNames[1] = marker.getMarkerId() + "_" + fileBuffer2.getOriginalFilename(); + byte[] fis = fileBuffer2.getBytes(); + fileBuffers[1] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, com.sun.org.apache.xml.internal.security.utils.Base64.BASE64DEFAULTLENGTH)); + } + if (fileBuffer3 != null) { + fileNames[2] = marker.getMarkerId() + "_" + fileBuffer3.getOriginalFilename(); + byte[] fis = fileBuffer3.getBytes(); + fileBuffers[2] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, Base64.BASE64DEFAULTLENGTH)); + } + Long companyId = marker.getCompanyId(); + if (companyId == null) { + return map; + } + boolean result = markerManager.saveMarkerAndPhotos(marker, companyId, fileNames, fileBuffers); + if (!result) { + return map; + } + } + } catch (Exception e) { + return map; + } + map.put("success", "true"); + map.put("message", "保存成功"); + return map; + } + + @RequestMapping("marker-info-delete") @ResponseBody public Map delete(@RequestParam(value = "id", required = true) Long id) { @@ -144,6 +208,9 @@ map.put("message", "删除需要ID信息"); return map; } + + System.out.println(ids); + markerManager.delMarkerByIds(ids); map.put("success", true); map.put("message", "删除成功"); @@ -240,6 +307,54 @@ return map; } + /** + * 批量上传标识点,用于无信号地区标识器信息统一上传,不修改已有标识点信息 + * @param strMarkers + * @return + */ + @RequestMapping("batch-save-no-update") + @ResponseBody + public Map batchSaveOrUpdate(@RequestParam(value = "markers", required = true) String strMarkers) { + strMarkers = strMarkers.replace('\n',' '); + Map map = new HashMap(); + map.put("message", "批量导入失败,或无导入标识器信息"); + Gson gson = new Gson(); + try { + List markers = gson.fromJson(strMarkers, new TypeToken>() { + }.getType()); + if (CollectionUtils.isEmpty(markers)) {//批量导入数据不存在,直接返回 + map.put("message", "批量导入数据不存在"); + return map; + } + + Long companyId = markers.get(0).getCompanyId(); + if (companyId == null) { + map.put("message", "未找到所属公司属性"); + return map; + } + + List markerDtoForSave = new ArrayList(); + for (MarkerDto markerDto : markers) { + // 上传marker的Id不为空且数据库中不存在记录,经纬度不为空,允许保存 + if (StringUtils.isNotBlank(markerDto.getMarkerId()) && markerManager.getMarkerByMarkerId(markerDto.getMarkerId()).size() <= 0) { + if (null != markerDto.getLongitude() && null != markerDto.getLatitude()) { + markerDtoForSave.add(markerDto); + } + } + } + boolean result = markerManager.batchSave(markerDtoForSave, companyId); + if (!result) { + return map; + } + } catch (Exception e) { + e.printStackTrace(); + return map; + } + map.put("success", true); + map.put("message", "保存成功"); + return map; + } + @RequestMapping("getMarkerListByCondition") @ResponseBody @POST diff --git a/src/main/java/com/casic/accessControl/user/web/UserController.java b/src/main/java/com/casic/accessControl/user/web/UserController.java index feab678..3534a97 100644 --- a/src/main/java/com/casic/accessControl/user/web/UserController.java +++ b/src/main/java/com/casic/accessControl/user/web/UserController.java @@ -46,6 +46,7 @@ @ResponseBody public Map login(@ModelAttribute User userInfo, HttpSession session) { Map result = new HashMap(); + User user = null; try{ user = userManager.login(userInfo); diff --git a/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java b/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java new file mode 100644 index 0000000..582120f --- /dev/null +++ b/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java @@ -0,0 +1,129 @@ +package com.casic.accessControl.util; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.net.URL; +import java.net.URLConnection; +import java.util.List; +import java.util.Map; + +/** + * Created by lenovo on 2016/8/31. + */ +public class HttpRequestUtils { + + /** + * 向指定URL发送GET方法的请求 + * + * @param url + * 发送请求的URL + * @param param + * 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 + * @return URL 所代表远程资源的响应结果 + */ + public static String sendGet(String url, String param) { + String result = ""; + BufferedReader in = null; + try { + String urlNameString = url + "?" + param; + URL realUrl = new URL(urlNameString); + // 打开和URL之间的连接 + URLConnection connection = realUrl.openConnection(); + // 设置通用的请求属性 + connection.setRequestProperty("accept", "*/*"); + connection.setRequestProperty("connection", "Keep-Alive"); + connection.setRequestProperty("user-agent", + "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + // 建立实际的连接 + connection.connect(); + // 获取所有响应头字段 + Map> map = connection.getHeaderFields(); + // 遍历所有的响应头字段 + for (String key : map.keySet()) { + System.out.println(key + "--->" + map.get(key)); + } + // 定义 BufferedReader输入流来读取URL的响应 + in = new BufferedReader(new InputStreamReader( + connection.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + result += line; + } + } catch (Exception e) { + System.out.println("发送GET请求出现异常!" + e); + e.printStackTrace(); + } + // 使用finally块来关闭输入流 + finally { + try { + if (in != null) { + in.close(); + } + } catch (Exception e2) { + e2.printStackTrace(); + } + } + return result; + } + + /** + * 向指定 URL 发送POST方法的请求 + * + * @param url + * 发送请求的 URL + * @param param + * 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 + * @return 所代表远程资源的响应结果 + */ + public static String sendPost(String url, String param) { + PrintWriter out = null; + BufferedReader in = null; + String result = ""; + try { + URL realUrl = new URL(url); + // 打开和URL之间的连接 + URLConnection conn = realUrl.openConnection(); + // 设置通用的请求属性 + conn.setRequestProperty("accept", "*/*"); + conn.setRequestProperty("connection", "Keep-Alive"); + conn.setRequestProperty("user-agent", + "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + // 发送POST请求必须设置如下两行 + conn.setDoOutput(true); + conn.setDoInput(true); + // 获取URLConnection对象对应的输出流 + out = new PrintWriter(conn.getOutputStream()); + // 发送请求参数 + out.print(param); + // flush输出流的缓冲 + out.flush(); + // 定义BufferedReader输入流来读取URL的响应 + in = new BufferedReader( + new InputStreamReader(conn.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + result += line; + } + } catch (Exception e) { + System.out.println("发送 POST 请求出现异常!"+e); + e.printStackTrace(); + } + //使用finally块来关闭输出流、输入流 + finally{ + try{ + if(out!=null){ + out.close(); + } + if(in!=null){ + in.close(); + } + } + catch(IOException ex){ + ex.printStackTrace(); + } + } + return result; + } + } \ No newline at end of file diff --git a/src/main/java/com/casic/accessControl/util/TimeFormat.java b/src/main/java/com/casic/accessControl/util/TimeFormat.java new file mode 100644 index 0000000..e9168d5 --- /dev/null +++ b/src/main/java/com/casic/accessControl/util/TimeFormat.java @@ -0,0 +1,148 @@ +package com.casic.accessControl.util; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +/** + * 格式化日期工具类 + * 默认模式yyyy-MM-dd HH:mm:ss + * @author Administrator + * + */ +public class TimeFormat { + + private static final String DATE_FORMAT_STRING = "yyyy-MM-dd"; + private static final String TIME_FORMAT_STRING = "HH:mm:ss"; + private static final String TIMESTAMP_FORMAT_STRING = "yyyy-MM-dd HH:mm:ss"; + + // 默认格式化格式 + private static SimpleDateFormat defaultFormat = new SimpleDateFormat(TIMESTAMP_FORMAT_STRING); + + public static void setFormatString(String pattern) { + defaultFormat.applyPattern(pattern); + } + + /** + * 默认格式化日期 + * + * @param Date date + * @return String + */ + public static String format(Date date) { + return defaultFormat.format(date); + } + + /** + * 日期格式化 + * + * @param date + * @return + */ + public static String formatDate(Date date) { + return TimeFormat.format(date, DATE_FORMAT_STRING); + } + + /** + * 时间格式化 + * + * @param date + * @return + */ + public static String formatTime(Date date) { + return TimeFormat.format(date, TIME_FORMAT_STRING); + } + + /** + * 时间戳格式化 + * + * @param date + * @return + */ + public static String formatTimestamp(Date date) { + return TimeFormat.format(date, TIMESTAMP_FORMAT_STRING); + } + + /** + * 以指定模式格式化日期 + * + * @param Date date + * @param String pattern + * @return String + */ + public static String format(Date date, String pattern) { + SimpleDateFormat formatter = new SimpleDateFormat(pattern); + return formatter.format(date); + } + + /** + * 根据起止日期生成日期序列 + * 包括start和end的日期 + * + * @param start + * @param end + * @return + */ + public static List generateDates(String start, String end) throws ParseException { + List dates = new ArrayList(); + Calendar s = Calendar.getInstance(); + Calendar e = Calendar.getInstance(); + s.setTime(TimeFormat.parse(start, DATE_FORMAT_STRING)); + s.set(Calendar.HOUR_OF_DAY, 0); + s.set(Calendar.MINUTE, 0); + s.set(Calendar.SECOND, 0); + e.setTime(TimeFormat.parse(end, DATE_FORMAT_STRING)); + e.set(Calendar.HOUR_OF_DAY, 0); + e.set(Calendar.MINUTE, 0); + e.set(Calendar.SECOND, 0); + while (s.before(e) == true) { + dates.add(TimeFormat.formatDate(s.getTime())); + s.add(Calendar.DATE, 1); + } + + dates.add(end); + return dates; + } + + + /** + * 解析日期字符串 + * + * @param String source + * @return Date + * + * @throws ParseException + */ + public static Date parse(String source) throws ParseException { + return defaultFormat.parse(source); + } + + /** + * 以指定模式解析日期 + * + * @param String source + * @param String pattern + * @return Date + * + * @throws ParseException + */ + public static Date parse(String source, String pattern) throws ParseException { + SimpleDateFormat formatter = new SimpleDateFormat(pattern); + return formatter.parse(source); + } + + + public static Date parseDateWithoutTime(String source) throws ParseException { + SimpleDateFormat formatter = new SimpleDateFormat(DATE_FORMAT_STRING); + Calendar date = Calendar.getInstance(); + date.setTime(formatter.parse(source)); + date.set(Calendar.HOUR, 0); + date.set(Calendar.HOUR, 0); + date.set(Calendar.MINUTE, 0); + return date.getTime(); + } + +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 53c91ea..cea976f 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -15,19 +15,17 @@ # ============================================================================ # db # ============================================================================ -#db.default.driverClassName=oracle.jdbc.driver.OracleDriver -#db.default.url=jdbc:oracle:thin:@192.168.0.203:1521:SZHTDB2 -#db.default.username=scott -#db.default.password=SZHTDB2 db.default.driverClassName=com.mysql.jdbc.Driver -db.default.url=jdbc:mysql://127.0.0.1:3306/ems?useUnicode=true&characterEncoding=UTF-8 -db.default.username=emsweb -db.default.password=emsweb +db.default.url=jdbc:mysql://127.0.0.1:3306/ems_tong?useUnicode=true&characterEncoding=UTF-8 +db.default.username=root +db.default.password=root +#db.default.username=emsweb +#db.default.password=emsweb #db.default.url=jdbc:mysql://119.254.110.71:3307/ems?useUnicode=true&characterEncoding=UTF-8 #db.default.username=root #db.default.password=rootems - -# ============================================================================ +# +## ============================================================================ # log4jdbc # ============================================================================ log4jdbc.enable=true diff --git a/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java new file mode 100644 index 0000000..634ceae --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java @@ -0,0 +1,46 @@ +package com.casic.accessControl.app.domain; + +import javax.persistence.*; +import java.util.Date; + +/** + * app的版本信息 + */ +//工单 +@Entity +@Table(name = "apkVersion") +public class ApkVersion { + private String version; + private String path; + private Date ts;//时间戳 + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "version") + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + @Column(name = "path") + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + @Column(name = "ts") + public Date getTs() { + return ts; + } + + public void setTs(Date ts) { + this.ts = ts; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java new file mode 100644 index 0000000..1d0242a --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java @@ -0,0 +1,50 @@ +package com.casic.accessControl.app.dto; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.util.TimeFormat; + +/** + * Created by lenovo on 2016/4/13. + */ +public class ApkVersionDto { + private String version; + private String path; + private String ts; + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public String getTs() { + return ts; + } + + public void setTs(String ts) { + this.ts = ts; + } + + public static ApkVersionDto Convert(ApkVersion version) { + if (version == null) { + return null; + } + ApkVersionDto versionDto = new ApkVersionDto(); + versionDto.setVersion(version.getVersion()); + versionDto.setPath(version.getVersion()); + versionDto.setTs(TimeFormat.formatTimestamp(version.getTs())); + + return versionDto; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java b/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java new file mode 100644 index 0000000..28b12a7 --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java @@ -0,0 +1,27 @@ +package com.casic.accessControl.app.manager; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.core.hibernate.HibernateEntityDao; +import org.hibernate.Query; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * + */ +@Service("apkVersionManager") +public class ApkVersionManager extends HibernateEntityDao { + + public ApkVersion getLatestVersion() { + String sql = "from ApkVersion order by ts desc"; + Query query = getSession().createQuery(sql); + List list = query.list(); + if (null != list && list.isEmpty() == false) { + return list.get(0); + } + + return null; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java b/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java new file mode 100644 index 0000000..065d3cc --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java @@ -0,0 +1,66 @@ +package com.casic.accessControl.app.web; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.app.manager.ApkVersionManager; +import com.casic.accessControl.marker.domain.Marker; +import com.casic.accessControl.marker.manager.MarkerManager; +import com.casic.accessControl.task.domain.Task; +import com.casic.accessControl.task.domain.TaskDetail; +import com.casic.accessControl.task.dto.TaskDetailDto; +import com.casic.accessControl.task.dto.TaskDto; +import com.casic.accessControl.task.dto.TaskStatus; +import com.casic.accessControl.task.manager.TaskDetailManager; +import com.casic.accessControl.task.manager.TaskManager; +import com.casic.accessControl.user.domain.Company; +import com.casic.accessControl.user.domain.Role; +import com.casic.accessControl.user.domain.User; +import com.casic.accessControl.user.dto.UserDto; +import com.casic.accessControl.user.manager.RoleManager; +import com.casic.accessControl.user.manager.UserManager; +import com.casic.accessControl.util.DataTable; +import com.casic.accessControl.util.StringUtils; +import com.google.gson.Gson; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +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.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * Created by lenovo on 2016/4/13. + */ +@Controller +@RequestMapping("app") +public class ApkVersionController { + + @Resource + private ApkVersionManager apkVersionManager; + + @RequestMapping("get-latest-version") + @ResponseBody + public Map getLatestVersion(HttpServletResponse response, HttpSession session) { + Map result = new HashMap(); + try { + ApkVersion latest = apkVersionManager.getLatestVersion(); + if (null != latest) { + result.put("version", latest.getVersion()); + result.put("path", latest.getPath()); + } else { + result.put("version", "1.0.0"); + } + } catch (Exception e) { + e.printStackTrace(); + result.put("version", "1.0.0"); + } + + return result; + } + +} diff --git a/src/main/java/com/casic/accessControl/marker/domain/Marker.java b/src/main/java/com/casic/accessControl/marker/domain/Marker.java index 0575cfe..7d5b854 100644 --- a/src/main/java/com/casic/accessControl/marker/domain/Marker.java +++ b/src/main/java/com/casic/accessControl/marker/domain/Marker.java @@ -67,6 +67,10 @@ private String area; @Column(name = "line") private String line; + @Column(name = "colorType") + private String colorType; + @Column(name = "photos") + private String photos; @@ -315,4 +319,20 @@ public void setArea(String area) { this.area = area; } + + public String getColorType() { + return colorType; + } + + public void setColorType(String colorType) { + this.colorType = colorType; + } + + public String getPhotos() { + return photos; + } + + public void setPhotos(String photos) { + this.photos = photos; + } } diff --git a/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java b/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java index 506f31d..c5f8cf5 100644 --- a/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java +++ b/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java @@ -2,12 +2,12 @@ //import com.casic.accessControl.feature.domain.Feature; import com.casic.accessControl.marker.domain.Marker; +import com.casic.accessControl.util.StringUtils; +import com.casic.accessControl.util.TimeFormat; import org.apache.commons.collections.CollectionUtils; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.List; +import java.text.ParseException; +import java.util.*; /** * Created by lenovo on 2016/5/16. @@ -43,6 +43,8 @@ private Long userId; private String area; private String line; + private String colorType; + private String photos; private String btnEdit = "编辑"; private String btnDelete = "删除"; @@ -296,6 +298,23 @@ this.area = area; } + public String getColorType() { + if (StringUtils.isEmpty(colorType)) return "0"; + return colorType; + } + + public void setColorType(String colorType) { + this.colorType = colorType; + } + + public String getPhotos() { + return photos; + } + + public void setPhotos(String photos) { + this.photos = photos; + } + public String getLine() { return line; } @@ -335,6 +354,52 @@ result.setRoad(doNullChange(marker.getRoad())); result.setArea(doNullChange(marker.getArea())); result.setLine(doNullChange(marker.getLine())); + result.setColorType(marker.getColorType()); + result.setPhotos(marker.getPhotos()); + return result; + } + + public static Marker convert2Marker(MarkerDto markerDto) { + if (markerDto == null) return null; + Marker result = new Marker(); + if(markerDto.getLongitude()==null||markerDto.getLatitude()==null) return null; + if (null != markerDto.getCreateTime() && markerDto.getCreateTime().length() == 19) { + try { + result.setCreateTime(TimeFormat.parse(markerDto.getCreateTime(), "yyyy-MM-dd HH:mm:ss")); + } catch (ParseException pex) { + result.setCreateTime(Calendar.getInstance().getTime()); + } + } else { + result.setCreateTime(Calendar.getInstance().getTime()); + } + result.setDepth(doNullChange(markerDto.getDepth())); + result.setId(markerDto.getId()); + result.setLatitude(markerDto.getLatitude()); + result.setLongitude(markerDto.getLongitude()); + result.setMarkerId(markerDto.getMarkerId()); + result.setMarkerDepth(doNullChange(markerDto.getMarkerDepth())); + result.setMarkerObjectId(doNullChange(markerDto.getMarkerObjectId())); + result.setMarkerObjectType(doNullChange(markerDto.getMarkerObjectType())); + result.setOwnerComp(doNullChange(markerDto.getOwnerComp())); + result.setIsValid(markerDto.getIsValid()); + result.setMemo(doNullChange(markerDto.getMemo())); + result.setPipeDiameter(doNullChange(markerDto.getPipeDiameter())); + result.setPipeMaterial(doNullChange(markerDto.getPipeMaterial())); + result.setMarkerType(doNullChange(markerDto.getMarkerType())); + result.setCreator(doNullChange(markerDto.getCreator())); + + result.setLayStyle(doNullChange(markerDto.getLayStyle())); + result.setBelowDepth(doNullChange(markerDto.getBelowDepth())); + result.setBelowDiameter(doNullChange(markerDto.getBelowDiameter())); + result.setBelowMaterial(doNullChange(markerDto.getBelowMaterial())); + result.setBelowType(doNullChange(markerDto.getBelowType())); + result.setConstructTime(doNullChange(markerDto.getConstructTime())); + result.setRecordType(markerDto.getRecordType()); + result.setRoad(doNullChange(markerDto.getRoad())); + result.setArea(doNullChange(markerDto.getArea())); + result.setLine(doNullChange(markerDto.getLine())); + result.setColorType(markerDto.getColorType()); + result.setPhotos(markerDto.getPhotos()); return result; } diff --git a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java index dd0fa4b..ba5a1fb 100644 --- a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java +++ b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java @@ -9,10 +9,7 @@ import com.casic.accessControl.marker.domain.Marker; import com.casic.accessControl.user.domain.Company; import com.casic.accessControl.user.domain.User; -import com.casic.accessControl.util.DataTable; -import com.casic.accessControl.util.DataTableParameter; -import com.casic.accessControl.util.DataTableUtils; -import com.casic.accessControl.util.DateUtils; +import com.casic.accessControl.util.*; import com.google.gson.Gson; import jxl.*; import jxl.read.biff.BiffException; @@ -31,11 +28,15 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; +import sun.misc.BASE64Decoder; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.File; +import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.text.ParseException; @@ -183,6 +184,53 @@ } /** + * 保存标识器和图片信息 + * @param markerDto + * @param companyId + * @param fileNames + * @param fileBuffers + * @return + */ + public boolean saveMarkerAndPhotos(MarkerDto markerDto, Long companyId, String[] fileNames, String[] fileBuffers) { + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + String strDirPath = request.getSession().getServletContext().getRealPath(""); + FileOutputStream fos = null; + String month = TimeFormat.format(Calendar.getInstance().getTime(), "yyyyMM"); + String webPath = "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String toDir = strDirPath + "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String filePaths = ""; + try { + for (int i = 0; i < fileBuffers.length; i++) { + if (fileBuffers[i] != null && fileNames[i] != null) { +// filePaths += toDir+fileNames[i]+","; + filePaths += webPath + fileNames[i] + ","; + byte[] buffer = new BASE64Decoder().decodeBuffer(fileBuffers[i]); //对android传过来的图片字符串进行解码 + File destDir = new File(toDir); + if (!destDir.exists()) + destDir.mkdirs(); + File imageFile = new File(destDir, fileNames[i]); + fos = new FileOutputStream(imageFile); //保存图片 + fos.write(buffer); + fos.flush(); + fos.close(); + } + } + if (filePaths.endsWith(",")) { + filePaths = filePaths.substring(0, filePaths.length() - 1); + } + } catch (Exception e) { + return false; + } + Marker marker = MarkerDto.convert2Marker(markerDto); + marker.setIsValid(1); + marker.setCompanyId(companyId); + marker.setPhotos(filePaths); + save(marker); + return true; + + } + + /** * 新增标识器 8-9 * * @param markers @@ -582,7 +630,7 @@ "所属区域","所属线路","所属道路","建设年代","权属单位","标示对象ID", "标识器ID","标识器类型","标识器埋深","安装部门","经度", "纬度", "最后修改时间","备注","下层管种类", "下层管埋深", - "下层管直径", "下层管材料", "标识对象类别"}; + "下层管直径", "下层管材料", "标识对象类别", "标识点颜色", "图片地址"}; Label[][] labels = new Label[markerDtos.size() + 1][titleTxt.length]; for(int k=0;k saveMarkerAndPhotos(@RequestParam(value = "fileBuffer1", required = false) MultipartFile fileBuffer1, + @RequestParam(value = "fileBuffer2", required = false) MultipartFile fileBuffer2, + @RequestParam(value = "fileBuffer3", required = false) MultipartFile fileBuffer3, + @RequestParam(value = "jsonMarker", required = true) String jsonMarker) { + Map map = new HashMap(); + map.put("message", "安装无标识器信息"); + Gson gson = new Gson(); + try { + MarkerDto marker = gson.fromJson(jsonMarker, MarkerDto.class); + + if (null == marker.getMarkerId()) { + map.put("message", "无标识器ID"); + map.put("success", "false"); + return map; + } else if (markerManager.getMarkerByMarkerId(marker.getMarkerId()).size() > 0) { + map.put("message", "已安装过该标识器[" + marker.getMarkerId() + "]"); + map.put("success", "false"); + return map; + } else { + String[] fileNames = new String[3]; + String[] fileBuffers = new String[3]; + if (fileBuffer1 != null) { + fileNames[0] = marker.getMarkerId() + "_" + fileBuffer1.getOriginalFilename(); + byte[] fis = fileBuffer1.getBytes(); + fileBuffers[0] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, com.sun.org.apache.xml.internal.security.utils.Base64.BASE64DEFAULTLENGTH)); + } + if (fileBuffer2 != null) { + fileNames[1] = marker.getMarkerId() + "_" + fileBuffer2.getOriginalFilename(); + byte[] fis = fileBuffer2.getBytes(); + fileBuffers[1] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, com.sun.org.apache.xml.internal.security.utils.Base64.BASE64DEFAULTLENGTH)); + } + if (fileBuffer3 != null) { + fileNames[2] = marker.getMarkerId() + "_" + fileBuffer3.getOriginalFilename(); + byte[] fis = fileBuffer3.getBytes(); + fileBuffers[2] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, Base64.BASE64DEFAULTLENGTH)); + } + Long companyId = marker.getCompanyId(); + if (companyId == null) { + return map; + } + boolean result = markerManager.saveMarkerAndPhotos(marker, companyId, fileNames, fileBuffers); + if (!result) { + return map; + } + } + } catch (Exception e) { + return map; + } + map.put("success", "true"); + map.put("message", "保存成功"); + return map; + } + + @RequestMapping("marker-info-delete") @ResponseBody public Map delete(@RequestParam(value = "id", required = true) Long id) { @@ -144,6 +208,9 @@ map.put("message", "删除需要ID信息"); return map; } + + System.out.println(ids); + markerManager.delMarkerByIds(ids); map.put("success", true); map.put("message", "删除成功"); @@ -240,6 +307,54 @@ return map; } + /** + * 批量上传标识点,用于无信号地区标识器信息统一上传,不修改已有标识点信息 + * @param strMarkers + * @return + */ + @RequestMapping("batch-save-no-update") + @ResponseBody + public Map batchSaveOrUpdate(@RequestParam(value = "markers", required = true) String strMarkers) { + strMarkers = strMarkers.replace('\n',' '); + Map map = new HashMap(); + map.put("message", "批量导入失败,或无导入标识器信息"); + Gson gson = new Gson(); + try { + List markers = gson.fromJson(strMarkers, new TypeToken>() { + }.getType()); + if (CollectionUtils.isEmpty(markers)) {//批量导入数据不存在,直接返回 + map.put("message", "批量导入数据不存在"); + return map; + } + + Long companyId = markers.get(0).getCompanyId(); + if (companyId == null) { + map.put("message", "未找到所属公司属性"); + return map; + } + + List markerDtoForSave = new ArrayList(); + for (MarkerDto markerDto : markers) { + // 上传marker的Id不为空且数据库中不存在记录,经纬度不为空,允许保存 + if (StringUtils.isNotBlank(markerDto.getMarkerId()) && markerManager.getMarkerByMarkerId(markerDto.getMarkerId()).size() <= 0) { + if (null != markerDto.getLongitude() && null != markerDto.getLatitude()) { + markerDtoForSave.add(markerDto); + } + } + } + boolean result = markerManager.batchSave(markerDtoForSave, companyId); + if (!result) { + return map; + } + } catch (Exception e) { + e.printStackTrace(); + return map; + } + map.put("success", true); + map.put("message", "保存成功"); + return map; + } + @RequestMapping("getMarkerListByCondition") @ResponseBody @POST diff --git a/src/main/java/com/casic/accessControl/user/web/UserController.java b/src/main/java/com/casic/accessControl/user/web/UserController.java index feab678..3534a97 100644 --- a/src/main/java/com/casic/accessControl/user/web/UserController.java +++ b/src/main/java/com/casic/accessControl/user/web/UserController.java @@ -46,6 +46,7 @@ @ResponseBody public Map login(@ModelAttribute User userInfo, HttpSession session) { Map result = new HashMap(); + User user = null; try{ user = userManager.login(userInfo); diff --git a/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java b/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java new file mode 100644 index 0000000..582120f --- /dev/null +++ b/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java @@ -0,0 +1,129 @@ +package com.casic.accessControl.util; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.net.URL; +import java.net.URLConnection; +import java.util.List; +import java.util.Map; + +/** + * Created by lenovo on 2016/8/31. + */ +public class HttpRequestUtils { + + /** + * 向指定URL发送GET方法的请求 + * + * @param url + * 发送请求的URL + * @param param + * 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 + * @return URL 所代表远程资源的响应结果 + */ + public static String sendGet(String url, String param) { + String result = ""; + BufferedReader in = null; + try { + String urlNameString = url + "?" + param; + URL realUrl = new URL(urlNameString); + // 打开和URL之间的连接 + URLConnection connection = realUrl.openConnection(); + // 设置通用的请求属性 + connection.setRequestProperty("accept", "*/*"); + connection.setRequestProperty("connection", "Keep-Alive"); + connection.setRequestProperty("user-agent", + "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + // 建立实际的连接 + connection.connect(); + // 获取所有响应头字段 + Map> map = connection.getHeaderFields(); + // 遍历所有的响应头字段 + for (String key : map.keySet()) { + System.out.println(key + "--->" + map.get(key)); + } + // 定义 BufferedReader输入流来读取URL的响应 + in = new BufferedReader(new InputStreamReader( + connection.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + result += line; + } + } catch (Exception e) { + System.out.println("发送GET请求出现异常!" + e); + e.printStackTrace(); + } + // 使用finally块来关闭输入流 + finally { + try { + if (in != null) { + in.close(); + } + } catch (Exception e2) { + e2.printStackTrace(); + } + } + return result; + } + + /** + * 向指定 URL 发送POST方法的请求 + * + * @param url + * 发送请求的 URL + * @param param + * 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 + * @return 所代表远程资源的响应结果 + */ + public static String sendPost(String url, String param) { + PrintWriter out = null; + BufferedReader in = null; + String result = ""; + try { + URL realUrl = new URL(url); + // 打开和URL之间的连接 + URLConnection conn = realUrl.openConnection(); + // 设置通用的请求属性 + conn.setRequestProperty("accept", "*/*"); + conn.setRequestProperty("connection", "Keep-Alive"); + conn.setRequestProperty("user-agent", + "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + // 发送POST请求必须设置如下两行 + conn.setDoOutput(true); + conn.setDoInput(true); + // 获取URLConnection对象对应的输出流 + out = new PrintWriter(conn.getOutputStream()); + // 发送请求参数 + out.print(param); + // flush输出流的缓冲 + out.flush(); + // 定义BufferedReader输入流来读取URL的响应 + in = new BufferedReader( + new InputStreamReader(conn.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + result += line; + } + } catch (Exception e) { + System.out.println("发送 POST 请求出现异常!"+e); + e.printStackTrace(); + } + //使用finally块来关闭输出流、输入流 + finally{ + try{ + if(out!=null){ + out.close(); + } + if(in!=null){ + in.close(); + } + } + catch(IOException ex){ + ex.printStackTrace(); + } + } + return result; + } + } \ No newline at end of file diff --git a/src/main/java/com/casic/accessControl/util/TimeFormat.java b/src/main/java/com/casic/accessControl/util/TimeFormat.java new file mode 100644 index 0000000..e9168d5 --- /dev/null +++ b/src/main/java/com/casic/accessControl/util/TimeFormat.java @@ -0,0 +1,148 @@ +package com.casic.accessControl.util; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +/** + * 格式化日期工具类 + * 默认模式yyyy-MM-dd HH:mm:ss + * @author Administrator + * + */ +public class TimeFormat { + + private static final String DATE_FORMAT_STRING = "yyyy-MM-dd"; + private static final String TIME_FORMAT_STRING = "HH:mm:ss"; + private static final String TIMESTAMP_FORMAT_STRING = "yyyy-MM-dd HH:mm:ss"; + + // 默认格式化格式 + private static SimpleDateFormat defaultFormat = new SimpleDateFormat(TIMESTAMP_FORMAT_STRING); + + public static void setFormatString(String pattern) { + defaultFormat.applyPattern(pattern); + } + + /** + * 默认格式化日期 + * + * @param Date date + * @return String + */ + public static String format(Date date) { + return defaultFormat.format(date); + } + + /** + * 日期格式化 + * + * @param date + * @return + */ + public static String formatDate(Date date) { + return TimeFormat.format(date, DATE_FORMAT_STRING); + } + + /** + * 时间格式化 + * + * @param date + * @return + */ + public static String formatTime(Date date) { + return TimeFormat.format(date, TIME_FORMAT_STRING); + } + + /** + * 时间戳格式化 + * + * @param date + * @return + */ + public static String formatTimestamp(Date date) { + return TimeFormat.format(date, TIMESTAMP_FORMAT_STRING); + } + + /** + * 以指定模式格式化日期 + * + * @param Date date + * @param String pattern + * @return String + */ + public static String format(Date date, String pattern) { + SimpleDateFormat formatter = new SimpleDateFormat(pattern); + return formatter.format(date); + } + + /** + * 根据起止日期生成日期序列 + * 包括start和end的日期 + * + * @param start + * @param end + * @return + */ + public static List generateDates(String start, String end) throws ParseException { + List dates = new ArrayList(); + Calendar s = Calendar.getInstance(); + Calendar e = Calendar.getInstance(); + s.setTime(TimeFormat.parse(start, DATE_FORMAT_STRING)); + s.set(Calendar.HOUR_OF_DAY, 0); + s.set(Calendar.MINUTE, 0); + s.set(Calendar.SECOND, 0); + e.setTime(TimeFormat.parse(end, DATE_FORMAT_STRING)); + e.set(Calendar.HOUR_OF_DAY, 0); + e.set(Calendar.MINUTE, 0); + e.set(Calendar.SECOND, 0); + while (s.before(e) == true) { + dates.add(TimeFormat.formatDate(s.getTime())); + s.add(Calendar.DATE, 1); + } + + dates.add(end); + return dates; + } + + + /** + * 解析日期字符串 + * + * @param String source + * @return Date + * + * @throws ParseException + */ + public static Date parse(String source) throws ParseException { + return defaultFormat.parse(source); + } + + /** + * 以指定模式解析日期 + * + * @param String source + * @param String pattern + * @return Date + * + * @throws ParseException + */ + public static Date parse(String source, String pattern) throws ParseException { + SimpleDateFormat formatter = new SimpleDateFormat(pattern); + return formatter.parse(source); + } + + + public static Date parseDateWithoutTime(String source) throws ParseException { + SimpleDateFormat formatter = new SimpleDateFormat(DATE_FORMAT_STRING); + Calendar date = Calendar.getInstance(); + date.setTime(formatter.parse(source)); + date.set(Calendar.HOUR, 0); + date.set(Calendar.HOUR, 0); + date.set(Calendar.MINUTE, 0); + return date.getTime(); + } + +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 53c91ea..cea976f 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -15,19 +15,17 @@ # ============================================================================ # db # ============================================================================ -#db.default.driverClassName=oracle.jdbc.driver.OracleDriver -#db.default.url=jdbc:oracle:thin:@192.168.0.203:1521:SZHTDB2 -#db.default.username=scott -#db.default.password=SZHTDB2 db.default.driverClassName=com.mysql.jdbc.Driver -db.default.url=jdbc:mysql://127.0.0.1:3306/ems?useUnicode=true&characterEncoding=UTF-8 -db.default.username=emsweb -db.default.password=emsweb +db.default.url=jdbc:mysql://127.0.0.1:3306/ems_tong?useUnicode=true&characterEncoding=UTF-8 +db.default.username=root +db.default.password=root +#db.default.username=emsweb +#db.default.password=emsweb #db.default.url=jdbc:mysql://119.254.110.71:3307/ems?useUnicode=true&characterEncoding=UTF-8 #db.default.username=root #db.default.password=rootems - -# ============================================================================ +# +## ============================================================================ # log4jdbc # ============================================================================ log4jdbc.enable=true diff --git a/src/main/resources/spring/applicationContext-filter.xml b/src/main/resources/spring/applicationContext-filter.xml index a08c5fc..98ac7d6 100644 --- a/src/main/resources/spring/applicationContext-filter.xml +++ b/src/main/resources/spring/applicationContext-filter.xml @@ -35,9 +35,13 @@ /user/ill-login.do /marker/exportMarker.do /marker/batchSave-na.do + /marker/batch-save-no-update.do + /marker/save-marker-photo.do /event/save-event.do /task/get-task.do + /app/get-latest-version.do /xls/* + /apk/* diff --git a/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java new file mode 100644 index 0000000..634ceae --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java @@ -0,0 +1,46 @@ +package com.casic.accessControl.app.domain; + +import javax.persistence.*; +import java.util.Date; + +/** + * app的版本信息 + */ +//工单 +@Entity +@Table(name = "apkVersion") +public class ApkVersion { + private String version; + private String path; + private Date ts;//时间戳 + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "version") + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + @Column(name = "path") + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + @Column(name = "ts") + public Date getTs() { + return ts; + } + + public void setTs(Date ts) { + this.ts = ts; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java new file mode 100644 index 0000000..1d0242a --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java @@ -0,0 +1,50 @@ +package com.casic.accessControl.app.dto; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.util.TimeFormat; + +/** + * Created by lenovo on 2016/4/13. + */ +public class ApkVersionDto { + private String version; + private String path; + private String ts; + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public String getTs() { + return ts; + } + + public void setTs(String ts) { + this.ts = ts; + } + + public static ApkVersionDto Convert(ApkVersion version) { + if (version == null) { + return null; + } + ApkVersionDto versionDto = new ApkVersionDto(); + versionDto.setVersion(version.getVersion()); + versionDto.setPath(version.getVersion()); + versionDto.setTs(TimeFormat.formatTimestamp(version.getTs())); + + return versionDto; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java b/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java new file mode 100644 index 0000000..28b12a7 --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java @@ -0,0 +1,27 @@ +package com.casic.accessControl.app.manager; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.core.hibernate.HibernateEntityDao; +import org.hibernate.Query; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * + */ +@Service("apkVersionManager") +public class ApkVersionManager extends HibernateEntityDao { + + public ApkVersion getLatestVersion() { + String sql = "from ApkVersion order by ts desc"; + Query query = getSession().createQuery(sql); + List list = query.list(); + if (null != list && list.isEmpty() == false) { + return list.get(0); + } + + return null; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java b/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java new file mode 100644 index 0000000..065d3cc --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java @@ -0,0 +1,66 @@ +package com.casic.accessControl.app.web; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.app.manager.ApkVersionManager; +import com.casic.accessControl.marker.domain.Marker; +import com.casic.accessControl.marker.manager.MarkerManager; +import com.casic.accessControl.task.domain.Task; +import com.casic.accessControl.task.domain.TaskDetail; +import com.casic.accessControl.task.dto.TaskDetailDto; +import com.casic.accessControl.task.dto.TaskDto; +import com.casic.accessControl.task.dto.TaskStatus; +import com.casic.accessControl.task.manager.TaskDetailManager; +import com.casic.accessControl.task.manager.TaskManager; +import com.casic.accessControl.user.domain.Company; +import com.casic.accessControl.user.domain.Role; +import com.casic.accessControl.user.domain.User; +import com.casic.accessControl.user.dto.UserDto; +import com.casic.accessControl.user.manager.RoleManager; +import com.casic.accessControl.user.manager.UserManager; +import com.casic.accessControl.util.DataTable; +import com.casic.accessControl.util.StringUtils; +import com.google.gson.Gson; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +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.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * Created by lenovo on 2016/4/13. + */ +@Controller +@RequestMapping("app") +public class ApkVersionController { + + @Resource + private ApkVersionManager apkVersionManager; + + @RequestMapping("get-latest-version") + @ResponseBody + public Map getLatestVersion(HttpServletResponse response, HttpSession session) { + Map result = new HashMap(); + try { + ApkVersion latest = apkVersionManager.getLatestVersion(); + if (null != latest) { + result.put("version", latest.getVersion()); + result.put("path", latest.getPath()); + } else { + result.put("version", "1.0.0"); + } + } catch (Exception e) { + e.printStackTrace(); + result.put("version", "1.0.0"); + } + + return result; + } + +} diff --git a/src/main/java/com/casic/accessControl/marker/domain/Marker.java b/src/main/java/com/casic/accessControl/marker/domain/Marker.java index 0575cfe..7d5b854 100644 --- a/src/main/java/com/casic/accessControl/marker/domain/Marker.java +++ b/src/main/java/com/casic/accessControl/marker/domain/Marker.java @@ -67,6 +67,10 @@ private String area; @Column(name = "line") private String line; + @Column(name = "colorType") + private String colorType; + @Column(name = "photos") + private String photos; @@ -315,4 +319,20 @@ public void setArea(String area) { this.area = area; } + + public String getColorType() { + return colorType; + } + + public void setColorType(String colorType) { + this.colorType = colorType; + } + + public String getPhotos() { + return photos; + } + + public void setPhotos(String photos) { + this.photos = photos; + } } diff --git a/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java b/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java index 506f31d..c5f8cf5 100644 --- a/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java +++ b/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java @@ -2,12 +2,12 @@ //import com.casic.accessControl.feature.domain.Feature; import com.casic.accessControl.marker.domain.Marker; +import com.casic.accessControl.util.StringUtils; +import com.casic.accessControl.util.TimeFormat; import org.apache.commons.collections.CollectionUtils; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.List; +import java.text.ParseException; +import java.util.*; /** * Created by lenovo on 2016/5/16. @@ -43,6 +43,8 @@ private Long userId; private String area; private String line; + private String colorType; + private String photos; private String btnEdit = "编辑"; private String btnDelete = "删除"; @@ -296,6 +298,23 @@ this.area = area; } + public String getColorType() { + if (StringUtils.isEmpty(colorType)) return "0"; + return colorType; + } + + public void setColorType(String colorType) { + this.colorType = colorType; + } + + public String getPhotos() { + return photos; + } + + public void setPhotos(String photos) { + this.photos = photos; + } + public String getLine() { return line; } @@ -335,6 +354,52 @@ result.setRoad(doNullChange(marker.getRoad())); result.setArea(doNullChange(marker.getArea())); result.setLine(doNullChange(marker.getLine())); + result.setColorType(marker.getColorType()); + result.setPhotos(marker.getPhotos()); + return result; + } + + public static Marker convert2Marker(MarkerDto markerDto) { + if (markerDto == null) return null; + Marker result = new Marker(); + if(markerDto.getLongitude()==null||markerDto.getLatitude()==null) return null; + if (null != markerDto.getCreateTime() && markerDto.getCreateTime().length() == 19) { + try { + result.setCreateTime(TimeFormat.parse(markerDto.getCreateTime(), "yyyy-MM-dd HH:mm:ss")); + } catch (ParseException pex) { + result.setCreateTime(Calendar.getInstance().getTime()); + } + } else { + result.setCreateTime(Calendar.getInstance().getTime()); + } + result.setDepth(doNullChange(markerDto.getDepth())); + result.setId(markerDto.getId()); + result.setLatitude(markerDto.getLatitude()); + result.setLongitude(markerDto.getLongitude()); + result.setMarkerId(markerDto.getMarkerId()); + result.setMarkerDepth(doNullChange(markerDto.getMarkerDepth())); + result.setMarkerObjectId(doNullChange(markerDto.getMarkerObjectId())); + result.setMarkerObjectType(doNullChange(markerDto.getMarkerObjectType())); + result.setOwnerComp(doNullChange(markerDto.getOwnerComp())); + result.setIsValid(markerDto.getIsValid()); + result.setMemo(doNullChange(markerDto.getMemo())); + result.setPipeDiameter(doNullChange(markerDto.getPipeDiameter())); + result.setPipeMaterial(doNullChange(markerDto.getPipeMaterial())); + result.setMarkerType(doNullChange(markerDto.getMarkerType())); + result.setCreator(doNullChange(markerDto.getCreator())); + + result.setLayStyle(doNullChange(markerDto.getLayStyle())); + result.setBelowDepth(doNullChange(markerDto.getBelowDepth())); + result.setBelowDiameter(doNullChange(markerDto.getBelowDiameter())); + result.setBelowMaterial(doNullChange(markerDto.getBelowMaterial())); + result.setBelowType(doNullChange(markerDto.getBelowType())); + result.setConstructTime(doNullChange(markerDto.getConstructTime())); + result.setRecordType(markerDto.getRecordType()); + result.setRoad(doNullChange(markerDto.getRoad())); + result.setArea(doNullChange(markerDto.getArea())); + result.setLine(doNullChange(markerDto.getLine())); + result.setColorType(markerDto.getColorType()); + result.setPhotos(markerDto.getPhotos()); return result; } diff --git a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java index dd0fa4b..ba5a1fb 100644 --- a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java +++ b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java @@ -9,10 +9,7 @@ import com.casic.accessControl.marker.domain.Marker; import com.casic.accessControl.user.domain.Company; import com.casic.accessControl.user.domain.User; -import com.casic.accessControl.util.DataTable; -import com.casic.accessControl.util.DataTableParameter; -import com.casic.accessControl.util.DataTableUtils; -import com.casic.accessControl.util.DateUtils; +import com.casic.accessControl.util.*; import com.google.gson.Gson; import jxl.*; import jxl.read.biff.BiffException; @@ -31,11 +28,15 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; +import sun.misc.BASE64Decoder; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.File; +import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.text.ParseException; @@ -183,6 +184,53 @@ } /** + * 保存标识器和图片信息 + * @param markerDto + * @param companyId + * @param fileNames + * @param fileBuffers + * @return + */ + public boolean saveMarkerAndPhotos(MarkerDto markerDto, Long companyId, String[] fileNames, String[] fileBuffers) { + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + String strDirPath = request.getSession().getServletContext().getRealPath(""); + FileOutputStream fos = null; + String month = TimeFormat.format(Calendar.getInstance().getTime(), "yyyyMM"); + String webPath = "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String toDir = strDirPath + "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String filePaths = ""; + try { + for (int i = 0; i < fileBuffers.length; i++) { + if (fileBuffers[i] != null && fileNames[i] != null) { +// filePaths += toDir+fileNames[i]+","; + filePaths += webPath + fileNames[i] + ","; + byte[] buffer = new BASE64Decoder().decodeBuffer(fileBuffers[i]); //对android传过来的图片字符串进行解码 + File destDir = new File(toDir); + if (!destDir.exists()) + destDir.mkdirs(); + File imageFile = new File(destDir, fileNames[i]); + fos = new FileOutputStream(imageFile); //保存图片 + fos.write(buffer); + fos.flush(); + fos.close(); + } + } + if (filePaths.endsWith(",")) { + filePaths = filePaths.substring(0, filePaths.length() - 1); + } + } catch (Exception e) { + return false; + } + Marker marker = MarkerDto.convert2Marker(markerDto); + marker.setIsValid(1); + marker.setCompanyId(companyId); + marker.setPhotos(filePaths); + save(marker); + return true; + + } + + /** * 新增标识器 8-9 * * @param markers @@ -582,7 +630,7 @@ "所属区域","所属线路","所属道路","建设年代","权属单位","标示对象ID", "标识器ID","标识器类型","标识器埋深","安装部门","经度", "纬度", "最后修改时间","备注","下层管种类", "下层管埋深", - "下层管直径", "下层管材料", "标识对象类别"}; + "下层管直径", "下层管材料", "标识对象类别", "标识点颜色", "图片地址"}; Label[][] labels = new Label[markerDtos.size() + 1][titleTxt.length]; for(int k=0;k saveMarkerAndPhotos(@RequestParam(value = "fileBuffer1", required = false) MultipartFile fileBuffer1, + @RequestParam(value = "fileBuffer2", required = false) MultipartFile fileBuffer2, + @RequestParam(value = "fileBuffer3", required = false) MultipartFile fileBuffer3, + @RequestParam(value = "jsonMarker", required = true) String jsonMarker) { + Map map = new HashMap(); + map.put("message", "安装无标识器信息"); + Gson gson = new Gson(); + try { + MarkerDto marker = gson.fromJson(jsonMarker, MarkerDto.class); + + if (null == marker.getMarkerId()) { + map.put("message", "无标识器ID"); + map.put("success", "false"); + return map; + } else if (markerManager.getMarkerByMarkerId(marker.getMarkerId()).size() > 0) { + map.put("message", "已安装过该标识器[" + marker.getMarkerId() + "]"); + map.put("success", "false"); + return map; + } else { + String[] fileNames = new String[3]; + String[] fileBuffers = new String[3]; + if (fileBuffer1 != null) { + fileNames[0] = marker.getMarkerId() + "_" + fileBuffer1.getOriginalFilename(); + byte[] fis = fileBuffer1.getBytes(); + fileBuffers[0] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, com.sun.org.apache.xml.internal.security.utils.Base64.BASE64DEFAULTLENGTH)); + } + if (fileBuffer2 != null) { + fileNames[1] = marker.getMarkerId() + "_" + fileBuffer2.getOriginalFilename(); + byte[] fis = fileBuffer2.getBytes(); + fileBuffers[1] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, com.sun.org.apache.xml.internal.security.utils.Base64.BASE64DEFAULTLENGTH)); + } + if (fileBuffer3 != null) { + fileNames[2] = marker.getMarkerId() + "_" + fileBuffer3.getOriginalFilename(); + byte[] fis = fileBuffer3.getBytes(); + fileBuffers[2] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, Base64.BASE64DEFAULTLENGTH)); + } + Long companyId = marker.getCompanyId(); + if (companyId == null) { + return map; + } + boolean result = markerManager.saveMarkerAndPhotos(marker, companyId, fileNames, fileBuffers); + if (!result) { + return map; + } + } + } catch (Exception e) { + return map; + } + map.put("success", "true"); + map.put("message", "保存成功"); + return map; + } + + @RequestMapping("marker-info-delete") @ResponseBody public Map delete(@RequestParam(value = "id", required = true) Long id) { @@ -144,6 +208,9 @@ map.put("message", "删除需要ID信息"); return map; } + + System.out.println(ids); + markerManager.delMarkerByIds(ids); map.put("success", true); map.put("message", "删除成功"); @@ -240,6 +307,54 @@ return map; } + /** + * 批量上传标识点,用于无信号地区标识器信息统一上传,不修改已有标识点信息 + * @param strMarkers + * @return + */ + @RequestMapping("batch-save-no-update") + @ResponseBody + public Map batchSaveOrUpdate(@RequestParam(value = "markers", required = true) String strMarkers) { + strMarkers = strMarkers.replace('\n',' '); + Map map = new HashMap(); + map.put("message", "批量导入失败,或无导入标识器信息"); + Gson gson = new Gson(); + try { + List markers = gson.fromJson(strMarkers, new TypeToken>() { + }.getType()); + if (CollectionUtils.isEmpty(markers)) {//批量导入数据不存在,直接返回 + map.put("message", "批量导入数据不存在"); + return map; + } + + Long companyId = markers.get(0).getCompanyId(); + if (companyId == null) { + map.put("message", "未找到所属公司属性"); + return map; + } + + List markerDtoForSave = new ArrayList(); + for (MarkerDto markerDto : markers) { + // 上传marker的Id不为空且数据库中不存在记录,经纬度不为空,允许保存 + if (StringUtils.isNotBlank(markerDto.getMarkerId()) && markerManager.getMarkerByMarkerId(markerDto.getMarkerId()).size() <= 0) { + if (null != markerDto.getLongitude() && null != markerDto.getLatitude()) { + markerDtoForSave.add(markerDto); + } + } + } + boolean result = markerManager.batchSave(markerDtoForSave, companyId); + if (!result) { + return map; + } + } catch (Exception e) { + e.printStackTrace(); + return map; + } + map.put("success", true); + map.put("message", "保存成功"); + return map; + } + @RequestMapping("getMarkerListByCondition") @ResponseBody @POST diff --git a/src/main/java/com/casic/accessControl/user/web/UserController.java b/src/main/java/com/casic/accessControl/user/web/UserController.java index feab678..3534a97 100644 --- a/src/main/java/com/casic/accessControl/user/web/UserController.java +++ b/src/main/java/com/casic/accessControl/user/web/UserController.java @@ -46,6 +46,7 @@ @ResponseBody public Map login(@ModelAttribute User userInfo, HttpSession session) { Map result = new HashMap(); + User user = null; try{ user = userManager.login(userInfo); diff --git a/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java b/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java new file mode 100644 index 0000000..582120f --- /dev/null +++ b/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java @@ -0,0 +1,129 @@ +package com.casic.accessControl.util; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.net.URL; +import java.net.URLConnection; +import java.util.List; +import java.util.Map; + +/** + * Created by lenovo on 2016/8/31. + */ +public class HttpRequestUtils { + + /** + * 向指定URL发送GET方法的请求 + * + * @param url + * 发送请求的URL + * @param param + * 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 + * @return URL 所代表远程资源的响应结果 + */ + public static String sendGet(String url, String param) { + String result = ""; + BufferedReader in = null; + try { + String urlNameString = url + "?" + param; + URL realUrl = new URL(urlNameString); + // 打开和URL之间的连接 + URLConnection connection = realUrl.openConnection(); + // 设置通用的请求属性 + connection.setRequestProperty("accept", "*/*"); + connection.setRequestProperty("connection", "Keep-Alive"); + connection.setRequestProperty("user-agent", + "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + // 建立实际的连接 + connection.connect(); + // 获取所有响应头字段 + Map> map = connection.getHeaderFields(); + // 遍历所有的响应头字段 + for (String key : map.keySet()) { + System.out.println(key + "--->" + map.get(key)); + } + // 定义 BufferedReader输入流来读取URL的响应 + in = new BufferedReader(new InputStreamReader( + connection.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + result += line; + } + } catch (Exception e) { + System.out.println("发送GET请求出现异常!" + e); + e.printStackTrace(); + } + // 使用finally块来关闭输入流 + finally { + try { + if (in != null) { + in.close(); + } + } catch (Exception e2) { + e2.printStackTrace(); + } + } + return result; + } + + /** + * 向指定 URL 发送POST方法的请求 + * + * @param url + * 发送请求的 URL + * @param param + * 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 + * @return 所代表远程资源的响应结果 + */ + public static String sendPost(String url, String param) { + PrintWriter out = null; + BufferedReader in = null; + String result = ""; + try { + URL realUrl = new URL(url); + // 打开和URL之间的连接 + URLConnection conn = realUrl.openConnection(); + // 设置通用的请求属性 + conn.setRequestProperty("accept", "*/*"); + conn.setRequestProperty("connection", "Keep-Alive"); + conn.setRequestProperty("user-agent", + "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + // 发送POST请求必须设置如下两行 + conn.setDoOutput(true); + conn.setDoInput(true); + // 获取URLConnection对象对应的输出流 + out = new PrintWriter(conn.getOutputStream()); + // 发送请求参数 + out.print(param); + // flush输出流的缓冲 + out.flush(); + // 定义BufferedReader输入流来读取URL的响应 + in = new BufferedReader( + new InputStreamReader(conn.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + result += line; + } + } catch (Exception e) { + System.out.println("发送 POST 请求出现异常!"+e); + e.printStackTrace(); + } + //使用finally块来关闭输出流、输入流 + finally{ + try{ + if(out!=null){ + out.close(); + } + if(in!=null){ + in.close(); + } + } + catch(IOException ex){ + ex.printStackTrace(); + } + } + return result; + } + } \ No newline at end of file diff --git a/src/main/java/com/casic/accessControl/util/TimeFormat.java b/src/main/java/com/casic/accessControl/util/TimeFormat.java new file mode 100644 index 0000000..e9168d5 --- /dev/null +++ b/src/main/java/com/casic/accessControl/util/TimeFormat.java @@ -0,0 +1,148 @@ +package com.casic.accessControl.util; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +/** + * 格式化日期工具类 + * 默认模式yyyy-MM-dd HH:mm:ss + * @author Administrator + * + */ +public class TimeFormat { + + private static final String DATE_FORMAT_STRING = "yyyy-MM-dd"; + private static final String TIME_FORMAT_STRING = "HH:mm:ss"; + private static final String TIMESTAMP_FORMAT_STRING = "yyyy-MM-dd HH:mm:ss"; + + // 默认格式化格式 + private static SimpleDateFormat defaultFormat = new SimpleDateFormat(TIMESTAMP_FORMAT_STRING); + + public static void setFormatString(String pattern) { + defaultFormat.applyPattern(pattern); + } + + /** + * 默认格式化日期 + * + * @param Date date + * @return String + */ + public static String format(Date date) { + return defaultFormat.format(date); + } + + /** + * 日期格式化 + * + * @param date + * @return + */ + public static String formatDate(Date date) { + return TimeFormat.format(date, DATE_FORMAT_STRING); + } + + /** + * 时间格式化 + * + * @param date + * @return + */ + public static String formatTime(Date date) { + return TimeFormat.format(date, TIME_FORMAT_STRING); + } + + /** + * 时间戳格式化 + * + * @param date + * @return + */ + public static String formatTimestamp(Date date) { + return TimeFormat.format(date, TIMESTAMP_FORMAT_STRING); + } + + /** + * 以指定模式格式化日期 + * + * @param Date date + * @param String pattern + * @return String + */ + public static String format(Date date, String pattern) { + SimpleDateFormat formatter = new SimpleDateFormat(pattern); + return formatter.format(date); + } + + /** + * 根据起止日期生成日期序列 + * 包括start和end的日期 + * + * @param start + * @param end + * @return + */ + public static List generateDates(String start, String end) throws ParseException { + List dates = new ArrayList(); + Calendar s = Calendar.getInstance(); + Calendar e = Calendar.getInstance(); + s.setTime(TimeFormat.parse(start, DATE_FORMAT_STRING)); + s.set(Calendar.HOUR_OF_DAY, 0); + s.set(Calendar.MINUTE, 0); + s.set(Calendar.SECOND, 0); + e.setTime(TimeFormat.parse(end, DATE_FORMAT_STRING)); + e.set(Calendar.HOUR_OF_DAY, 0); + e.set(Calendar.MINUTE, 0); + e.set(Calendar.SECOND, 0); + while (s.before(e) == true) { + dates.add(TimeFormat.formatDate(s.getTime())); + s.add(Calendar.DATE, 1); + } + + dates.add(end); + return dates; + } + + + /** + * 解析日期字符串 + * + * @param String source + * @return Date + * + * @throws ParseException + */ + public static Date parse(String source) throws ParseException { + return defaultFormat.parse(source); + } + + /** + * 以指定模式解析日期 + * + * @param String source + * @param String pattern + * @return Date + * + * @throws ParseException + */ + public static Date parse(String source, String pattern) throws ParseException { + SimpleDateFormat formatter = new SimpleDateFormat(pattern); + return formatter.parse(source); + } + + + public static Date parseDateWithoutTime(String source) throws ParseException { + SimpleDateFormat formatter = new SimpleDateFormat(DATE_FORMAT_STRING); + Calendar date = Calendar.getInstance(); + date.setTime(formatter.parse(source)); + date.set(Calendar.HOUR, 0); + date.set(Calendar.HOUR, 0); + date.set(Calendar.MINUTE, 0); + return date.getTime(); + } + +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 53c91ea..cea976f 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -15,19 +15,17 @@ # ============================================================================ # db # ============================================================================ -#db.default.driverClassName=oracle.jdbc.driver.OracleDriver -#db.default.url=jdbc:oracle:thin:@192.168.0.203:1521:SZHTDB2 -#db.default.username=scott -#db.default.password=SZHTDB2 db.default.driverClassName=com.mysql.jdbc.Driver -db.default.url=jdbc:mysql://127.0.0.1:3306/ems?useUnicode=true&characterEncoding=UTF-8 -db.default.username=emsweb -db.default.password=emsweb +db.default.url=jdbc:mysql://127.0.0.1:3306/ems_tong?useUnicode=true&characterEncoding=UTF-8 +db.default.username=root +db.default.password=root +#db.default.username=emsweb +#db.default.password=emsweb #db.default.url=jdbc:mysql://119.254.110.71:3307/ems?useUnicode=true&characterEncoding=UTF-8 #db.default.username=root #db.default.password=rootems - -# ============================================================================ +# +## ============================================================================ # log4jdbc # ============================================================================ log4jdbc.enable=true diff --git a/src/main/resources/spring/applicationContext-filter.xml b/src/main/resources/spring/applicationContext-filter.xml index a08c5fc..98ac7d6 100644 --- a/src/main/resources/spring/applicationContext-filter.xml +++ b/src/main/resources/spring/applicationContext-filter.xml @@ -35,9 +35,13 @@ /user/ill-login.do /marker/exportMarker.do /marker/batchSave-na.do + /marker/batch-save-no-update.do + /marker/save-marker-photo.do /event/save-event.do /task/get-task.do + /app/get-latest-version.do /xls/* + /apk/* diff --git a/src/main/resources/spring/applicationContext-hibernate.xml b/src/main/resources/spring/applicationContext-hibernate.xml index 5bb1a7e..dc54192 100644 --- a/src/main/resources/spring/applicationContext-hibernate.xml +++ b/src/main/resources/spring/applicationContext-hibernate.xml @@ -65,6 +65,7 @@ com.casic.accessControl.task.domain.Position com.casic.accessControl.event.domain.Event com.casic.accessControl.marker.domain.OptionItem + com.casic.accessControl.app.domain.ApkVersion diff --git a/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java new file mode 100644 index 0000000..634ceae --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java @@ -0,0 +1,46 @@ +package com.casic.accessControl.app.domain; + +import javax.persistence.*; +import java.util.Date; + +/** + * app的版本信息 + */ +//工单 +@Entity +@Table(name = "apkVersion") +public class ApkVersion { + private String version; + private String path; + private Date ts;//时间戳 + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "version") + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + @Column(name = "path") + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + @Column(name = "ts") + public Date getTs() { + return ts; + } + + public void setTs(Date ts) { + this.ts = ts; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java new file mode 100644 index 0000000..1d0242a --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java @@ -0,0 +1,50 @@ +package com.casic.accessControl.app.dto; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.util.TimeFormat; + +/** + * Created by lenovo on 2016/4/13. + */ +public class ApkVersionDto { + private String version; + private String path; + private String ts; + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public String getTs() { + return ts; + } + + public void setTs(String ts) { + this.ts = ts; + } + + public static ApkVersionDto Convert(ApkVersion version) { + if (version == null) { + return null; + } + ApkVersionDto versionDto = new ApkVersionDto(); + versionDto.setVersion(version.getVersion()); + versionDto.setPath(version.getVersion()); + versionDto.setTs(TimeFormat.formatTimestamp(version.getTs())); + + return versionDto; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java b/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java new file mode 100644 index 0000000..28b12a7 --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java @@ -0,0 +1,27 @@ +package com.casic.accessControl.app.manager; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.core.hibernate.HibernateEntityDao; +import org.hibernate.Query; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * + */ +@Service("apkVersionManager") +public class ApkVersionManager extends HibernateEntityDao { + + public ApkVersion getLatestVersion() { + String sql = "from ApkVersion order by ts desc"; + Query query = getSession().createQuery(sql); + List list = query.list(); + if (null != list && list.isEmpty() == false) { + return list.get(0); + } + + return null; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java b/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java new file mode 100644 index 0000000..065d3cc --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java @@ -0,0 +1,66 @@ +package com.casic.accessControl.app.web; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.app.manager.ApkVersionManager; +import com.casic.accessControl.marker.domain.Marker; +import com.casic.accessControl.marker.manager.MarkerManager; +import com.casic.accessControl.task.domain.Task; +import com.casic.accessControl.task.domain.TaskDetail; +import com.casic.accessControl.task.dto.TaskDetailDto; +import com.casic.accessControl.task.dto.TaskDto; +import com.casic.accessControl.task.dto.TaskStatus; +import com.casic.accessControl.task.manager.TaskDetailManager; +import com.casic.accessControl.task.manager.TaskManager; +import com.casic.accessControl.user.domain.Company; +import com.casic.accessControl.user.domain.Role; +import com.casic.accessControl.user.domain.User; +import com.casic.accessControl.user.dto.UserDto; +import com.casic.accessControl.user.manager.RoleManager; +import com.casic.accessControl.user.manager.UserManager; +import com.casic.accessControl.util.DataTable; +import com.casic.accessControl.util.StringUtils; +import com.google.gson.Gson; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +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.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * Created by lenovo on 2016/4/13. + */ +@Controller +@RequestMapping("app") +public class ApkVersionController { + + @Resource + private ApkVersionManager apkVersionManager; + + @RequestMapping("get-latest-version") + @ResponseBody + public Map getLatestVersion(HttpServletResponse response, HttpSession session) { + Map result = new HashMap(); + try { + ApkVersion latest = apkVersionManager.getLatestVersion(); + if (null != latest) { + result.put("version", latest.getVersion()); + result.put("path", latest.getPath()); + } else { + result.put("version", "1.0.0"); + } + } catch (Exception e) { + e.printStackTrace(); + result.put("version", "1.0.0"); + } + + return result; + } + +} diff --git a/src/main/java/com/casic/accessControl/marker/domain/Marker.java b/src/main/java/com/casic/accessControl/marker/domain/Marker.java index 0575cfe..7d5b854 100644 --- a/src/main/java/com/casic/accessControl/marker/domain/Marker.java +++ b/src/main/java/com/casic/accessControl/marker/domain/Marker.java @@ -67,6 +67,10 @@ private String area; @Column(name = "line") private String line; + @Column(name = "colorType") + private String colorType; + @Column(name = "photos") + private String photos; @@ -315,4 +319,20 @@ public void setArea(String area) { this.area = area; } + + public String getColorType() { + return colorType; + } + + public void setColorType(String colorType) { + this.colorType = colorType; + } + + public String getPhotos() { + return photos; + } + + public void setPhotos(String photos) { + this.photos = photos; + } } diff --git a/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java b/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java index 506f31d..c5f8cf5 100644 --- a/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java +++ b/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java @@ -2,12 +2,12 @@ //import com.casic.accessControl.feature.domain.Feature; import com.casic.accessControl.marker.domain.Marker; +import com.casic.accessControl.util.StringUtils; +import com.casic.accessControl.util.TimeFormat; import org.apache.commons.collections.CollectionUtils; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.List; +import java.text.ParseException; +import java.util.*; /** * Created by lenovo on 2016/5/16. @@ -43,6 +43,8 @@ private Long userId; private String area; private String line; + private String colorType; + private String photos; private String btnEdit = "编辑"; private String btnDelete = "删除"; @@ -296,6 +298,23 @@ this.area = area; } + public String getColorType() { + if (StringUtils.isEmpty(colorType)) return "0"; + return colorType; + } + + public void setColorType(String colorType) { + this.colorType = colorType; + } + + public String getPhotos() { + return photos; + } + + public void setPhotos(String photos) { + this.photos = photos; + } + public String getLine() { return line; } @@ -335,6 +354,52 @@ result.setRoad(doNullChange(marker.getRoad())); result.setArea(doNullChange(marker.getArea())); result.setLine(doNullChange(marker.getLine())); + result.setColorType(marker.getColorType()); + result.setPhotos(marker.getPhotos()); + return result; + } + + public static Marker convert2Marker(MarkerDto markerDto) { + if (markerDto == null) return null; + Marker result = new Marker(); + if(markerDto.getLongitude()==null||markerDto.getLatitude()==null) return null; + if (null != markerDto.getCreateTime() && markerDto.getCreateTime().length() == 19) { + try { + result.setCreateTime(TimeFormat.parse(markerDto.getCreateTime(), "yyyy-MM-dd HH:mm:ss")); + } catch (ParseException pex) { + result.setCreateTime(Calendar.getInstance().getTime()); + } + } else { + result.setCreateTime(Calendar.getInstance().getTime()); + } + result.setDepth(doNullChange(markerDto.getDepth())); + result.setId(markerDto.getId()); + result.setLatitude(markerDto.getLatitude()); + result.setLongitude(markerDto.getLongitude()); + result.setMarkerId(markerDto.getMarkerId()); + result.setMarkerDepth(doNullChange(markerDto.getMarkerDepth())); + result.setMarkerObjectId(doNullChange(markerDto.getMarkerObjectId())); + result.setMarkerObjectType(doNullChange(markerDto.getMarkerObjectType())); + result.setOwnerComp(doNullChange(markerDto.getOwnerComp())); + result.setIsValid(markerDto.getIsValid()); + result.setMemo(doNullChange(markerDto.getMemo())); + result.setPipeDiameter(doNullChange(markerDto.getPipeDiameter())); + result.setPipeMaterial(doNullChange(markerDto.getPipeMaterial())); + result.setMarkerType(doNullChange(markerDto.getMarkerType())); + result.setCreator(doNullChange(markerDto.getCreator())); + + result.setLayStyle(doNullChange(markerDto.getLayStyle())); + result.setBelowDepth(doNullChange(markerDto.getBelowDepth())); + result.setBelowDiameter(doNullChange(markerDto.getBelowDiameter())); + result.setBelowMaterial(doNullChange(markerDto.getBelowMaterial())); + result.setBelowType(doNullChange(markerDto.getBelowType())); + result.setConstructTime(doNullChange(markerDto.getConstructTime())); + result.setRecordType(markerDto.getRecordType()); + result.setRoad(doNullChange(markerDto.getRoad())); + result.setArea(doNullChange(markerDto.getArea())); + result.setLine(doNullChange(markerDto.getLine())); + result.setColorType(markerDto.getColorType()); + result.setPhotos(markerDto.getPhotos()); return result; } diff --git a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java index dd0fa4b..ba5a1fb 100644 --- a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java +++ b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java @@ -9,10 +9,7 @@ import com.casic.accessControl.marker.domain.Marker; import com.casic.accessControl.user.domain.Company; import com.casic.accessControl.user.domain.User; -import com.casic.accessControl.util.DataTable; -import com.casic.accessControl.util.DataTableParameter; -import com.casic.accessControl.util.DataTableUtils; -import com.casic.accessControl.util.DateUtils; +import com.casic.accessControl.util.*; import com.google.gson.Gson; import jxl.*; import jxl.read.biff.BiffException; @@ -31,11 +28,15 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; +import sun.misc.BASE64Decoder; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.File; +import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.text.ParseException; @@ -183,6 +184,53 @@ } /** + * 保存标识器和图片信息 + * @param markerDto + * @param companyId + * @param fileNames + * @param fileBuffers + * @return + */ + public boolean saveMarkerAndPhotos(MarkerDto markerDto, Long companyId, String[] fileNames, String[] fileBuffers) { + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + String strDirPath = request.getSession().getServletContext().getRealPath(""); + FileOutputStream fos = null; + String month = TimeFormat.format(Calendar.getInstance().getTime(), "yyyyMM"); + String webPath = "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String toDir = strDirPath + "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String filePaths = ""; + try { + for (int i = 0; i < fileBuffers.length; i++) { + if (fileBuffers[i] != null && fileNames[i] != null) { +// filePaths += toDir+fileNames[i]+","; + filePaths += webPath + fileNames[i] + ","; + byte[] buffer = new BASE64Decoder().decodeBuffer(fileBuffers[i]); //对android传过来的图片字符串进行解码 + File destDir = new File(toDir); + if (!destDir.exists()) + destDir.mkdirs(); + File imageFile = new File(destDir, fileNames[i]); + fos = new FileOutputStream(imageFile); //保存图片 + fos.write(buffer); + fos.flush(); + fos.close(); + } + } + if (filePaths.endsWith(",")) { + filePaths = filePaths.substring(0, filePaths.length() - 1); + } + } catch (Exception e) { + return false; + } + Marker marker = MarkerDto.convert2Marker(markerDto); + marker.setIsValid(1); + marker.setCompanyId(companyId); + marker.setPhotos(filePaths); + save(marker); + return true; + + } + + /** * 新增标识器 8-9 * * @param markers @@ -582,7 +630,7 @@ "所属区域","所属线路","所属道路","建设年代","权属单位","标示对象ID", "标识器ID","标识器类型","标识器埋深","安装部门","经度", "纬度", "最后修改时间","备注","下层管种类", "下层管埋深", - "下层管直径", "下层管材料", "标识对象类别"}; + "下层管直径", "下层管材料", "标识对象类别", "标识点颜色", "图片地址"}; Label[][] labels = new Label[markerDtos.size() + 1][titleTxt.length]; for(int k=0;k saveMarkerAndPhotos(@RequestParam(value = "fileBuffer1", required = false) MultipartFile fileBuffer1, + @RequestParam(value = "fileBuffer2", required = false) MultipartFile fileBuffer2, + @RequestParam(value = "fileBuffer3", required = false) MultipartFile fileBuffer3, + @RequestParam(value = "jsonMarker", required = true) String jsonMarker) { + Map map = new HashMap(); + map.put("message", "安装无标识器信息"); + Gson gson = new Gson(); + try { + MarkerDto marker = gson.fromJson(jsonMarker, MarkerDto.class); + + if (null == marker.getMarkerId()) { + map.put("message", "无标识器ID"); + map.put("success", "false"); + return map; + } else if (markerManager.getMarkerByMarkerId(marker.getMarkerId()).size() > 0) { + map.put("message", "已安装过该标识器[" + marker.getMarkerId() + "]"); + map.put("success", "false"); + return map; + } else { + String[] fileNames = new String[3]; + String[] fileBuffers = new String[3]; + if (fileBuffer1 != null) { + fileNames[0] = marker.getMarkerId() + "_" + fileBuffer1.getOriginalFilename(); + byte[] fis = fileBuffer1.getBytes(); + fileBuffers[0] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, com.sun.org.apache.xml.internal.security.utils.Base64.BASE64DEFAULTLENGTH)); + } + if (fileBuffer2 != null) { + fileNames[1] = marker.getMarkerId() + "_" + fileBuffer2.getOriginalFilename(); + byte[] fis = fileBuffer2.getBytes(); + fileBuffers[1] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, com.sun.org.apache.xml.internal.security.utils.Base64.BASE64DEFAULTLENGTH)); + } + if (fileBuffer3 != null) { + fileNames[2] = marker.getMarkerId() + "_" + fileBuffer3.getOriginalFilename(); + byte[] fis = fileBuffer3.getBytes(); + fileBuffers[2] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, Base64.BASE64DEFAULTLENGTH)); + } + Long companyId = marker.getCompanyId(); + if (companyId == null) { + return map; + } + boolean result = markerManager.saveMarkerAndPhotos(marker, companyId, fileNames, fileBuffers); + if (!result) { + return map; + } + } + } catch (Exception e) { + return map; + } + map.put("success", "true"); + map.put("message", "保存成功"); + return map; + } + + @RequestMapping("marker-info-delete") @ResponseBody public Map delete(@RequestParam(value = "id", required = true) Long id) { @@ -144,6 +208,9 @@ map.put("message", "删除需要ID信息"); return map; } + + System.out.println(ids); + markerManager.delMarkerByIds(ids); map.put("success", true); map.put("message", "删除成功"); @@ -240,6 +307,54 @@ return map; } + /** + * 批量上传标识点,用于无信号地区标识器信息统一上传,不修改已有标识点信息 + * @param strMarkers + * @return + */ + @RequestMapping("batch-save-no-update") + @ResponseBody + public Map batchSaveOrUpdate(@RequestParam(value = "markers", required = true) String strMarkers) { + strMarkers = strMarkers.replace('\n',' '); + Map map = new HashMap(); + map.put("message", "批量导入失败,或无导入标识器信息"); + Gson gson = new Gson(); + try { + List markers = gson.fromJson(strMarkers, new TypeToken>() { + }.getType()); + if (CollectionUtils.isEmpty(markers)) {//批量导入数据不存在,直接返回 + map.put("message", "批量导入数据不存在"); + return map; + } + + Long companyId = markers.get(0).getCompanyId(); + if (companyId == null) { + map.put("message", "未找到所属公司属性"); + return map; + } + + List markerDtoForSave = new ArrayList(); + for (MarkerDto markerDto : markers) { + // 上传marker的Id不为空且数据库中不存在记录,经纬度不为空,允许保存 + if (StringUtils.isNotBlank(markerDto.getMarkerId()) && markerManager.getMarkerByMarkerId(markerDto.getMarkerId()).size() <= 0) { + if (null != markerDto.getLongitude() && null != markerDto.getLatitude()) { + markerDtoForSave.add(markerDto); + } + } + } + boolean result = markerManager.batchSave(markerDtoForSave, companyId); + if (!result) { + return map; + } + } catch (Exception e) { + e.printStackTrace(); + return map; + } + map.put("success", true); + map.put("message", "保存成功"); + return map; + } + @RequestMapping("getMarkerListByCondition") @ResponseBody @POST diff --git a/src/main/java/com/casic/accessControl/user/web/UserController.java b/src/main/java/com/casic/accessControl/user/web/UserController.java index feab678..3534a97 100644 --- a/src/main/java/com/casic/accessControl/user/web/UserController.java +++ b/src/main/java/com/casic/accessControl/user/web/UserController.java @@ -46,6 +46,7 @@ @ResponseBody public Map login(@ModelAttribute User userInfo, HttpSession session) { Map result = new HashMap(); + User user = null; try{ user = userManager.login(userInfo); diff --git a/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java b/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java new file mode 100644 index 0000000..582120f --- /dev/null +++ b/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java @@ -0,0 +1,129 @@ +package com.casic.accessControl.util; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.net.URL; +import java.net.URLConnection; +import java.util.List; +import java.util.Map; + +/** + * Created by lenovo on 2016/8/31. + */ +public class HttpRequestUtils { + + /** + * 向指定URL发送GET方法的请求 + * + * @param url + * 发送请求的URL + * @param param + * 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 + * @return URL 所代表远程资源的响应结果 + */ + public static String sendGet(String url, String param) { + String result = ""; + BufferedReader in = null; + try { + String urlNameString = url + "?" + param; + URL realUrl = new URL(urlNameString); + // 打开和URL之间的连接 + URLConnection connection = realUrl.openConnection(); + // 设置通用的请求属性 + connection.setRequestProperty("accept", "*/*"); + connection.setRequestProperty("connection", "Keep-Alive"); + connection.setRequestProperty("user-agent", + "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + // 建立实际的连接 + connection.connect(); + // 获取所有响应头字段 + Map> map = connection.getHeaderFields(); + // 遍历所有的响应头字段 + for (String key : map.keySet()) { + System.out.println(key + "--->" + map.get(key)); + } + // 定义 BufferedReader输入流来读取URL的响应 + in = new BufferedReader(new InputStreamReader( + connection.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + result += line; + } + } catch (Exception e) { + System.out.println("发送GET请求出现异常!" + e); + e.printStackTrace(); + } + // 使用finally块来关闭输入流 + finally { + try { + if (in != null) { + in.close(); + } + } catch (Exception e2) { + e2.printStackTrace(); + } + } + return result; + } + + /** + * 向指定 URL 发送POST方法的请求 + * + * @param url + * 发送请求的 URL + * @param param + * 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 + * @return 所代表远程资源的响应结果 + */ + public static String sendPost(String url, String param) { + PrintWriter out = null; + BufferedReader in = null; + String result = ""; + try { + URL realUrl = new URL(url); + // 打开和URL之间的连接 + URLConnection conn = realUrl.openConnection(); + // 设置通用的请求属性 + conn.setRequestProperty("accept", "*/*"); + conn.setRequestProperty("connection", "Keep-Alive"); + conn.setRequestProperty("user-agent", + "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + // 发送POST请求必须设置如下两行 + conn.setDoOutput(true); + conn.setDoInput(true); + // 获取URLConnection对象对应的输出流 + out = new PrintWriter(conn.getOutputStream()); + // 发送请求参数 + out.print(param); + // flush输出流的缓冲 + out.flush(); + // 定义BufferedReader输入流来读取URL的响应 + in = new BufferedReader( + new InputStreamReader(conn.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + result += line; + } + } catch (Exception e) { + System.out.println("发送 POST 请求出现异常!"+e); + e.printStackTrace(); + } + //使用finally块来关闭输出流、输入流 + finally{ + try{ + if(out!=null){ + out.close(); + } + if(in!=null){ + in.close(); + } + } + catch(IOException ex){ + ex.printStackTrace(); + } + } + return result; + } + } \ No newline at end of file diff --git a/src/main/java/com/casic/accessControl/util/TimeFormat.java b/src/main/java/com/casic/accessControl/util/TimeFormat.java new file mode 100644 index 0000000..e9168d5 --- /dev/null +++ b/src/main/java/com/casic/accessControl/util/TimeFormat.java @@ -0,0 +1,148 @@ +package com.casic.accessControl.util; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +/** + * 格式化日期工具类 + * 默认模式yyyy-MM-dd HH:mm:ss + * @author Administrator + * + */ +public class TimeFormat { + + private static final String DATE_FORMAT_STRING = "yyyy-MM-dd"; + private static final String TIME_FORMAT_STRING = "HH:mm:ss"; + private static final String TIMESTAMP_FORMAT_STRING = "yyyy-MM-dd HH:mm:ss"; + + // 默认格式化格式 + private static SimpleDateFormat defaultFormat = new SimpleDateFormat(TIMESTAMP_FORMAT_STRING); + + public static void setFormatString(String pattern) { + defaultFormat.applyPattern(pattern); + } + + /** + * 默认格式化日期 + * + * @param Date date + * @return String + */ + public static String format(Date date) { + return defaultFormat.format(date); + } + + /** + * 日期格式化 + * + * @param date + * @return + */ + public static String formatDate(Date date) { + return TimeFormat.format(date, DATE_FORMAT_STRING); + } + + /** + * 时间格式化 + * + * @param date + * @return + */ + public static String formatTime(Date date) { + return TimeFormat.format(date, TIME_FORMAT_STRING); + } + + /** + * 时间戳格式化 + * + * @param date + * @return + */ + public static String formatTimestamp(Date date) { + return TimeFormat.format(date, TIMESTAMP_FORMAT_STRING); + } + + /** + * 以指定模式格式化日期 + * + * @param Date date + * @param String pattern + * @return String + */ + public static String format(Date date, String pattern) { + SimpleDateFormat formatter = new SimpleDateFormat(pattern); + return formatter.format(date); + } + + /** + * 根据起止日期生成日期序列 + * 包括start和end的日期 + * + * @param start + * @param end + * @return + */ + public static List generateDates(String start, String end) throws ParseException { + List dates = new ArrayList(); + Calendar s = Calendar.getInstance(); + Calendar e = Calendar.getInstance(); + s.setTime(TimeFormat.parse(start, DATE_FORMAT_STRING)); + s.set(Calendar.HOUR_OF_DAY, 0); + s.set(Calendar.MINUTE, 0); + s.set(Calendar.SECOND, 0); + e.setTime(TimeFormat.parse(end, DATE_FORMAT_STRING)); + e.set(Calendar.HOUR_OF_DAY, 0); + e.set(Calendar.MINUTE, 0); + e.set(Calendar.SECOND, 0); + while (s.before(e) == true) { + dates.add(TimeFormat.formatDate(s.getTime())); + s.add(Calendar.DATE, 1); + } + + dates.add(end); + return dates; + } + + + /** + * 解析日期字符串 + * + * @param String source + * @return Date + * + * @throws ParseException + */ + public static Date parse(String source) throws ParseException { + return defaultFormat.parse(source); + } + + /** + * 以指定模式解析日期 + * + * @param String source + * @param String pattern + * @return Date + * + * @throws ParseException + */ + public static Date parse(String source, String pattern) throws ParseException { + SimpleDateFormat formatter = new SimpleDateFormat(pattern); + return formatter.parse(source); + } + + + public static Date parseDateWithoutTime(String source) throws ParseException { + SimpleDateFormat formatter = new SimpleDateFormat(DATE_FORMAT_STRING); + Calendar date = Calendar.getInstance(); + date.setTime(formatter.parse(source)); + date.set(Calendar.HOUR, 0); + date.set(Calendar.HOUR, 0); + date.set(Calendar.MINUTE, 0); + return date.getTime(); + } + +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 53c91ea..cea976f 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -15,19 +15,17 @@ # ============================================================================ # db # ============================================================================ -#db.default.driverClassName=oracle.jdbc.driver.OracleDriver -#db.default.url=jdbc:oracle:thin:@192.168.0.203:1521:SZHTDB2 -#db.default.username=scott -#db.default.password=SZHTDB2 db.default.driverClassName=com.mysql.jdbc.Driver -db.default.url=jdbc:mysql://127.0.0.1:3306/ems?useUnicode=true&characterEncoding=UTF-8 -db.default.username=emsweb -db.default.password=emsweb +db.default.url=jdbc:mysql://127.0.0.1:3306/ems_tong?useUnicode=true&characterEncoding=UTF-8 +db.default.username=root +db.default.password=root +#db.default.username=emsweb +#db.default.password=emsweb #db.default.url=jdbc:mysql://119.254.110.71:3307/ems?useUnicode=true&characterEncoding=UTF-8 #db.default.username=root #db.default.password=rootems - -# ============================================================================ +# +## ============================================================================ # log4jdbc # ============================================================================ log4jdbc.enable=true diff --git a/src/main/resources/spring/applicationContext-filter.xml b/src/main/resources/spring/applicationContext-filter.xml index a08c5fc..98ac7d6 100644 --- a/src/main/resources/spring/applicationContext-filter.xml +++ b/src/main/resources/spring/applicationContext-filter.xml @@ -35,9 +35,13 @@ /user/ill-login.do /marker/exportMarker.do /marker/batchSave-na.do + /marker/batch-save-no-update.do + /marker/save-marker-photo.do /event/save-event.do /task/get-task.do + /app/get-latest-version.do /xls/* + /apk/* diff --git a/src/main/resources/spring/applicationContext-hibernate.xml b/src/main/resources/spring/applicationContext-hibernate.xml index 5bb1a7e..dc54192 100644 --- a/src/main/resources/spring/applicationContext-hibernate.xml +++ b/src/main/resources/spring/applicationContext-hibernate.xml @@ -65,6 +65,7 @@ com.casic.accessControl.task.domain.Position com.casic.accessControl.event.domain.Event com.casic.accessControl.marker.domain.OptionItem + com.casic.accessControl.app.domain.ApkVersion diff --git a/src/main/webapp/common/layout/menu_new.jsp b/src/main/webapp/common/layout/menu_new.jsp index 3cf4b4e..cbd822e 100644 --- a/src/main/webapp/common/layout/menu_new.jsp +++ b/src/main/webapp/common/layout/menu_new.jsp @@ -20,7 +20,7 @@
  • - + @@ -54,7 +54,7 @@
  • - + diff --git a/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java new file mode 100644 index 0000000..634ceae --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java @@ -0,0 +1,46 @@ +package com.casic.accessControl.app.domain; + +import javax.persistence.*; +import java.util.Date; + +/** + * app的版本信息 + */ +//工单 +@Entity +@Table(name = "apkVersion") +public class ApkVersion { + private String version; + private String path; + private Date ts;//时间戳 + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "version") + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + @Column(name = "path") + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + @Column(name = "ts") + public Date getTs() { + return ts; + } + + public void setTs(Date ts) { + this.ts = ts; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java new file mode 100644 index 0000000..1d0242a --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java @@ -0,0 +1,50 @@ +package com.casic.accessControl.app.dto; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.util.TimeFormat; + +/** + * Created by lenovo on 2016/4/13. + */ +public class ApkVersionDto { + private String version; + private String path; + private String ts; + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public String getTs() { + return ts; + } + + public void setTs(String ts) { + this.ts = ts; + } + + public static ApkVersionDto Convert(ApkVersion version) { + if (version == null) { + return null; + } + ApkVersionDto versionDto = new ApkVersionDto(); + versionDto.setVersion(version.getVersion()); + versionDto.setPath(version.getVersion()); + versionDto.setTs(TimeFormat.formatTimestamp(version.getTs())); + + return versionDto; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java b/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java new file mode 100644 index 0000000..28b12a7 --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java @@ -0,0 +1,27 @@ +package com.casic.accessControl.app.manager; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.core.hibernate.HibernateEntityDao; +import org.hibernate.Query; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * + */ +@Service("apkVersionManager") +public class ApkVersionManager extends HibernateEntityDao { + + public ApkVersion getLatestVersion() { + String sql = "from ApkVersion order by ts desc"; + Query query = getSession().createQuery(sql); + List list = query.list(); + if (null != list && list.isEmpty() == false) { + return list.get(0); + } + + return null; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java b/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java new file mode 100644 index 0000000..065d3cc --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java @@ -0,0 +1,66 @@ +package com.casic.accessControl.app.web; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.app.manager.ApkVersionManager; +import com.casic.accessControl.marker.domain.Marker; +import com.casic.accessControl.marker.manager.MarkerManager; +import com.casic.accessControl.task.domain.Task; +import com.casic.accessControl.task.domain.TaskDetail; +import com.casic.accessControl.task.dto.TaskDetailDto; +import com.casic.accessControl.task.dto.TaskDto; +import com.casic.accessControl.task.dto.TaskStatus; +import com.casic.accessControl.task.manager.TaskDetailManager; +import com.casic.accessControl.task.manager.TaskManager; +import com.casic.accessControl.user.domain.Company; +import com.casic.accessControl.user.domain.Role; +import com.casic.accessControl.user.domain.User; +import com.casic.accessControl.user.dto.UserDto; +import com.casic.accessControl.user.manager.RoleManager; +import com.casic.accessControl.user.manager.UserManager; +import com.casic.accessControl.util.DataTable; +import com.casic.accessControl.util.StringUtils; +import com.google.gson.Gson; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +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.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * Created by lenovo on 2016/4/13. + */ +@Controller +@RequestMapping("app") +public class ApkVersionController { + + @Resource + private ApkVersionManager apkVersionManager; + + @RequestMapping("get-latest-version") + @ResponseBody + public Map getLatestVersion(HttpServletResponse response, HttpSession session) { + Map result = new HashMap(); + try { + ApkVersion latest = apkVersionManager.getLatestVersion(); + if (null != latest) { + result.put("version", latest.getVersion()); + result.put("path", latest.getPath()); + } else { + result.put("version", "1.0.0"); + } + } catch (Exception e) { + e.printStackTrace(); + result.put("version", "1.0.0"); + } + + return result; + } + +} diff --git a/src/main/java/com/casic/accessControl/marker/domain/Marker.java b/src/main/java/com/casic/accessControl/marker/domain/Marker.java index 0575cfe..7d5b854 100644 --- a/src/main/java/com/casic/accessControl/marker/domain/Marker.java +++ b/src/main/java/com/casic/accessControl/marker/domain/Marker.java @@ -67,6 +67,10 @@ private String area; @Column(name = "line") private String line; + @Column(name = "colorType") + private String colorType; + @Column(name = "photos") + private String photos; @@ -315,4 +319,20 @@ public void setArea(String area) { this.area = area; } + + public String getColorType() { + return colorType; + } + + public void setColorType(String colorType) { + this.colorType = colorType; + } + + public String getPhotos() { + return photos; + } + + public void setPhotos(String photos) { + this.photos = photos; + } } diff --git a/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java b/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java index 506f31d..c5f8cf5 100644 --- a/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java +++ b/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java @@ -2,12 +2,12 @@ //import com.casic.accessControl.feature.domain.Feature; import com.casic.accessControl.marker.domain.Marker; +import com.casic.accessControl.util.StringUtils; +import com.casic.accessControl.util.TimeFormat; import org.apache.commons.collections.CollectionUtils; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.List; +import java.text.ParseException; +import java.util.*; /** * Created by lenovo on 2016/5/16. @@ -43,6 +43,8 @@ private Long userId; private String area; private String line; + private String colorType; + private String photos; private String btnEdit = "编辑"; private String btnDelete = "删除"; @@ -296,6 +298,23 @@ this.area = area; } + public String getColorType() { + if (StringUtils.isEmpty(colorType)) return "0"; + return colorType; + } + + public void setColorType(String colorType) { + this.colorType = colorType; + } + + public String getPhotos() { + return photos; + } + + public void setPhotos(String photos) { + this.photos = photos; + } + public String getLine() { return line; } @@ -335,6 +354,52 @@ result.setRoad(doNullChange(marker.getRoad())); result.setArea(doNullChange(marker.getArea())); result.setLine(doNullChange(marker.getLine())); + result.setColorType(marker.getColorType()); + result.setPhotos(marker.getPhotos()); + return result; + } + + public static Marker convert2Marker(MarkerDto markerDto) { + if (markerDto == null) return null; + Marker result = new Marker(); + if(markerDto.getLongitude()==null||markerDto.getLatitude()==null) return null; + if (null != markerDto.getCreateTime() && markerDto.getCreateTime().length() == 19) { + try { + result.setCreateTime(TimeFormat.parse(markerDto.getCreateTime(), "yyyy-MM-dd HH:mm:ss")); + } catch (ParseException pex) { + result.setCreateTime(Calendar.getInstance().getTime()); + } + } else { + result.setCreateTime(Calendar.getInstance().getTime()); + } + result.setDepth(doNullChange(markerDto.getDepth())); + result.setId(markerDto.getId()); + result.setLatitude(markerDto.getLatitude()); + result.setLongitude(markerDto.getLongitude()); + result.setMarkerId(markerDto.getMarkerId()); + result.setMarkerDepth(doNullChange(markerDto.getMarkerDepth())); + result.setMarkerObjectId(doNullChange(markerDto.getMarkerObjectId())); + result.setMarkerObjectType(doNullChange(markerDto.getMarkerObjectType())); + result.setOwnerComp(doNullChange(markerDto.getOwnerComp())); + result.setIsValid(markerDto.getIsValid()); + result.setMemo(doNullChange(markerDto.getMemo())); + result.setPipeDiameter(doNullChange(markerDto.getPipeDiameter())); + result.setPipeMaterial(doNullChange(markerDto.getPipeMaterial())); + result.setMarkerType(doNullChange(markerDto.getMarkerType())); + result.setCreator(doNullChange(markerDto.getCreator())); + + result.setLayStyle(doNullChange(markerDto.getLayStyle())); + result.setBelowDepth(doNullChange(markerDto.getBelowDepth())); + result.setBelowDiameter(doNullChange(markerDto.getBelowDiameter())); + result.setBelowMaterial(doNullChange(markerDto.getBelowMaterial())); + result.setBelowType(doNullChange(markerDto.getBelowType())); + result.setConstructTime(doNullChange(markerDto.getConstructTime())); + result.setRecordType(markerDto.getRecordType()); + result.setRoad(doNullChange(markerDto.getRoad())); + result.setArea(doNullChange(markerDto.getArea())); + result.setLine(doNullChange(markerDto.getLine())); + result.setColorType(markerDto.getColorType()); + result.setPhotos(markerDto.getPhotos()); return result; } diff --git a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java index dd0fa4b..ba5a1fb 100644 --- a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java +++ b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java @@ -9,10 +9,7 @@ import com.casic.accessControl.marker.domain.Marker; import com.casic.accessControl.user.domain.Company; import com.casic.accessControl.user.domain.User; -import com.casic.accessControl.util.DataTable; -import com.casic.accessControl.util.DataTableParameter; -import com.casic.accessControl.util.DataTableUtils; -import com.casic.accessControl.util.DateUtils; +import com.casic.accessControl.util.*; import com.google.gson.Gson; import jxl.*; import jxl.read.biff.BiffException; @@ -31,11 +28,15 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; +import sun.misc.BASE64Decoder; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.File; +import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.text.ParseException; @@ -183,6 +184,53 @@ } /** + * 保存标识器和图片信息 + * @param markerDto + * @param companyId + * @param fileNames + * @param fileBuffers + * @return + */ + public boolean saveMarkerAndPhotos(MarkerDto markerDto, Long companyId, String[] fileNames, String[] fileBuffers) { + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + String strDirPath = request.getSession().getServletContext().getRealPath(""); + FileOutputStream fos = null; + String month = TimeFormat.format(Calendar.getInstance().getTime(), "yyyyMM"); + String webPath = "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String toDir = strDirPath + "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String filePaths = ""; + try { + for (int i = 0; i < fileBuffers.length; i++) { + if (fileBuffers[i] != null && fileNames[i] != null) { +// filePaths += toDir+fileNames[i]+","; + filePaths += webPath + fileNames[i] + ","; + byte[] buffer = new BASE64Decoder().decodeBuffer(fileBuffers[i]); //对android传过来的图片字符串进行解码 + File destDir = new File(toDir); + if (!destDir.exists()) + destDir.mkdirs(); + File imageFile = new File(destDir, fileNames[i]); + fos = new FileOutputStream(imageFile); //保存图片 + fos.write(buffer); + fos.flush(); + fos.close(); + } + } + if (filePaths.endsWith(",")) { + filePaths = filePaths.substring(0, filePaths.length() - 1); + } + } catch (Exception e) { + return false; + } + Marker marker = MarkerDto.convert2Marker(markerDto); + marker.setIsValid(1); + marker.setCompanyId(companyId); + marker.setPhotos(filePaths); + save(marker); + return true; + + } + + /** * 新增标识器 8-9 * * @param markers @@ -582,7 +630,7 @@ "所属区域","所属线路","所属道路","建设年代","权属单位","标示对象ID", "标识器ID","标识器类型","标识器埋深","安装部门","经度", "纬度", "最后修改时间","备注","下层管种类", "下层管埋深", - "下层管直径", "下层管材料", "标识对象类别"}; + "下层管直径", "下层管材料", "标识对象类别", "标识点颜色", "图片地址"}; Label[][] labels = new Label[markerDtos.size() + 1][titleTxt.length]; for(int k=0;k saveMarkerAndPhotos(@RequestParam(value = "fileBuffer1", required = false) MultipartFile fileBuffer1, + @RequestParam(value = "fileBuffer2", required = false) MultipartFile fileBuffer2, + @RequestParam(value = "fileBuffer3", required = false) MultipartFile fileBuffer3, + @RequestParam(value = "jsonMarker", required = true) String jsonMarker) { + Map map = new HashMap(); + map.put("message", "安装无标识器信息"); + Gson gson = new Gson(); + try { + MarkerDto marker = gson.fromJson(jsonMarker, MarkerDto.class); + + if (null == marker.getMarkerId()) { + map.put("message", "无标识器ID"); + map.put("success", "false"); + return map; + } else if (markerManager.getMarkerByMarkerId(marker.getMarkerId()).size() > 0) { + map.put("message", "已安装过该标识器[" + marker.getMarkerId() + "]"); + map.put("success", "false"); + return map; + } else { + String[] fileNames = new String[3]; + String[] fileBuffers = new String[3]; + if (fileBuffer1 != null) { + fileNames[0] = marker.getMarkerId() + "_" + fileBuffer1.getOriginalFilename(); + byte[] fis = fileBuffer1.getBytes(); + fileBuffers[0] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, com.sun.org.apache.xml.internal.security.utils.Base64.BASE64DEFAULTLENGTH)); + } + if (fileBuffer2 != null) { + fileNames[1] = marker.getMarkerId() + "_" + fileBuffer2.getOriginalFilename(); + byte[] fis = fileBuffer2.getBytes(); + fileBuffers[1] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, com.sun.org.apache.xml.internal.security.utils.Base64.BASE64DEFAULTLENGTH)); + } + if (fileBuffer3 != null) { + fileNames[2] = marker.getMarkerId() + "_" + fileBuffer3.getOriginalFilename(); + byte[] fis = fileBuffer3.getBytes(); + fileBuffers[2] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, Base64.BASE64DEFAULTLENGTH)); + } + Long companyId = marker.getCompanyId(); + if (companyId == null) { + return map; + } + boolean result = markerManager.saveMarkerAndPhotos(marker, companyId, fileNames, fileBuffers); + if (!result) { + return map; + } + } + } catch (Exception e) { + return map; + } + map.put("success", "true"); + map.put("message", "保存成功"); + return map; + } + + @RequestMapping("marker-info-delete") @ResponseBody public Map delete(@RequestParam(value = "id", required = true) Long id) { @@ -144,6 +208,9 @@ map.put("message", "删除需要ID信息"); return map; } + + System.out.println(ids); + markerManager.delMarkerByIds(ids); map.put("success", true); map.put("message", "删除成功"); @@ -240,6 +307,54 @@ return map; } + /** + * 批量上传标识点,用于无信号地区标识器信息统一上传,不修改已有标识点信息 + * @param strMarkers + * @return + */ + @RequestMapping("batch-save-no-update") + @ResponseBody + public Map batchSaveOrUpdate(@RequestParam(value = "markers", required = true) String strMarkers) { + strMarkers = strMarkers.replace('\n',' '); + Map map = new HashMap(); + map.put("message", "批量导入失败,或无导入标识器信息"); + Gson gson = new Gson(); + try { + List markers = gson.fromJson(strMarkers, new TypeToken>() { + }.getType()); + if (CollectionUtils.isEmpty(markers)) {//批量导入数据不存在,直接返回 + map.put("message", "批量导入数据不存在"); + return map; + } + + Long companyId = markers.get(0).getCompanyId(); + if (companyId == null) { + map.put("message", "未找到所属公司属性"); + return map; + } + + List markerDtoForSave = new ArrayList(); + for (MarkerDto markerDto : markers) { + // 上传marker的Id不为空且数据库中不存在记录,经纬度不为空,允许保存 + if (StringUtils.isNotBlank(markerDto.getMarkerId()) && markerManager.getMarkerByMarkerId(markerDto.getMarkerId()).size() <= 0) { + if (null != markerDto.getLongitude() && null != markerDto.getLatitude()) { + markerDtoForSave.add(markerDto); + } + } + } + boolean result = markerManager.batchSave(markerDtoForSave, companyId); + if (!result) { + return map; + } + } catch (Exception e) { + e.printStackTrace(); + return map; + } + map.put("success", true); + map.put("message", "保存成功"); + return map; + } + @RequestMapping("getMarkerListByCondition") @ResponseBody @POST diff --git a/src/main/java/com/casic/accessControl/user/web/UserController.java b/src/main/java/com/casic/accessControl/user/web/UserController.java index feab678..3534a97 100644 --- a/src/main/java/com/casic/accessControl/user/web/UserController.java +++ b/src/main/java/com/casic/accessControl/user/web/UserController.java @@ -46,6 +46,7 @@ @ResponseBody public Map login(@ModelAttribute User userInfo, HttpSession session) { Map result = new HashMap(); + User user = null; try{ user = userManager.login(userInfo); diff --git a/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java b/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java new file mode 100644 index 0000000..582120f --- /dev/null +++ b/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java @@ -0,0 +1,129 @@ +package com.casic.accessControl.util; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.net.URL; +import java.net.URLConnection; +import java.util.List; +import java.util.Map; + +/** + * Created by lenovo on 2016/8/31. + */ +public class HttpRequestUtils { + + /** + * 向指定URL发送GET方法的请求 + * + * @param url + * 发送请求的URL + * @param param + * 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 + * @return URL 所代表远程资源的响应结果 + */ + public static String sendGet(String url, String param) { + String result = ""; + BufferedReader in = null; + try { + String urlNameString = url + "?" + param; + URL realUrl = new URL(urlNameString); + // 打开和URL之间的连接 + URLConnection connection = realUrl.openConnection(); + // 设置通用的请求属性 + connection.setRequestProperty("accept", "*/*"); + connection.setRequestProperty("connection", "Keep-Alive"); + connection.setRequestProperty("user-agent", + "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + // 建立实际的连接 + connection.connect(); + // 获取所有响应头字段 + Map> map = connection.getHeaderFields(); + // 遍历所有的响应头字段 + for (String key : map.keySet()) { + System.out.println(key + "--->" + map.get(key)); + } + // 定义 BufferedReader输入流来读取URL的响应 + in = new BufferedReader(new InputStreamReader( + connection.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + result += line; + } + } catch (Exception e) { + System.out.println("发送GET请求出现异常!" + e); + e.printStackTrace(); + } + // 使用finally块来关闭输入流 + finally { + try { + if (in != null) { + in.close(); + } + } catch (Exception e2) { + e2.printStackTrace(); + } + } + return result; + } + + /** + * 向指定 URL 发送POST方法的请求 + * + * @param url + * 发送请求的 URL + * @param param + * 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 + * @return 所代表远程资源的响应结果 + */ + public static String sendPost(String url, String param) { + PrintWriter out = null; + BufferedReader in = null; + String result = ""; + try { + URL realUrl = new URL(url); + // 打开和URL之间的连接 + URLConnection conn = realUrl.openConnection(); + // 设置通用的请求属性 + conn.setRequestProperty("accept", "*/*"); + conn.setRequestProperty("connection", "Keep-Alive"); + conn.setRequestProperty("user-agent", + "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + // 发送POST请求必须设置如下两行 + conn.setDoOutput(true); + conn.setDoInput(true); + // 获取URLConnection对象对应的输出流 + out = new PrintWriter(conn.getOutputStream()); + // 发送请求参数 + out.print(param); + // flush输出流的缓冲 + out.flush(); + // 定义BufferedReader输入流来读取URL的响应 + in = new BufferedReader( + new InputStreamReader(conn.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + result += line; + } + } catch (Exception e) { + System.out.println("发送 POST 请求出现异常!"+e); + e.printStackTrace(); + } + //使用finally块来关闭输出流、输入流 + finally{ + try{ + if(out!=null){ + out.close(); + } + if(in!=null){ + in.close(); + } + } + catch(IOException ex){ + ex.printStackTrace(); + } + } + return result; + } + } \ No newline at end of file diff --git a/src/main/java/com/casic/accessControl/util/TimeFormat.java b/src/main/java/com/casic/accessControl/util/TimeFormat.java new file mode 100644 index 0000000..e9168d5 --- /dev/null +++ b/src/main/java/com/casic/accessControl/util/TimeFormat.java @@ -0,0 +1,148 @@ +package com.casic.accessControl.util; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +/** + * 格式化日期工具类 + * 默认模式yyyy-MM-dd HH:mm:ss + * @author Administrator + * + */ +public class TimeFormat { + + private static final String DATE_FORMAT_STRING = "yyyy-MM-dd"; + private static final String TIME_FORMAT_STRING = "HH:mm:ss"; + private static final String TIMESTAMP_FORMAT_STRING = "yyyy-MM-dd HH:mm:ss"; + + // 默认格式化格式 + private static SimpleDateFormat defaultFormat = new SimpleDateFormat(TIMESTAMP_FORMAT_STRING); + + public static void setFormatString(String pattern) { + defaultFormat.applyPattern(pattern); + } + + /** + * 默认格式化日期 + * + * @param Date date + * @return String + */ + public static String format(Date date) { + return defaultFormat.format(date); + } + + /** + * 日期格式化 + * + * @param date + * @return + */ + public static String formatDate(Date date) { + return TimeFormat.format(date, DATE_FORMAT_STRING); + } + + /** + * 时间格式化 + * + * @param date + * @return + */ + public static String formatTime(Date date) { + return TimeFormat.format(date, TIME_FORMAT_STRING); + } + + /** + * 时间戳格式化 + * + * @param date + * @return + */ + public static String formatTimestamp(Date date) { + return TimeFormat.format(date, TIMESTAMP_FORMAT_STRING); + } + + /** + * 以指定模式格式化日期 + * + * @param Date date + * @param String pattern + * @return String + */ + public static String format(Date date, String pattern) { + SimpleDateFormat formatter = new SimpleDateFormat(pattern); + return formatter.format(date); + } + + /** + * 根据起止日期生成日期序列 + * 包括start和end的日期 + * + * @param start + * @param end + * @return + */ + public static List generateDates(String start, String end) throws ParseException { + List dates = new ArrayList(); + Calendar s = Calendar.getInstance(); + Calendar e = Calendar.getInstance(); + s.setTime(TimeFormat.parse(start, DATE_FORMAT_STRING)); + s.set(Calendar.HOUR_OF_DAY, 0); + s.set(Calendar.MINUTE, 0); + s.set(Calendar.SECOND, 0); + e.setTime(TimeFormat.parse(end, DATE_FORMAT_STRING)); + e.set(Calendar.HOUR_OF_DAY, 0); + e.set(Calendar.MINUTE, 0); + e.set(Calendar.SECOND, 0); + while (s.before(e) == true) { + dates.add(TimeFormat.formatDate(s.getTime())); + s.add(Calendar.DATE, 1); + } + + dates.add(end); + return dates; + } + + + /** + * 解析日期字符串 + * + * @param String source + * @return Date + * + * @throws ParseException + */ + public static Date parse(String source) throws ParseException { + return defaultFormat.parse(source); + } + + /** + * 以指定模式解析日期 + * + * @param String source + * @param String pattern + * @return Date + * + * @throws ParseException + */ + public static Date parse(String source, String pattern) throws ParseException { + SimpleDateFormat formatter = new SimpleDateFormat(pattern); + return formatter.parse(source); + } + + + public static Date parseDateWithoutTime(String source) throws ParseException { + SimpleDateFormat formatter = new SimpleDateFormat(DATE_FORMAT_STRING); + Calendar date = Calendar.getInstance(); + date.setTime(formatter.parse(source)); + date.set(Calendar.HOUR, 0); + date.set(Calendar.HOUR, 0); + date.set(Calendar.MINUTE, 0); + return date.getTime(); + } + +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 53c91ea..cea976f 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -15,19 +15,17 @@ # ============================================================================ # db # ============================================================================ -#db.default.driverClassName=oracle.jdbc.driver.OracleDriver -#db.default.url=jdbc:oracle:thin:@192.168.0.203:1521:SZHTDB2 -#db.default.username=scott -#db.default.password=SZHTDB2 db.default.driverClassName=com.mysql.jdbc.Driver -db.default.url=jdbc:mysql://127.0.0.1:3306/ems?useUnicode=true&characterEncoding=UTF-8 -db.default.username=emsweb -db.default.password=emsweb +db.default.url=jdbc:mysql://127.0.0.1:3306/ems_tong?useUnicode=true&characterEncoding=UTF-8 +db.default.username=root +db.default.password=root +#db.default.username=emsweb +#db.default.password=emsweb #db.default.url=jdbc:mysql://119.254.110.71:3307/ems?useUnicode=true&characterEncoding=UTF-8 #db.default.username=root #db.default.password=rootems - -# ============================================================================ +# +## ============================================================================ # log4jdbc # ============================================================================ log4jdbc.enable=true diff --git a/src/main/resources/spring/applicationContext-filter.xml b/src/main/resources/spring/applicationContext-filter.xml index a08c5fc..98ac7d6 100644 --- a/src/main/resources/spring/applicationContext-filter.xml +++ b/src/main/resources/spring/applicationContext-filter.xml @@ -35,9 +35,13 @@ /user/ill-login.do /marker/exportMarker.do /marker/batchSave-na.do + /marker/batch-save-no-update.do + /marker/save-marker-photo.do /event/save-event.do /task/get-task.do + /app/get-latest-version.do /xls/* + /apk/* diff --git a/src/main/resources/spring/applicationContext-hibernate.xml b/src/main/resources/spring/applicationContext-hibernate.xml index 5bb1a7e..dc54192 100644 --- a/src/main/resources/spring/applicationContext-hibernate.xml +++ b/src/main/resources/spring/applicationContext-hibernate.xml @@ -65,6 +65,7 @@ com.casic.accessControl.task.domain.Position com.casic.accessControl.event.domain.Event com.casic.accessControl.marker.domain.OptionItem + com.casic.accessControl.app.domain.ApkVersion diff --git a/src/main/webapp/common/layout/menu_new.jsp b/src/main/webapp/common/layout/menu_new.jsp index 3cf4b4e..cbd822e 100644 --- a/src/main/webapp/common/layout/menu_new.jsp +++ b/src/main/webapp/common/layout/menu_new.jsp @@ -20,7 +20,7 @@
  • - + @@ -54,7 +54,7 @@
  • - + diff --git a/src/main/webapp/content/ems/ems-gd.jsp b/src/main/webapp/content/ems/ems-gd.jsp new file mode 100644 index 0000000..5137b49 --- /dev/null +++ b/src/main/webapp/content/ems/ems-gd.jsp @@ -0,0 +1,604 @@ +<%@page contentType="text/html;charset=UTF-8" %> + +<%@include file="/taglibs.jsp" %> + +<%pageContext.setAttribute("currentMenu", "ems");%> + + + + + + + + + + + + + 地下管线电子标识系统 + + + + + + + + + + + + + + + + + + +<%-- + +--%> + + + + + + + + + + + + + + +<%@include file="/common/layout/header.jsp" %> + +
    + + + + <%@include file="/common/layout/menu_new.jsp" %> + + + +
    + + + +
    + +
    + + +
    +
    +
    +
    + +
    +
    + +
    +
    + +
    +
    + +
    +
    + +
    + +
    + +
    + +
    + +
    + +
    +
    +
    + + + + +
    +
    +
    +
    + + + + +
    +
    +
    + +
    + +
    + +<%--todo list:错误使用方法 + +--%> +
    + +
    +
    + +
    + +
    + +
    + + +
    + +
    + + 移动 + 绘制区域 + 新增标识器 + 删除标识器 + 保存标识器 + 批量导入 + 导出Excel + 清空 + +
    + +
    +
    + +
    + + + +
    + +
    + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java new file mode 100644 index 0000000..634ceae --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java @@ -0,0 +1,46 @@ +package com.casic.accessControl.app.domain; + +import javax.persistence.*; +import java.util.Date; + +/** + * app的版本信息 + */ +//工单 +@Entity +@Table(name = "apkVersion") +public class ApkVersion { + private String version; + private String path; + private Date ts;//时间戳 + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "version") + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + @Column(name = "path") + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + @Column(name = "ts") + public Date getTs() { + return ts; + } + + public void setTs(Date ts) { + this.ts = ts; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java new file mode 100644 index 0000000..1d0242a --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java @@ -0,0 +1,50 @@ +package com.casic.accessControl.app.dto; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.util.TimeFormat; + +/** + * Created by lenovo on 2016/4/13. + */ +public class ApkVersionDto { + private String version; + private String path; + private String ts; + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public String getTs() { + return ts; + } + + public void setTs(String ts) { + this.ts = ts; + } + + public static ApkVersionDto Convert(ApkVersion version) { + if (version == null) { + return null; + } + ApkVersionDto versionDto = new ApkVersionDto(); + versionDto.setVersion(version.getVersion()); + versionDto.setPath(version.getVersion()); + versionDto.setTs(TimeFormat.formatTimestamp(version.getTs())); + + return versionDto; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java b/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java new file mode 100644 index 0000000..28b12a7 --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java @@ -0,0 +1,27 @@ +package com.casic.accessControl.app.manager; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.core.hibernate.HibernateEntityDao; +import org.hibernate.Query; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * + */ +@Service("apkVersionManager") +public class ApkVersionManager extends HibernateEntityDao { + + public ApkVersion getLatestVersion() { + String sql = "from ApkVersion order by ts desc"; + Query query = getSession().createQuery(sql); + List list = query.list(); + if (null != list && list.isEmpty() == false) { + return list.get(0); + } + + return null; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java b/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java new file mode 100644 index 0000000..065d3cc --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java @@ -0,0 +1,66 @@ +package com.casic.accessControl.app.web; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.app.manager.ApkVersionManager; +import com.casic.accessControl.marker.domain.Marker; +import com.casic.accessControl.marker.manager.MarkerManager; +import com.casic.accessControl.task.domain.Task; +import com.casic.accessControl.task.domain.TaskDetail; +import com.casic.accessControl.task.dto.TaskDetailDto; +import com.casic.accessControl.task.dto.TaskDto; +import com.casic.accessControl.task.dto.TaskStatus; +import com.casic.accessControl.task.manager.TaskDetailManager; +import com.casic.accessControl.task.manager.TaskManager; +import com.casic.accessControl.user.domain.Company; +import com.casic.accessControl.user.domain.Role; +import com.casic.accessControl.user.domain.User; +import com.casic.accessControl.user.dto.UserDto; +import com.casic.accessControl.user.manager.RoleManager; +import com.casic.accessControl.user.manager.UserManager; +import com.casic.accessControl.util.DataTable; +import com.casic.accessControl.util.StringUtils; +import com.google.gson.Gson; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +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.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * Created by lenovo on 2016/4/13. + */ +@Controller +@RequestMapping("app") +public class ApkVersionController { + + @Resource + private ApkVersionManager apkVersionManager; + + @RequestMapping("get-latest-version") + @ResponseBody + public Map getLatestVersion(HttpServletResponse response, HttpSession session) { + Map result = new HashMap(); + try { + ApkVersion latest = apkVersionManager.getLatestVersion(); + if (null != latest) { + result.put("version", latest.getVersion()); + result.put("path", latest.getPath()); + } else { + result.put("version", "1.0.0"); + } + } catch (Exception e) { + e.printStackTrace(); + result.put("version", "1.0.0"); + } + + return result; + } + +} diff --git a/src/main/java/com/casic/accessControl/marker/domain/Marker.java b/src/main/java/com/casic/accessControl/marker/domain/Marker.java index 0575cfe..7d5b854 100644 --- a/src/main/java/com/casic/accessControl/marker/domain/Marker.java +++ b/src/main/java/com/casic/accessControl/marker/domain/Marker.java @@ -67,6 +67,10 @@ private String area; @Column(name = "line") private String line; + @Column(name = "colorType") + private String colorType; + @Column(name = "photos") + private String photos; @@ -315,4 +319,20 @@ public void setArea(String area) { this.area = area; } + + public String getColorType() { + return colorType; + } + + public void setColorType(String colorType) { + this.colorType = colorType; + } + + public String getPhotos() { + return photos; + } + + public void setPhotos(String photos) { + this.photos = photos; + } } diff --git a/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java b/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java index 506f31d..c5f8cf5 100644 --- a/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java +++ b/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java @@ -2,12 +2,12 @@ //import com.casic.accessControl.feature.domain.Feature; import com.casic.accessControl.marker.domain.Marker; +import com.casic.accessControl.util.StringUtils; +import com.casic.accessControl.util.TimeFormat; import org.apache.commons.collections.CollectionUtils; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.List; +import java.text.ParseException; +import java.util.*; /** * Created by lenovo on 2016/5/16. @@ -43,6 +43,8 @@ private Long userId; private String area; private String line; + private String colorType; + private String photos; private String btnEdit = "编辑"; private String btnDelete = "删除"; @@ -296,6 +298,23 @@ this.area = area; } + public String getColorType() { + if (StringUtils.isEmpty(colorType)) return "0"; + return colorType; + } + + public void setColorType(String colorType) { + this.colorType = colorType; + } + + public String getPhotos() { + return photos; + } + + public void setPhotos(String photos) { + this.photos = photos; + } + public String getLine() { return line; } @@ -335,6 +354,52 @@ result.setRoad(doNullChange(marker.getRoad())); result.setArea(doNullChange(marker.getArea())); result.setLine(doNullChange(marker.getLine())); + result.setColorType(marker.getColorType()); + result.setPhotos(marker.getPhotos()); + return result; + } + + public static Marker convert2Marker(MarkerDto markerDto) { + if (markerDto == null) return null; + Marker result = new Marker(); + if(markerDto.getLongitude()==null||markerDto.getLatitude()==null) return null; + if (null != markerDto.getCreateTime() && markerDto.getCreateTime().length() == 19) { + try { + result.setCreateTime(TimeFormat.parse(markerDto.getCreateTime(), "yyyy-MM-dd HH:mm:ss")); + } catch (ParseException pex) { + result.setCreateTime(Calendar.getInstance().getTime()); + } + } else { + result.setCreateTime(Calendar.getInstance().getTime()); + } + result.setDepth(doNullChange(markerDto.getDepth())); + result.setId(markerDto.getId()); + result.setLatitude(markerDto.getLatitude()); + result.setLongitude(markerDto.getLongitude()); + result.setMarkerId(markerDto.getMarkerId()); + result.setMarkerDepth(doNullChange(markerDto.getMarkerDepth())); + result.setMarkerObjectId(doNullChange(markerDto.getMarkerObjectId())); + result.setMarkerObjectType(doNullChange(markerDto.getMarkerObjectType())); + result.setOwnerComp(doNullChange(markerDto.getOwnerComp())); + result.setIsValid(markerDto.getIsValid()); + result.setMemo(doNullChange(markerDto.getMemo())); + result.setPipeDiameter(doNullChange(markerDto.getPipeDiameter())); + result.setPipeMaterial(doNullChange(markerDto.getPipeMaterial())); + result.setMarkerType(doNullChange(markerDto.getMarkerType())); + result.setCreator(doNullChange(markerDto.getCreator())); + + result.setLayStyle(doNullChange(markerDto.getLayStyle())); + result.setBelowDepth(doNullChange(markerDto.getBelowDepth())); + result.setBelowDiameter(doNullChange(markerDto.getBelowDiameter())); + result.setBelowMaterial(doNullChange(markerDto.getBelowMaterial())); + result.setBelowType(doNullChange(markerDto.getBelowType())); + result.setConstructTime(doNullChange(markerDto.getConstructTime())); + result.setRecordType(markerDto.getRecordType()); + result.setRoad(doNullChange(markerDto.getRoad())); + result.setArea(doNullChange(markerDto.getArea())); + result.setLine(doNullChange(markerDto.getLine())); + result.setColorType(markerDto.getColorType()); + result.setPhotos(markerDto.getPhotos()); return result; } diff --git a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java index dd0fa4b..ba5a1fb 100644 --- a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java +++ b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java @@ -9,10 +9,7 @@ import com.casic.accessControl.marker.domain.Marker; import com.casic.accessControl.user.domain.Company; import com.casic.accessControl.user.domain.User; -import com.casic.accessControl.util.DataTable; -import com.casic.accessControl.util.DataTableParameter; -import com.casic.accessControl.util.DataTableUtils; -import com.casic.accessControl.util.DateUtils; +import com.casic.accessControl.util.*; import com.google.gson.Gson; import jxl.*; import jxl.read.biff.BiffException; @@ -31,11 +28,15 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; +import sun.misc.BASE64Decoder; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.File; +import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.text.ParseException; @@ -183,6 +184,53 @@ } /** + * 保存标识器和图片信息 + * @param markerDto + * @param companyId + * @param fileNames + * @param fileBuffers + * @return + */ + public boolean saveMarkerAndPhotos(MarkerDto markerDto, Long companyId, String[] fileNames, String[] fileBuffers) { + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + String strDirPath = request.getSession().getServletContext().getRealPath(""); + FileOutputStream fos = null; + String month = TimeFormat.format(Calendar.getInstance().getTime(), "yyyyMM"); + String webPath = "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String toDir = strDirPath + "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String filePaths = ""; + try { + for (int i = 0; i < fileBuffers.length; i++) { + if (fileBuffers[i] != null && fileNames[i] != null) { +// filePaths += toDir+fileNames[i]+","; + filePaths += webPath + fileNames[i] + ","; + byte[] buffer = new BASE64Decoder().decodeBuffer(fileBuffers[i]); //对android传过来的图片字符串进行解码 + File destDir = new File(toDir); + if (!destDir.exists()) + destDir.mkdirs(); + File imageFile = new File(destDir, fileNames[i]); + fos = new FileOutputStream(imageFile); //保存图片 + fos.write(buffer); + fos.flush(); + fos.close(); + } + } + if (filePaths.endsWith(",")) { + filePaths = filePaths.substring(0, filePaths.length() - 1); + } + } catch (Exception e) { + return false; + } + Marker marker = MarkerDto.convert2Marker(markerDto); + marker.setIsValid(1); + marker.setCompanyId(companyId); + marker.setPhotos(filePaths); + save(marker); + return true; + + } + + /** * 新增标识器 8-9 * * @param markers @@ -582,7 +630,7 @@ "所属区域","所属线路","所属道路","建设年代","权属单位","标示对象ID", "标识器ID","标识器类型","标识器埋深","安装部门","经度", "纬度", "最后修改时间","备注","下层管种类", "下层管埋深", - "下层管直径", "下层管材料", "标识对象类别"}; + "下层管直径", "下层管材料", "标识对象类别", "标识点颜色", "图片地址"}; Label[][] labels = new Label[markerDtos.size() + 1][titleTxt.length]; for(int k=0;k saveMarkerAndPhotos(@RequestParam(value = "fileBuffer1", required = false) MultipartFile fileBuffer1, + @RequestParam(value = "fileBuffer2", required = false) MultipartFile fileBuffer2, + @RequestParam(value = "fileBuffer3", required = false) MultipartFile fileBuffer3, + @RequestParam(value = "jsonMarker", required = true) String jsonMarker) { + Map map = new HashMap(); + map.put("message", "安装无标识器信息"); + Gson gson = new Gson(); + try { + MarkerDto marker = gson.fromJson(jsonMarker, MarkerDto.class); + + if (null == marker.getMarkerId()) { + map.put("message", "无标识器ID"); + map.put("success", "false"); + return map; + } else if (markerManager.getMarkerByMarkerId(marker.getMarkerId()).size() > 0) { + map.put("message", "已安装过该标识器[" + marker.getMarkerId() + "]"); + map.put("success", "false"); + return map; + } else { + String[] fileNames = new String[3]; + String[] fileBuffers = new String[3]; + if (fileBuffer1 != null) { + fileNames[0] = marker.getMarkerId() + "_" + fileBuffer1.getOriginalFilename(); + byte[] fis = fileBuffer1.getBytes(); + fileBuffers[0] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, com.sun.org.apache.xml.internal.security.utils.Base64.BASE64DEFAULTLENGTH)); + } + if (fileBuffer2 != null) { + fileNames[1] = marker.getMarkerId() + "_" + fileBuffer2.getOriginalFilename(); + byte[] fis = fileBuffer2.getBytes(); + fileBuffers[1] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, com.sun.org.apache.xml.internal.security.utils.Base64.BASE64DEFAULTLENGTH)); + } + if (fileBuffer3 != null) { + fileNames[2] = marker.getMarkerId() + "_" + fileBuffer3.getOriginalFilename(); + byte[] fis = fileBuffer3.getBytes(); + fileBuffers[2] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, Base64.BASE64DEFAULTLENGTH)); + } + Long companyId = marker.getCompanyId(); + if (companyId == null) { + return map; + } + boolean result = markerManager.saveMarkerAndPhotos(marker, companyId, fileNames, fileBuffers); + if (!result) { + return map; + } + } + } catch (Exception e) { + return map; + } + map.put("success", "true"); + map.put("message", "保存成功"); + return map; + } + + @RequestMapping("marker-info-delete") @ResponseBody public Map delete(@RequestParam(value = "id", required = true) Long id) { @@ -144,6 +208,9 @@ map.put("message", "删除需要ID信息"); return map; } + + System.out.println(ids); + markerManager.delMarkerByIds(ids); map.put("success", true); map.put("message", "删除成功"); @@ -240,6 +307,54 @@ return map; } + /** + * 批量上传标识点,用于无信号地区标识器信息统一上传,不修改已有标识点信息 + * @param strMarkers + * @return + */ + @RequestMapping("batch-save-no-update") + @ResponseBody + public Map batchSaveOrUpdate(@RequestParam(value = "markers", required = true) String strMarkers) { + strMarkers = strMarkers.replace('\n',' '); + Map map = new HashMap(); + map.put("message", "批量导入失败,或无导入标识器信息"); + Gson gson = new Gson(); + try { + List markers = gson.fromJson(strMarkers, new TypeToken>() { + }.getType()); + if (CollectionUtils.isEmpty(markers)) {//批量导入数据不存在,直接返回 + map.put("message", "批量导入数据不存在"); + return map; + } + + Long companyId = markers.get(0).getCompanyId(); + if (companyId == null) { + map.put("message", "未找到所属公司属性"); + return map; + } + + List markerDtoForSave = new ArrayList(); + for (MarkerDto markerDto : markers) { + // 上传marker的Id不为空且数据库中不存在记录,经纬度不为空,允许保存 + if (StringUtils.isNotBlank(markerDto.getMarkerId()) && markerManager.getMarkerByMarkerId(markerDto.getMarkerId()).size() <= 0) { + if (null != markerDto.getLongitude() && null != markerDto.getLatitude()) { + markerDtoForSave.add(markerDto); + } + } + } + boolean result = markerManager.batchSave(markerDtoForSave, companyId); + if (!result) { + return map; + } + } catch (Exception e) { + e.printStackTrace(); + return map; + } + map.put("success", true); + map.put("message", "保存成功"); + return map; + } + @RequestMapping("getMarkerListByCondition") @ResponseBody @POST diff --git a/src/main/java/com/casic/accessControl/user/web/UserController.java b/src/main/java/com/casic/accessControl/user/web/UserController.java index feab678..3534a97 100644 --- a/src/main/java/com/casic/accessControl/user/web/UserController.java +++ b/src/main/java/com/casic/accessControl/user/web/UserController.java @@ -46,6 +46,7 @@ @ResponseBody public Map login(@ModelAttribute User userInfo, HttpSession session) { Map result = new HashMap(); + User user = null; try{ user = userManager.login(userInfo); diff --git a/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java b/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java new file mode 100644 index 0000000..582120f --- /dev/null +++ b/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java @@ -0,0 +1,129 @@ +package com.casic.accessControl.util; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.net.URL; +import java.net.URLConnection; +import java.util.List; +import java.util.Map; + +/** + * Created by lenovo on 2016/8/31. + */ +public class HttpRequestUtils { + + /** + * 向指定URL发送GET方法的请求 + * + * @param url + * 发送请求的URL + * @param param + * 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 + * @return URL 所代表远程资源的响应结果 + */ + public static String sendGet(String url, String param) { + String result = ""; + BufferedReader in = null; + try { + String urlNameString = url + "?" + param; + URL realUrl = new URL(urlNameString); + // 打开和URL之间的连接 + URLConnection connection = realUrl.openConnection(); + // 设置通用的请求属性 + connection.setRequestProperty("accept", "*/*"); + connection.setRequestProperty("connection", "Keep-Alive"); + connection.setRequestProperty("user-agent", + "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + // 建立实际的连接 + connection.connect(); + // 获取所有响应头字段 + Map> map = connection.getHeaderFields(); + // 遍历所有的响应头字段 + for (String key : map.keySet()) { + System.out.println(key + "--->" + map.get(key)); + } + // 定义 BufferedReader输入流来读取URL的响应 + in = new BufferedReader(new InputStreamReader( + connection.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + result += line; + } + } catch (Exception e) { + System.out.println("发送GET请求出现异常!" + e); + e.printStackTrace(); + } + // 使用finally块来关闭输入流 + finally { + try { + if (in != null) { + in.close(); + } + } catch (Exception e2) { + e2.printStackTrace(); + } + } + return result; + } + + /** + * 向指定 URL 发送POST方法的请求 + * + * @param url + * 发送请求的 URL + * @param param + * 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 + * @return 所代表远程资源的响应结果 + */ + public static String sendPost(String url, String param) { + PrintWriter out = null; + BufferedReader in = null; + String result = ""; + try { + URL realUrl = new URL(url); + // 打开和URL之间的连接 + URLConnection conn = realUrl.openConnection(); + // 设置通用的请求属性 + conn.setRequestProperty("accept", "*/*"); + conn.setRequestProperty("connection", "Keep-Alive"); + conn.setRequestProperty("user-agent", + "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + // 发送POST请求必须设置如下两行 + conn.setDoOutput(true); + conn.setDoInput(true); + // 获取URLConnection对象对应的输出流 + out = new PrintWriter(conn.getOutputStream()); + // 发送请求参数 + out.print(param); + // flush输出流的缓冲 + out.flush(); + // 定义BufferedReader输入流来读取URL的响应 + in = new BufferedReader( + new InputStreamReader(conn.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + result += line; + } + } catch (Exception e) { + System.out.println("发送 POST 请求出现异常!"+e); + e.printStackTrace(); + } + //使用finally块来关闭输出流、输入流 + finally{ + try{ + if(out!=null){ + out.close(); + } + if(in!=null){ + in.close(); + } + } + catch(IOException ex){ + ex.printStackTrace(); + } + } + return result; + } + } \ No newline at end of file diff --git a/src/main/java/com/casic/accessControl/util/TimeFormat.java b/src/main/java/com/casic/accessControl/util/TimeFormat.java new file mode 100644 index 0000000..e9168d5 --- /dev/null +++ b/src/main/java/com/casic/accessControl/util/TimeFormat.java @@ -0,0 +1,148 @@ +package com.casic.accessControl.util; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +/** + * 格式化日期工具类 + * 默认模式yyyy-MM-dd HH:mm:ss + * @author Administrator + * + */ +public class TimeFormat { + + private static final String DATE_FORMAT_STRING = "yyyy-MM-dd"; + private static final String TIME_FORMAT_STRING = "HH:mm:ss"; + private static final String TIMESTAMP_FORMAT_STRING = "yyyy-MM-dd HH:mm:ss"; + + // 默认格式化格式 + private static SimpleDateFormat defaultFormat = new SimpleDateFormat(TIMESTAMP_FORMAT_STRING); + + public static void setFormatString(String pattern) { + defaultFormat.applyPattern(pattern); + } + + /** + * 默认格式化日期 + * + * @param Date date + * @return String + */ + public static String format(Date date) { + return defaultFormat.format(date); + } + + /** + * 日期格式化 + * + * @param date + * @return + */ + public static String formatDate(Date date) { + return TimeFormat.format(date, DATE_FORMAT_STRING); + } + + /** + * 时间格式化 + * + * @param date + * @return + */ + public static String formatTime(Date date) { + return TimeFormat.format(date, TIME_FORMAT_STRING); + } + + /** + * 时间戳格式化 + * + * @param date + * @return + */ + public static String formatTimestamp(Date date) { + return TimeFormat.format(date, TIMESTAMP_FORMAT_STRING); + } + + /** + * 以指定模式格式化日期 + * + * @param Date date + * @param String pattern + * @return String + */ + public static String format(Date date, String pattern) { + SimpleDateFormat formatter = new SimpleDateFormat(pattern); + return formatter.format(date); + } + + /** + * 根据起止日期生成日期序列 + * 包括start和end的日期 + * + * @param start + * @param end + * @return + */ + public static List generateDates(String start, String end) throws ParseException { + List dates = new ArrayList(); + Calendar s = Calendar.getInstance(); + Calendar e = Calendar.getInstance(); + s.setTime(TimeFormat.parse(start, DATE_FORMAT_STRING)); + s.set(Calendar.HOUR_OF_DAY, 0); + s.set(Calendar.MINUTE, 0); + s.set(Calendar.SECOND, 0); + e.setTime(TimeFormat.parse(end, DATE_FORMAT_STRING)); + e.set(Calendar.HOUR_OF_DAY, 0); + e.set(Calendar.MINUTE, 0); + e.set(Calendar.SECOND, 0); + while (s.before(e) == true) { + dates.add(TimeFormat.formatDate(s.getTime())); + s.add(Calendar.DATE, 1); + } + + dates.add(end); + return dates; + } + + + /** + * 解析日期字符串 + * + * @param String source + * @return Date + * + * @throws ParseException + */ + public static Date parse(String source) throws ParseException { + return defaultFormat.parse(source); + } + + /** + * 以指定模式解析日期 + * + * @param String source + * @param String pattern + * @return Date + * + * @throws ParseException + */ + public static Date parse(String source, String pattern) throws ParseException { + SimpleDateFormat formatter = new SimpleDateFormat(pattern); + return formatter.parse(source); + } + + + public static Date parseDateWithoutTime(String source) throws ParseException { + SimpleDateFormat formatter = new SimpleDateFormat(DATE_FORMAT_STRING); + Calendar date = Calendar.getInstance(); + date.setTime(formatter.parse(source)); + date.set(Calendar.HOUR, 0); + date.set(Calendar.HOUR, 0); + date.set(Calendar.MINUTE, 0); + return date.getTime(); + } + +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 53c91ea..cea976f 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -15,19 +15,17 @@ # ============================================================================ # db # ============================================================================ -#db.default.driverClassName=oracle.jdbc.driver.OracleDriver -#db.default.url=jdbc:oracle:thin:@192.168.0.203:1521:SZHTDB2 -#db.default.username=scott -#db.default.password=SZHTDB2 db.default.driverClassName=com.mysql.jdbc.Driver -db.default.url=jdbc:mysql://127.0.0.1:3306/ems?useUnicode=true&characterEncoding=UTF-8 -db.default.username=emsweb -db.default.password=emsweb +db.default.url=jdbc:mysql://127.0.0.1:3306/ems_tong?useUnicode=true&characterEncoding=UTF-8 +db.default.username=root +db.default.password=root +#db.default.username=emsweb +#db.default.password=emsweb #db.default.url=jdbc:mysql://119.254.110.71:3307/ems?useUnicode=true&characterEncoding=UTF-8 #db.default.username=root #db.default.password=rootems - -# ============================================================================ +# +## ============================================================================ # log4jdbc # ============================================================================ log4jdbc.enable=true diff --git a/src/main/resources/spring/applicationContext-filter.xml b/src/main/resources/spring/applicationContext-filter.xml index a08c5fc..98ac7d6 100644 --- a/src/main/resources/spring/applicationContext-filter.xml +++ b/src/main/resources/spring/applicationContext-filter.xml @@ -35,9 +35,13 @@ /user/ill-login.do /marker/exportMarker.do /marker/batchSave-na.do + /marker/batch-save-no-update.do + /marker/save-marker-photo.do /event/save-event.do /task/get-task.do + /app/get-latest-version.do /xls/* + /apk/* diff --git a/src/main/resources/spring/applicationContext-hibernate.xml b/src/main/resources/spring/applicationContext-hibernate.xml index 5bb1a7e..dc54192 100644 --- a/src/main/resources/spring/applicationContext-hibernate.xml +++ b/src/main/resources/spring/applicationContext-hibernate.xml @@ -65,6 +65,7 @@ com.casic.accessControl.task.domain.Position com.casic.accessControl.event.domain.Event com.casic.accessControl.marker.domain.OptionItem + com.casic.accessControl.app.domain.ApkVersion diff --git a/src/main/webapp/common/layout/menu_new.jsp b/src/main/webapp/common/layout/menu_new.jsp index 3cf4b4e..cbd822e 100644 --- a/src/main/webapp/common/layout/menu_new.jsp +++ b/src/main/webapp/common/layout/menu_new.jsp @@ -20,7 +20,7 @@
  • - + @@ -54,7 +54,7 @@
  • - + diff --git a/src/main/webapp/content/ems/ems-gd.jsp b/src/main/webapp/content/ems/ems-gd.jsp new file mode 100644 index 0000000..5137b49 --- /dev/null +++ b/src/main/webapp/content/ems/ems-gd.jsp @@ -0,0 +1,604 @@ +<%@page contentType="text/html;charset=UTF-8" %> + +<%@include file="/taglibs.jsp" %> + +<%pageContext.setAttribute("currentMenu", "ems");%> + + + + + + + + + + + + + 地下管线电子标识系统 + + + + + + + + + + + + + + + + + + +<%-- + +--%> + + + + + + + + + + + + + + +<%@include file="/common/layout/header.jsp" %> + +
    + + + + <%@include file="/common/layout/menu_new.jsp" %> + + + +
    + + + +
    + +
    + + +
    +
    +
    +
    + +
    +
    + +
    +
    + +
    +
    + +
    +
    + +
    + +
    + +
    + +
    + +
    + +
    +
    +
    + + + + +
    +
    +
    +
    + + + + +
    +
    +
    + +
    + +
    + +<%--todo list:错误使用方法 + +--%> +
    + +
    +
    + +
    + +
    + +
    + + +
    + +
    + + 移动 + 绘制区域 + 新增标识器 + 删除标识器 + 保存标识器 + 批量导入 + 导出Excel + 清空 + +
    + +
    +
    + +
    + + + +
    + +
    + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/webapp/content/task/task-gd.jsp b/src/main/webapp/content/task/task-gd.jsp new file mode 100644 index 0000000..d2d5549 --- /dev/null +++ b/src/main/webapp/content/task/task-gd.jsp @@ -0,0 +1,374 @@ +<%@page contentType="text/html;charset=UTF-8" %> + +<%@include file="/taglibs.jsp" %> + +<%pageContext.setAttribute("currentMenu", "task");%> + + + + + + + + + + + + + 地下管线电子标识系统 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +<%@include file="/common/layout/header.jsp" %> + +
    + + + + <%@include file="/common/layout/menu_new.jsp" %> + + + +
    + + + +
    + +
    + +
    + + 移动 + 绘制区域 + 选择多点创建工单 + 清空选择 + +
    + +
    + +
    + + +
    + +
    + +
    + +
    历史工单
    + +
    + +
    + +
    + <%--巡检员:--%> +
    +
    + + +
    +
    + + +
      +
    +
      +
      + +
      + +
      + +
      + +
      +
      + +
      + + + +
      + +
      + +
      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java new file mode 100644 index 0000000..634ceae --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java @@ -0,0 +1,46 @@ +package com.casic.accessControl.app.domain; + +import javax.persistence.*; +import java.util.Date; + +/** + * app的版本信息 + */ +//工单 +@Entity +@Table(name = "apkVersion") +public class ApkVersion { + private String version; + private String path; + private Date ts;//时间戳 + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "version") + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + @Column(name = "path") + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + @Column(name = "ts") + public Date getTs() { + return ts; + } + + public void setTs(Date ts) { + this.ts = ts; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java new file mode 100644 index 0000000..1d0242a --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java @@ -0,0 +1,50 @@ +package com.casic.accessControl.app.dto; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.util.TimeFormat; + +/** + * Created by lenovo on 2016/4/13. + */ +public class ApkVersionDto { + private String version; + private String path; + private String ts; + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public String getTs() { + return ts; + } + + public void setTs(String ts) { + this.ts = ts; + } + + public static ApkVersionDto Convert(ApkVersion version) { + if (version == null) { + return null; + } + ApkVersionDto versionDto = new ApkVersionDto(); + versionDto.setVersion(version.getVersion()); + versionDto.setPath(version.getVersion()); + versionDto.setTs(TimeFormat.formatTimestamp(version.getTs())); + + return versionDto; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java b/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java new file mode 100644 index 0000000..28b12a7 --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java @@ -0,0 +1,27 @@ +package com.casic.accessControl.app.manager; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.core.hibernate.HibernateEntityDao; +import org.hibernate.Query; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * + */ +@Service("apkVersionManager") +public class ApkVersionManager extends HibernateEntityDao { + + public ApkVersion getLatestVersion() { + String sql = "from ApkVersion order by ts desc"; + Query query = getSession().createQuery(sql); + List list = query.list(); + if (null != list && list.isEmpty() == false) { + return list.get(0); + } + + return null; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java b/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java new file mode 100644 index 0000000..065d3cc --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java @@ -0,0 +1,66 @@ +package com.casic.accessControl.app.web; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.app.manager.ApkVersionManager; +import com.casic.accessControl.marker.domain.Marker; +import com.casic.accessControl.marker.manager.MarkerManager; +import com.casic.accessControl.task.domain.Task; +import com.casic.accessControl.task.domain.TaskDetail; +import com.casic.accessControl.task.dto.TaskDetailDto; +import com.casic.accessControl.task.dto.TaskDto; +import com.casic.accessControl.task.dto.TaskStatus; +import com.casic.accessControl.task.manager.TaskDetailManager; +import com.casic.accessControl.task.manager.TaskManager; +import com.casic.accessControl.user.domain.Company; +import com.casic.accessControl.user.domain.Role; +import com.casic.accessControl.user.domain.User; +import com.casic.accessControl.user.dto.UserDto; +import com.casic.accessControl.user.manager.RoleManager; +import com.casic.accessControl.user.manager.UserManager; +import com.casic.accessControl.util.DataTable; +import com.casic.accessControl.util.StringUtils; +import com.google.gson.Gson; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +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.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * Created by lenovo on 2016/4/13. + */ +@Controller +@RequestMapping("app") +public class ApkVersionController { + + @Resource + private ApkVersionManager apkVersionManager; + + @RequestMapping("get-latest-version") + @ResponseBody + public Map getLatestVersion(HttpServletResponse response, HttpSession session) { + Map result = new HashMap(); + try { + ApkVersion latest = apkVersionManager.getLatestVersion(); + if (null != latest) { + result.put("version", latest.getVersion()); + result.put("path", latest.getPath()); + } else { + result.put("version", "1.0.0"); + } + } catch (Exception e) { + e.printStackTrace(); + result.put("version", "1.0.0"); + } + + return result; + } + +} diff --git a/src/main/java/com/casic/accessControl/marker/domain/Marker.java b/src/main/java/com/casic/accessControl/marker/domain/Marker.java index 0575cfe..7d5b854 100644 --- a/src/main/java/com/casic/accessControl/marker/domain/Marker.java +++ b/src/main/java/com/casic/accessControl/marker/domain/Marker.java @@ -67,6 +67,10 @@ private String area; @Column(name = "line") private String line; + @Column(name = "colorType") + private String colorType; + @Column(name = "photos") + private String photos; @@ -315,4 +319,20 @@ public void setArea(String area) { this.area = area; } + + public String getColorType() { + return colorType; + } + + public void setColorType(String colorType) { + this.colorType = colorType; + } + + public String getPhotos() { + return photos; + } + + public void setPhotos(String photos) { + this.photos = photos; + } } diff --git a/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java b/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java index 506f31d..c5f8cf5 100644 --- a/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java +++ b/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java @@ -2,12 +2,12 @@ //import com.casic.accessControl.feature.domain.Feature; import com.casic.accessControl.marker.domain.Marker; +import com.casic.accessControl.util.StringUtils; +import com.casic.accessControl.util.TimeFormat; import org.apache.commons.collections.CollectionUtils; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.List; +import java.text.ParseException; +import java.util.*; /** * Created by lenovo on 2016/5/16. @@ -43,6 +43,8 @@ private Long userId; private String area; private String line; + private String colorType; + private String photos; private String btnEdit = "编辑"; private String btnDelete = "删除"; @@ -296,6 +298,23 @@ this.area = area; } + public String getColorType() { + if (StringUtils.isEmpty(colorType)) return "0"; + return colorType; + } + + public void setColorType(String colorType) { + this.colorType = colorType; + } + + public String getPhotos() { + return photos; + } + + public void setPhotos(String photos) { + this.photos = photos; + } + public String getLine() { return line; } @@ -335,6 +354,52 @@ result.setRoad(doNullChange(marker.getRoad())); result.setArea(doNullChange(marker.getArea())); result.setLine(doNullChange(marker.getLine())); + result.setColorType(marker.getColorType()); + result.setPhotos(marker.getPhotos()); + return result; + } + + public static Marker convert2Marker(MarkerDto markerDto) { + if (markerDto == null) return null; + Marker result = new Marker(); + if(markerDto.getLongitude()==null||markerDto.getLatitude()==null) return null; + if (null != markerDto.getCreateTime() && markerDto.getCreateTime().length() == 19) { + try { + result.setCreateTime(TimeFormat.parse(markerDto.getCreateTime(), "yyyy-MM-dd HH:mm:ss")); + } catch (ParseException pex) { + result.setCreateTime(Calendar.getInstance().getTime()); + } + } else { + result.setCreateTime(Calendar.getInstance().getTime()); + } + result.setDepth(doNullChange(markerDto.getDepth())); + result.setId(markerDto.getId()); + result.setLatitude(markerDto.getLatitude()); + result.setLongitude(markerDto.getLongitude()); + result.setMarkerId(markerDto.getMarkerId()); + result.setMarkerDepth(doNullChange(markerDto.getMarkerDepth())); + result.setMarkerObjectId(doNullChange(markerDto.getMarkerObjectId())); + result.setMarkerObjectType(doNullChange(markerDto.getMarkerObjectType())); + result.setOwnerComp(doNullChange(markerDto.getOwnerComp())); + result.setIsValid(markerDto.getIsValid()); + result.setMemo(doNullChange(markerDto.getMemo())); + result.setPipeDiameter(doNullChange(markerDto.getPipeDiameter())); + result.setPipeMaterial(doNullChange(markerDto.getPipeMaterial())); + result.setMarkerType(doNullChange(markerDto.getMarkerType())); + result.setCreator(doNullChange(markerDto.getCreator())); + + result.setLayStyle(doNullChange(markerDto.getLayStyle())); + result.setBelowDepth(doNullChange(markerDto.getBelowDepth())); + result.setBelowDiameter(doNullChange(markerDto.getBelowDiameter())); + result.setBelowMaterial(doNullChange(markerDto.getBelowMaterial())); + result.setBelowType(doNullChange(markerDto.getBelowType())); + result.setConstructTime(doNullChange(markerDto.getConstructTime())); + result.setRecordType(markerDto.getRecordType()); + result.setRoad(doNullChange(markerDto.getRoad())); + result.setArea(doNullChange(markerDto.getArea())); + result.setLine(doNullChange(markerDto.getLine())); + result.setColorType(markerDto.getColorType()); + result.setPhotos(markerDto.getPhotos()); return result; } diff --git a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java index dd0fa4b..ba5a1fb 100644 --- a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java +++ b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java @@ -9,10 +9,7 @@ import com.casic.accessControl.marker.domain.Marker; import com.casic.accessControl.user.domain.Company; import com.casic.accessControl.user.domain.User; -import com.casic.accessControl.util.DataTable; -import com.casic.accessControl.util.DataTableParameter; -import com.casic.accessControl.util.DataTableUtils; -import com.casic.accessControl.util.DateUtils; +import com.casic.accessControl.util.*; import com.google.gson.Gson; import jxl.*; import jxl.read.biff.BiffException; @@ -31,11 +28,15 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; +import sun.misc.BASE64Decoder; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.File; +import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.text.ParseException; @@ -183,6 +184,53 @@ } /** + * 保存标识器和图片信息 + * @param markerDto + * @param companyId + * @param fileNames + * @param fileBuffers + * @return + */ + public boolean saveMarkerAndPhotos(MarkerDto markerDto, Long companyId, String[] fileNames, String[] fileBuffers) { + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + String strDirPath = request.getSession().getServletContext().getRealPath(""); + FileOutputStream fos = null; + String month = TimeFormat.format(Calendar.getInstance().getTime(), "yyyyMM"); + String webPath = "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String toDir = strDirPath + "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String filePaths = ""; + try { + for (int i = 0; i < fileBuffers.length; i++) { + if (fileBuffers[i] != null && fileNames[i] != null) { +// filePaths += toDir+fileNames[i]+","; + filePaths += webPath + fileNames[i] + ","; + byte[] buffer = new BASE64Decoder().decodeBuffer(fileBuffers[i]); //对android传过来的图片字符串进行解码 + File destDir = new File(toDir); + if (!destDir.exists()) + destDir.mkdirs(); + File imageFile = new File(destDir, fileNames[i]); + fos = new FileOutputStream(imageFile); //保存图片 + fos.write(buffer); + fos.flush(); + fos.close(); + } + } + if (filePaths.endsWith(",")) { + filePaths = filePaths.substring(0, filePaths.length() - 1); + } + } catch (Exception e) { + return false; + } + Marker marker = MarkerDto.convert2Marker(markerDto); + marker.setIsValid(1); + marker.setCompanyId(companyId); + marker.setPhotos(filePaths); + save(marker); + return true; + + } + + /** * 新增标识器 8-9 * * @param markers @@ -582,7 +630,7 @@ "所属区域","所属线路","所属道路","建设年代","权属单位","标示对象ID", "标识器ID","标识器类型","标识器埋深","安装部门","经度", "纬度", "最后修改时间","备注","下层管种类", "下层管埋深", - "下层管直径", "下层管材料", "标识对象类别"}; + "下层管直径", "下层管材料", "标识对象类别", "标识点颜色", "图片地址"}; Label[][] labels = new Label[markerDtos.size() + 1][titleTxt.length]; for(int k=0;k saveMarkerAndPhotos(@RequestParam(value = "fileBuffer1", required = false) MultipartFile fileBuffer1, + @RequestParam(value = "fileBuffer2", required = false) MultipartFile fileBuffer2, + @RequestParam(value = "fileBuffer3", required = false) MultipartFile fileBuffer3, + @RequestParam(value = "jsonMarker", required = true) String jsonMarker) { + Map map = new HashMap(); + map.put("message", "安装无标识器信息"); + Gson gson = new Gson(); + try { + MarkerDto marker = gson.fromJson(jsonMarker, MarkerDto.class); + + if (null == marker.getMarkerId()) { + map.put("message", "无标识器ID"); + map.put("success", "false"); + return map; + } else if (markerManager.getMarkerByMarkerId(marker.getMarkerId()).size() > 0) { + map.put("message", "已安装过该标识器[" + marker.getMarkerId() + "]"); + map.put("success", "false"); + return map; + } else { + String[] fileNames = new String[3]; + String[] fileBuffers = new String[3]; + if (fileBuffer1 != null) { + fileNames[0] = marker.getMarkerId() + "_" + fileBuffer1.getOriginalFilename(); + byte[] fis = fileBuffer1.getBytes(); + fileBuffers[0] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, com.sun.org.apache.xml.internal.security.utils.Base64.BASE64DEFAULTLENGTH)); + } + if (fileBuffer2 != null) { + fileNames[1] = marker.getMarkerId() + "_" + fileBuffer2.getOriginalFilename(); + byte[] fis = fileBuffer2.getBytes(); + fileBuffers[1] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, com.sun.org.apache.xml.internal.security.utils.Base64.BASE64DEFAULTLENGTH)); + } + if (fileBuffer3 != null) { + fileNames[2] = marker.getMarkerId() + "_" + fileBuffer3.getOriginalFilename(); + byte[] fis = fileBuffer3.getBytes(); + fileBuffers[2] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, Base64.BASE64DEFAULTLENGTH)); + } + Long companyId = marker.getCompanyId(); + if (companyId == null) { + return map; + } + boolean result = markerManager.saveMarkerAndPhotos(marker, companyId, fileNames, fileBuffers); + if (!result) { + return map; + } + } + } catch (Exception e) { + return map; + } + map.put("success", "true"); + map.put("message", "保存成功"); + return map; + } + + @RequestMapping("marker-info-delete") @ResponseBody public Map delete(@RequestParam(value = "id", required = true) Long id) { @@ -144,6 +208,9 @@ map.put("message", "删除需要ID信息"); return map; } + + System.out.println(ids); + markerManager.delMarkerByIds(ids); map.put("success", true); map.put("message", "删除成功"); @@ -240,6 +307,54 @@ return map; } + /** + * 批量上传标识点,用于无信号地区标识器信息统一上传,不修改已有标识点信息 + * @param strMarkers + * @return + */ + @RequestMapping("batch-save-no-update") + @ResponseBody + public Map batchSaveOrUpdate(@RequestParam(value = "markers", required = true) String strMarkers) { + strMarkers = strMarkers.replace('\n',' '); + Map map = new HashMap(); + map.put("message", "批量导入失败,或无导入标识器信息"); + Gson gson = new Gson(); + try { + List markers = gson.fromJson(strMarkers, new TypeToken>() { + }.getType()); + if (CollectionUtils.isEmpty(markers)) {//批量导入数据不存在,直接返回 + map.put("message", "批量导入数据不存在"); + return map; + } + + Long companyId = markers.get(0).getCompanyId(); + if (companyId == null) { + map.put("message", "未找到所属公司属性"); + return map; + } + + List markerDtoForSave = new ArrayList(); + for (MarkerDto markerDto : markers) { + // 上传marker的Id不为空且数据库中不存在记录,经纬度不为空,允许保存 + if (StringUtils.isNotBlank(markerDto.getMarkerId()) && markerManager.getMarkerByMarkerId(markerDto.getMarkerId()).size() <= 0) { + if (null != markerDto.getLongitude() && null != markerDto.getLatitude()) { + markerDtoForSave.add(markerDto); + } + } + } + boolean result = markerManager.batchSave(markerDtoForSave, companyId); + if (!result) { + return map; + } + } catch (Exception e) { + e.printStackTrace(); + return map; + } + map.put("success", true); + map.put("message", "保存成功"); + return map; + } + @RequestMapping("getMarkerListByCondition") @ResponseBody @POST diff --git a/src/main/java/com/casic/accessControl/user/web/UserController.java b/src/main/java/com/casic/accessControl/user/web/UserController.java index feab678..3534a97 100644 --- a/src/main/java/com/casic/accessControl/user/web/UserController.java +++ b/src/main/java/com/casic/accessControl/user/web/UserController.java @@ -46,6 +46,7 @@ @ResponseBody public Map login(@ModelAttribute User userInfo, HttpSession session) { Map result = new HashMap(); + User user = null; try{ user = userManager.login(userInfo); diff --git a/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java b/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java new file mode 100644 index 0000000..582120f --- /dev/null +++ b/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java @@ -0,0 +1,129 @@ +package com.casic.accessControl.util; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.net.URL; +import java.net.URLConnection; +import java.util.List; +import java.util.Map; + +/** + * Created by lenovo on 2016/8/31. + */ +public class HttpRequestUtils { + + /** + * 向指定URL发送GET方法的请求 + * + * @param url + * 发送请求的URL + * @param param + * 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 + * @return URL 所代表远程资源的响应结果 + */ + public static String sendGet(String url, String param) { + String result = ""; + BufferedReader in = null; + try { + String urlNameString = url + "?" + param; + URL realUrl = new URL(urlNameString); + // 打开和URL之间的连接 + URLConnection connection = realUrl.openConnection(); + // 设置通用的请求属性 + connection.setRequestProperty("accept", "*/*"); + connection.setRequestProperty("connection", "Keep-Alive"); + connection.setRequestProperty("user-agent", + "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + // 建立实际的连接 + connection.connect(); + // 获取所有响应头字段 + Map> map = connection.getHeaderFields(); + // 遍历所有的响应头字段 + for (String key : map.keySet()) { + System.out.println(key + "--->" + map.get(key)); + } + // 定义 BufferedReader输入流来读取URL的响应 + in = new BufferedReader(new InputStreamReader( + connection.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + result += line; + } + } catch (Exception e) { + System.out.println("发送GET请求出现异常!" + e); + e.printStackTrace(); + } + // 使用finally块来关闭输入流 + finally { + try { + if (in != null) { + in.close(); + } + } catch (Exception e2) { + e2.printStackTrace(); + } + } + return result; + } + + /** + * 向指定 URL 发送POST方法的请求 + * + * @param url + * 发送请求的 URL + * @param param + * 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 + * @return 所代表远程资源的响应结果 + */ + public static String sendPost(String url, String param) { + PrintWriter out = null; + BufferedReader in = null; + String result = ""; + try { + URL realUrl = new URL(url); + // 打开和URL之间的连接 + URLConnection conn = realUrl.openConnection(); + // 设置通用的请求属性 + conn.setRequestProperty("accept", "*/*"); + conn.setRequestProperty("connection", "Keep-Alive"); + conn.setRequestProperty("user-agent", + "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + // 发送POST请求必须设置如下两行 + conn.setDoOutput(true); + conn.setDoInput(true); + // 获取URLConnection对象对应的输出流 + out = new PrintWriter(conn.getOutputStream()); + // 发送请求参数 + out.print(param); + // flush输出流的缓冲 + out.flush(); + // 定义BufferedReader输入流来读取URL的响应 + in = new BufferedReader( + new InputStreamReader(conn.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + result += line; + } + } catch (Exception e) { + System.out.println("发送 POST 请求出现异常!"+e); + e.printStackTrace(); + } + //使用finally块来关闭输出流、输入流 + finally{ + try{ + if(out!=null){ + out.close(); + } + if(in!=null){ + in.close(); + } + } + catch(IOException ex){ + ex.printStackTrace(); + } + } + return result; + } + } \ No newline at end of file diff --git a/src/main/java/com/casic/accessControl/util/TimeFormat.java b/src/main/java/com/casic/accessControl/util/TimeFormat.java new file mode 100644 index 0000000..e9168d5 --- /dev/null +++ b/src/main/java/com/casic/accessControl/util/TimeFormat.java @@ -0,0 +1,148 @@ +package com.casic.accessControl.util; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +/** + * 格式化日期工具类 + * 默认模式yyyy-MM-dd HH:mm:ss + * @author Administrator + * + */ +public class TimeFormat { + + private static final String DATE_FORMAT_STRING = "yyyy-MM-dd"; + private static final String TIME_FORMAT_STRING = "HH:mm:ss"; + private static final String TIMESTAMP_FORMAT_STRING = "yyyy-MM-dd HH:mm:ss"; + + // 默认格式化格式 + private static SimpleDateFormat defaultFormat = new SimpleDateFormat(TIMESTAMP_FORMAT_STRING); + + public static void setFormatString(String pattern) { + defaultFormat.applyPattern(pattern); + } + + /** + * 默认格式化日期 + * + * @param Date date + * @return String + */ + public static String format(Date date) { + return defaultFormat.format(date); + } + + /** + * 日期格式化 + * + * @param date + * @return + */ + public static String formatDate(Date date) { + return TimeFormat.format(date, DATE_FORMAT_STRING); + } + + /** + * 时间格式化 + * + * @param date + * @return + */ + public static String formatTime(Date date) { + return TimeFormat.format(date, TIME_FORMAT_STRING); + } + + /** + * 时间戳格式化 + * + * @param date + * @return + */ + public static String formatTimestamp(Date date) { + return TimeFormat.format(date, TIMESTAMP_FORMAT_STRING); + } + + /** + * 以指定模式格式化日期 + * + * @param Date date + * @param String pattern + * @return String + */ + public static String format(Date date, String pattern) { + SimpleDateFormat formatter = new SimpleDateFormat(pattern); + return formatter.format(date); + } + + /** + * 根据起止日期生成日期序列 + * 包括start和end的日期 + * + * @param start + * @param end + * @return + */ + public static List generateDates(String start, String end) throws ParseException { + List dates = new ArrayList(); + Calendar s = Calendar.getInstance(); + Calendar e = Calendar.getInstance(); + s.setTime(TimeFormat.parse(start, DATE_FORMAT_STRING)); + s.set(Calendar.HOUR_OF_DAY, 0); + s.set(Calendar.MINUTE, 0); + s.set(Calendar.SECOND, 0); + e.setTime(TimeFormat.parse(end, DATE_FORMAT_STRING)); + e.set(Calendar.HOUR_OF_DAY, 0); + e.set(Calendar.MINUTE, 0); + e.set(Calendar.SECOND, 0); + while (s.before(e) == true) { + dates.add(TimeFormat.formatDate(s.getTime())); + s.add(Calendar.DATE, 1); + } + + dates.add(end); + return dates; + } + + + /** + * 解析日期字符串 + * + * @param String source + * @return Date + * + * @throws ParseException + */ + public static Date parse(String source) throws ParseException { + return defaultFormat.parse(source); + } + + /** + * 以指定模式解析日期 + * + * @param String source + * @param String pattern + * @return Date + * + * @throws ParseException + */ + public static Date parse(String source, String pattern) throws ParseException { + SimpleDateFormat formatter = new SimpleDateFormat(pattern); + return formatter.parse(source); + } + + + public static Date parseDateWithoutTime(String source) throws ParseException { + SimpleDateFormat formatter = new SimpleDateFormat(DATE_FORMAT_STRING); + Calendar date = Calendar.getInstance(); + date.setTime(formatter.parse(source)); + date.set(Calendar.HOUR, 0); + date.set(Calendar.HOUR, 0); + date.set(Calendar.MINUTE, 0); + return date.getTime(); + } + +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 53c91ea..cea976f 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -15,19 +15,17 @@ # ============================================================================ # db # ============================================================================ -#db.default.driverClassName=oracle.jdbc.driver.OracleDriver -#db.default.url=jdbc:oracle:thin:@192.168.0.203:1521:SZHTDB2 -#db.default.username=scott -#db.default.password=SZHTDB2 db.default.driverClassName=com.mysql.jdbc.Driver -db.default.url=jdbc:mysql://127.0.0.1:3306/ems?useUnicode=true&characterEncoding=UTF-8 -db.default.username=emsweb -db.default.password=emsweb +db.default.url=jdbc:mysql://127.0.0.1:3306/ems_tong?useUnicode=true&characterEncoding=UTF-8 +db.default.username=root +db.default.password=root +#db.default.username=emsweb +#db.default.password=emsweb #db.default.url=jdbc:mysql://119.254.110.71:3307/ems?useUnicode=true&characterEncoding=UTF-8 #db.default.username=root #db.default.password=rootems - -# ============================================================================ +# +## ============================================================================ # log4jdbc # ============================================================================ log4jdbc.enable=true diff --git a/src/main/resources/spring/applicationContext-filter.xml b/src/main/resources/spring/applicationContext-filter.xml index a08c5fc..98ac7d6 100644 --- a/src/main/resources/spring/applicationContext-filter.xml +++ b/src/main/resources/spring/applicationContext-filter.xml @@ -35,9 +35,13 @@ /user/ill-login.do /marker/exportMarker.do /marker/batchSave-na.do + /marker/batch-save-no-update.do + /marker/save-marker-photo.do /event/save-event.do /task/get-task.do + /app/get-latest-version.do /xls/* + /apk/* diff --git a/src/main/resources/spring/applicationContext-hibernate.xml b/src/main/resources/spring/applicationContext-hibernate.xml index 5bb1a7e..dc54192 100644 --- a/src/main/resources/spring/applicationContext-hibernate.xml +++ b/src/main/resources/spring/applicationContext-hibernate.xml @@ -65,6 +65,7 @@ com.casic.accessControl.task.domain.Position com.casic.accessControl.event.domain.Event com.casic.accessControl.marker.domain.OptionItem + com.casic.accessControl.app.domain.ApkVersion diff --git a/src/main/webapp/common/layout/menu_new.jsp b/src/main/webapp/common/layout/menu_new.jsp index 3cf4b4e..cbd822e 100644 --- a/src/main/webapp/common/layout/menu_new.jsp +++ b/src/main/webapp/common/layout/menu_new.jsp @@ -20,7 +20,7 @@
    • - + @@ -54,7 +54,7 @@
    • - + diff --git a/src/main/webapp/content/ems/ems-gd.jsp b/src/main/webapp/content/ems/ems-gd.jsp new file mode 100644 index 0000000..5137b49 --- /dev/null +++ b/src/main/webapp/content/ems/ems-gd.jsp @@ -0,0 +1,604 @@ +<%@page contentType="text/html;charset=UTF-8" %> + +<%@include file="/taglibs.jsp" %> + +<%pageContext.setAttribute("currentMenu", "ems");%> + + + + + + + + + + + + + 地下管线电子标识系统 + + + + + + + + + + + + + + + + + + +<%-- + +--%> + + + + + + + + + + + + + + +<%@include file="/common/layout/header.jsp" %> + +
      + + + + <%@include file="/common/layout/menu_new.jsp" %> + + + +
      + + + +
      + +
      + + +
      +
      +
      +
      + +
      +
      + +
      +
      + +
      +
      + +
      +
      + +
      + +
      + +
      + +
      + +
      + +
      +
      +
      + + + + +
      +
      +
      +
      + + + + +
      +
      +
      + +
      + +
      + +<%--todo list:错误使用方法 + +--%> +
      + +
      +
      + +
      + +
      + +
      + + +
      + +
      + + 移动 + 绘制区域 + 新增标识器 + 删除标识器 + 保存标识器 + 批量导入 + 导出Excel + 清空 + +
      + +
      +
      + +
      + + + +
      + +
      + +
      + + + + +
      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/webapp/content/task/task-gd.jsp b/src/main/webapp/content/task/task-gd.jsp new file mode 100644 index 0000000..d2d5549 --- /dev/null +++ b/src/main/webapp/content/task/task-gd.jsp @@ -0,0 +1,374 @@ +<%@page contentType="text/html;charset=UTF-8" %> + +<%@include file="/taglibs.jsp" %> + +<%pageContext.setAttribute("currentMenu", "task");%> + + + + + + + + + + + + + 地下管线电子标识系统 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +<%@include file="/common/layout/header.jsp" %> + +
      + + + + <%@include file="/common/layout/menu_new.jsp" %> + + + +
      + + + +
      + +
      + +
      + + 移动 + 绘制区域 + 选择多点创建工单 + 清空选择 + +
      + +
      + +
      + + +
      + +
      + +
      + +
      历史工单
      + +
      + +
      + +
      + <%--巡检员:--%> +
      +
      + + +
      +
      + + +
        +
      +
        +
        + +
        + +
        + +
        + +
        +
        + +
        + + + +
        + +
        + +
        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/webapp/images/drop/0.png b/src/main/webapp/images/drop/0.png new file mode 100644 index 0000000..f4b966b --- /dev/null +++ b/src/main/webapp/images/drop/0.png Binary files differ diff --git a/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java new file mode 100644 index 0000000..634ceae --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java @@ -0,0 +1,46 @@ +package com.casic.accessControl.app.domain; + +import javax.persistence.*; +import java.util.Date; + +/** + * app的版本信息 + */ +//工单 +@Entity +@Table(name = "apkVersion") +public class ApkVersion { + private String version; + private String path; + private Date ts;//时间戳 + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "version") + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + @Column(name = "path") + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + @Column(name = "ts") + public Date getTs() { + return ts; + } + + public void setTs(Date ts) { + this.ts = ts; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java new file mode 100644 index 0000000..1d0242a --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java @@ -0,0 +1,50 @@ +package com.casic.accessControl.app.dto; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.util.TimeFormat; + +/** + * Created by lenovo on 2016/4/13. + */ +public class ApkVersionDto { + private String version; + private String path; + private String ts; + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public String getTs() { + return ts; + } + + public void setTs(String ts) { + this.ts = ts; + } + + public static ApkVersionDto Convert(ApkVersion version) { + if (version == null) { + return null; + } + ApkVersionDto versionDto = new ApkVersionDto(); + versionDto.setVersion(version.getVersion()); + versionDto.setPath(version.getVersion()); + versionDto.setTs(TimeFormat.formatTimestamp(version.getTs())); + + return versionDto; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java b/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java new file mode 100644 index 0000000..28b12a7 --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java @@ -0,0 +1,27 @@ +package com.casic.accessControl.app.manager; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.core.hibernate.HibernateEntityDao; +import org.hibernate.Query; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * + */ +@Service("apkVersionManager") +public class ApkVersionManager extends HibernateEntityDao { + + public ApkVersion getLatestVersion() { + String sql = "from ApkVersion order by ts desc"; + Query query = getSession().createQuery(sql); + List list = query.list(); + if (null != list && list.isEmpty() == false) { + return list.get(0); + } + + return null; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java b/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java new file mode 100644 index 0000000..065d3cc --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java @@ -0,0 +1,66 @@ +package com.casic.accessControl.app.web; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.app.manager.ApkVersionManager; +import com.casic.accessControl.marker.domain.Marker; +import com.casic.accessControl.marker.manager.MarkerManager; +import com.casic.accessControl.task.domain.Task; +import com.casic.accessControl.task.domain.TaskDetail; +import com.casic.accessControl.task.dto.TaskDetailDto; +import com.casic.accessControl.task.dto.TaskDto; +import com.casic.accessControl.task.dto.TaskStatus; +import com.casic.accessControl.task.manager.TaskDetailManager; +import com.casic.accessControl.task.manager.TaskManager; +import com.casic.accessControl.user.domain.Company; +import com.casic.accessControl.user.domain.Role; +import com.casic.accessControl.user.domain.User; +import com.casic.accessControl.user.dto.UserDto; +import com.casic.accessControl.user.manager.RoleManager; +import com.casic.accessControl.user.manager.UserManager; +import com.casic.accessControl.util.DataTable; +import com.casic.accessControl.util.StringUtils; +import com.google.gson.Gson; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +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.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * Created by lenovo on 2016/4/13. + */ +@Controller +@RequestMapping("app") +public class ApkVersionController { + + @Resource + private ApkVersionManager apkVersionManager; + + @RequestMapping("get-latest-version") + @ResponseBody + public Map getLatestVersion(HttpServletResponse response, HttpSession session) { + Map result = new HashMap(); + try { + ApkVersion latest = apkVersionManager.getLatestVersion(); + if (null != latest) { + result.put("version", latest.getVersion()); + result.put("path", latest.getPath()); + } else { + result.put("version", "1.0.0"); + } + } catch (Exception e) { + e.printStackTrace(); + result.put("version", "1.0.0"); + } + + return result; + } + +} diff --git a/src/main/java/com/casic/accessControl/marker/domain/Marker.java b/src/main/java/com/casic/accessControl/marker/domain/Marker.java index 0575cfe..7d5b854 100644 --- a/src/main/java/com/casic/accessControl/marker/domain/Marker.java +++ b/src/main/java/com/casic/accessControl/marker/domain/Marker.java @@ -67,6 +67,10 @@ private String area; @Column(name = "line") private String line; + @Column(name = "colorType") + private String colorType; + @Column(name = "photos") + private String photos; @@ -315,4 +319,20 @@ public void setArea(String area) { this.area = area; } + + public String getColorType() { + return colorType; + } + + public void setColorType(String colorType) { + this.colorType = colorType; + } + + public String getPhotos() { + return photos; + } + + public void setPhotos(String photos) { + this.photos = photos; + } } diff --git a/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java b/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java index 506f31d..c5f8cf5 100644 --- a/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java +++ b/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java @@ -2,12 +2,12 @@ //import com.casic.accessControl.feature.domain.Feature; import com.casic.accessControl.marker.domain.Marker; +import com.casic.accessControl.util.StringUtils; +import com.casic.accessControl.util.TimeFormat; import org.apache.commons.collections.CollectionUtils; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.List; +import java.text.ParseException; +import java.util.*; /** * Created by lenovo on 2016/5/16. @@ -43,6 +43,8 @@ private Long userId; private String area; private String line; + private String colorType; + private String photos; private String btnEdit = "编辑"; private String btnDelete = "删除"; @@ -296,6 +298,23 @@ this.area = area; } + public String getColorType() { + if (StringUtils.isEmpty(colorType)) return "0"; + return colorType; + } + + public void setColorType(String colorType) { + this.colorType = colorType; + } + + public String getPhotos() { + return photos; + } + + public void setPhotos(String photos) { + this.photos = photos; + } + public String getLine() { return line; } @@ -335,6 +354,52 @@ result.setRoad(doNullChange(marker.getRoad())); result.setArea(doNullChange(marker.getArea())); result.setLine(doNullChange(marker.getLine())); + result.setColorType(marker.getColorType()); + result.setPhotos(marker.getPhotos()); + return result; + } + + public static Marker convert2Marker(MarkerDto markerDto) { + if (markerDto == null) return null; + Marker result = new Marker(); + if(markerDto.getLongitude()==null||markerDto.getLatitude()==null) return null; + if (null != markerDto.getCreateTime() && markerDto.getCreateTime().length() == 19) { + try { + result.setCreateTime(TimeFormat.parse(markerDto.getCreateTime(), "yyyy-MM-dd HH:mm:ss")); + } catch (ParseException pex) { + result.setCreateTime(Calendar.getInstance().getTime()); + } + } else { + result.setCreateTime(Calendar.getInstance().getTime()); + } + result.setDepth(doNullChange(markerDto.getDepth())); + result.setId(markerDto.getId()); + result.setLatitude(markerDto.getLatitude()); + result.setLongitude(markerDto.getLongitude()); + result.setMarkerId(markerDto.getMarkerId()); + result.setMarkerDepth(doNullChange(markerDto.getMarkerDepth())); + result.setMarkerObjectId(doNullChange(markerDto.getMarkerObjectId())); + result.setMarkerObjectType(doNullChange(markerDto.getMarkerObjectType())); + result.setOwnerComp(doNullChange(markerDto.getOwnerComp())); + result.setIsValid(markerDto.getIsValid()); + result.setMemo(doNullChange(markerDto.getMemo())); + result.setPipeDiameter(doNullChange(markerDto.getPipeDiameter())); + result.setPipeMaterial(doNullChange(markerDto.getPipeMaterial())); + result.setMarkerType(doNullChange(markerDto.getMarkerType())); + result.setCreator(doNullChange(markerDto.getCreator())); + + result.setLayStyle(doNullChange(markerDto.getLayStyle())); + result.setBelowDepth(doNullChange(markerDto.getBelowDepth())); + result.setBelowDiameter(doNullChange(markerDto.getBelowDiameter())); + result.setBelowMaterial(doNullChange(markerDto.getBelowMaterial())); + result.setBelowType(doNullChange(markerDto.getBelowType())); + result.setConstructTime(doNullChange(markerDto.getConstructTime())); + result.setRecordType(markerDto.getRecordType()); + result.setRoad(doNullChange(markerDto.getRoad())); + result.setArea(doNullChange(markerDto.getArea())); + result.setLine(doNullChange(markerDto.getLine())); + result.setColorType(markerDto.getColorType()); + result.setPhotos(markerDto.getPhotos()); return result; } diff --git a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java index dd0fa4b..ba5a1fb 100644 --- a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java +++ b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java @@ -9,10 +9,7 @@ import com.casic.accessControl.marker.domain.Marker; import com.casic.accessControl.user.domain.Company; import com.casic.accessControl.user.domain.User; -import com.casic.accessControl.util.DataTable; -import com.casic.accessControl.util.DataTableParameter; -import com.casic.accessControl.util.DataTableUtils; -import com.casic.accessControl.util.DateUtils; +import com.casic.accessControl.util.*; import com.google.gson.Gson; import jxl.*; import jxl.read.biff.BiffException; @@ -31,11 +28,15 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; +import sun.misc.BASE64Decoder; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.File; +import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.text.ParseException; @@ -183,6 +184,53 @@ } /** + * 保存标识器和图片信息 + * @param markerDto + * @param companyId + * @param fileNames + * @param fileBuffers + * @return + */ + public boolean saveMarkerAndPhotos(MarkerDto markerDto, Long companyId, String[] fileNames, String[] fileBuffers) { + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + String strDirPath = request.getSession().getServletContext().getRealPath(""); + FileOutputStream fos = null; + String month = TimeFormat.format(Calendar.getInstance().getTime(), "yyyyMM"); + String webPath = "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String toDir = strDirPath + "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String filePaths = ""; + try { + for (int i = 0; i < fileBuffers.length; i++) { + if (fileBuffers[i] != null && fileNames[i] != null) { +// filePaths += toDir+fileNames[i]+","; + filePaths += webPath + fileNames[i] + ","; + byte[] buffer = new BASE64Decoder().decodeBuffer(fileBuffers[i]); //对android传过来的图片字符串进行解码 + File destDir = new File(toDir); + if (!destDir.exists()) + destDir.mkdirs(); + File imageFile = new File(destDir, fileNames[i]); + fos = new FileOutputStream(imageFile); //保存图片 + fos.write(buffer); + fos.flush(); + fos.close(); + } + } + if (filePaths.endsWith(",")) { + filePaths = filePaths.substring(0, filePaths.length() - 1); + } + } catch (Exception e) { + return false; + } + Marker marker = MarkerDto.convert2Marker(markerDto); + marker.setIsValid(1); + marker.setCompanyId(companyId); + marker.setPhotos(filePaths); + save(marker); + return true; + + } + + /** * 新增标识器 8-9 * * @param markers @@ -582,7 +630,7 @@ "所属区域","所属线路","所属道路","建设年代","权属单位","标示对象ID", "标识器ID","标识器类型","标识器埋深","安装部门","经度", "纬度", "最后修改时间","备注","下层管种类", "下层管埋深", - "下层管直径", "下层管材料", "标识对象类别"}; + "下层管直径", "下层管材料", "标识对象类别", "标识点颜色", "图片地址"}; Label[][] labels = new Label[markerDtos.size() + 1][titleTxt.length]; for(int k=0;k saveMarkerAndPhotos(@RequestParam(value = "fileBuffer1", required = false) MultipartFile fileBuffer1, + @RequestParam(value = "fileBuffer2", required = false) MultipartFile fileBuffer2, + @RequestParam(value = "fileBuffer3", required = false) MultipartFile fileBuffer3, + @RequestParam(value = "jsonMarker", required = true) String jsonMarker) { + Map map = new HashMap(); + map.put("message", "安装无标识器信息"); + Gson gson = new Gson(); + try { + MarkerDto marker = gson.fromJson(jsonMarker, MarkerDto.class); + + if (null == marker.getMarkerId()) { + map.put("message", "无标识器ID"); + map.put("success", "false"); + return map; + } else if (markerManager.getMarkerByMarkerId(marker.getMarkerId()).size() > 0) { + map.put("message", "已安装过该标识器[" + marker.getMarkerId() + "]"); + map.put("success", "false"); + return map; + } else { + String[] fileNames = new String[3]; + String[] fileBuffers = new String[3]; + if (fileBuffer1 != null) { + fileNames[0] = marker.getMarkerId() + "_" + fileBuffer1.getOriginalFilename(); + byte[] fis = fileBuffer1.getBytes(); + fileBuffers[0] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, com.sun.org.apache.xml.internal.security.utils.Base64.BASE64DEFAULTLENGTH)); + } + if (fileBuffer2 != null) { + fileNames[1] = marker.getMarkerId() + "_" + fileBuffer2.getOriginalFilename(); + byte[] fis = fileBuffer2.getBytes(); + fileBuffers[1] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, com.sun.org.apache.xml.internal.security.utils.Base64.BASE64DEFAULTLENGTH)); + } + if (fileBuffer3 != null) { + fileNames[2] = marker.getMarkerId() + "_" + fileBuffer3.getOriginalFilename(); + byte[] fis = fileBuffer3.getBytes(); + fileBuffers[2] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, Base64.BASE64DEFAULTLENGTH)); + } + Long companyId = marker.getCompanyId(); + if (companyId == null) { + return map; + } + boolean result = markerManager.saveMarkerAndPhotos(marker, companyId, fileNames, fileBuffers); + if (!result) { + return map; + } + } + } catch (Exception e) { + return map; + } + map.put("success", "true"); + map.put("message", "保存成功"); + return map; + } + + @RequestMapping("marker-info-delete") @ResponseBody public Map delete(@RequestParam(value = "id", required = true) Long id) { @@ -144,6 +208,9 @@ map.put("message", "删除需要ID信息"); return map; } + + System.out.println(ids); + markerManager.delMarkerByIds(ids); map.put("success", true); map.put("message", "删除成功"); @@ -240,6 +307,54 @@ return map; } + /** + * 批量上传标识点,用于无信号地区标识器信息统一上传,不修改已有标识点信息 + * @param strMarkers + * @return + */ + @RequestMapping("batch-save-no-update") + @ResponseBody + public Map batchSaveOrUpdate(@RequestParam(value = "markers", required = true) String strMarkers) { + strMarkers = strMarkers.replace('\n',' '); + Map map = new HashMap(); + map.put("message", "批量导入失败,或无导入标识器信息"); + Gson gson = new Gson(); + try { + List markers = gson.fromJson(strMarkers, new TypeToken>() { + }.getType()); + if (CollectionUtils.isEmpty(markers)) {//批量导入数据不存在,直接返回 + map.put("message", "批量导入数据不存在"); + return map; + } + + Long companyId = markers.get(0).getCompanyId(); + if (companyId == null) { + map.put("message", "未找到所属公司属性"); + return map; + } + + List markerDtoForSave = new ArrayList(); + for (MarkerDto markerDto : markers) { + // 上传marker的Id不为空且数据库中不存在记录,经纬度不为空,允许保存 + if (StringUtils.isNotBlank(markerDto.getMarkerId()) && markerManager.getMarkerByMarkerId(markerDto.getMarkerId()).size() <= 0) { + if (null != markerDto.getLongitude() && null != markerDto.getLatitude()) { + markerDtoForSave.add(markerDto); + } + } + } + boolean result = markerManager.batchSave(markerDtoForSave, companyId); + if (!result) { + return map; + } + } catch (Exception e) { + e.printStackTrace(); + return map; + } + map.put("success", true); + map.put("message", "保存成功"); + return map; + } + @RequestMapping("getMarkerListByCondition") @ResponseBody @POST diff --git a/src/main/java/com/casic/accessControl/user/web/UserController.java b/src/main/java/com/casic/accessControl/user/web/UserController.java index feab678..3534a97 100644 --- a/src/main/java/com/casic/accessControl/user/web/UserController.java +++ b/src/main/java/com/casic/accessControl/user/web/UserController.java @@ -46,6 +46,7 @@ @ResponseBody public Map login(@ModelAttribute User userInfo, HttpSession session) { Map result = new HashMap(); + User user = null; try{ user = userManager.login(userInfo); diff --git a/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java b/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java new file mode 100644 index 0000000..582120f --- /dev/null +++ b/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java @@ -0,0 +1,129 @@ +package com.casic.accessControl.util; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.net.URL; +import java.net.URLConnection; +import java.util.List; +import java.util.Map; + +/** + * Created by lenovo on 2016/8/31. + */ +public class HttpRequestUtils { + + /** + * 向指定URL发送GET方法的请求 + * + * @param url + * 发送请求的URL + * @param param + * 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 + * @return URL 所代表远程资源的响应结果 + */ + public static String sendGet(String url, String param) { + String result = ""; + BufferedReader in = null; + try { + String urlNameString = url + "?" + param; + URL realUrl = new URL(urlNameString); + // 打开和URL之间的连接 + URLConnection connection = realUrl.openConnection(); + // 设置通用的请求属性 + connection.setRequestProperty("accept", "*/*"); + connection.setRequestProperty("connection", "Keep-Alive"); + connection.setRequestProperty("user-agent", + "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + // 建立实际的连接 + connection.connect(); + // 获取所有响应头字段 + Map> map = connection.getHeaderFields(); + // 遍历所有的响应头字段 + for (String key : map.keySet()) { + System.out.println(key + "--->" + map.get(key)); + } + // 定义 BufferedReader输入流来读取URL的响应 + in = new BufferedReader(new InputStreamReader( + connection.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + result += line; + } + } catch (Exception e) { + System.out.println("发送GET请求出现异常!" + e); + e.printStackTrace(); + } + // 使用finally块来关闭输入流 + finally { + try { + if (in != null) { + in.close(); + } + } catch (Exception e2) { + e2.printStackTrace(); + } + } + return result; + } + + /** + * 向指定 URL 发送POST方法的请求 + * + * @param url + * 发送请求的 URL + * @param param + * 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 + * @return 所代表远程资源的响应结果 + */ + public static String sendPost(String url, String param) { + PrintWriter out = null; + BufferedReader in = null; + String result = ""; + try { + URL realUrl = new URL(url); + // 打开和URL之间的连接 + URLConnection conn = realUrl.openConnection(); + // 设置通用的请求属性 + conn.setRequestProperty("accept", "*/*"); + conn.setRequestProperty("connection", "Keep-Alive"); + conn.setRequestProperty("user-agent", + "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + // 发送POST请求必须设置如下两行 + conn.setDoOutput(true); + conn.setDoInput(true); + // 获取URLConnection对象对应的输出流 + out = new PrintWriter(conn.getOutputStream()); + // 发送请求参数 + out.print(param); + // flush输出流的缓冲 + out.flush(); + // 定义BufferedReader输入流来读取URL的响应 + in = new BufferedReader( + new InputStreamReader(conn.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + result += line; + } + } catch (Exception e) { + System.out.println("发送 POST 请求出现异常!"+e); + e.printStackTrace(); + } + //使用finally块来关闭输出流、输入流 + finally{ + try{ + if(out!=null){ + out.close(); + } + if(in!=null){ + in.close(); + } + } + catch(IOException ex){ + ex.printStackTrace(); + } + } + return result; + } + } \ No newline at end of file diff --git a/src/main/java/com/casic/accessControl/util/TimeFormat.java b/src/main/java/com/casic/accessControl/util/TimeFormat.java new file mode 100644 index 0000000..e9168d5 --- /dev/null +++ b/src/main/java/com/casic/accessControl/util/TimeFormat.java @@ -0,0 +1,148 @@ +package com.casic.accessControl.util; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +/** + * 格式化日期工具类 + * 默认模式yyyy-MM-dd HH:mm:ss + * @author Administrator + * + */ +public class TimeFormat { + + private static final String DATE_FORMAT_STRING = "yyyy-MM-dd"; + private static final String TIME_FORMAT_STRING = "HH:mm:ss"; + private static final String TIMESTAMP_FORMAT_STRING = "yyyy-MM-dd HH:mm:ss"; + + // 默认格式化格式 + private static SimpleDateFormat defaultFormat = new SimpleDateFormat(TIMESTAMP_FORMAT_STRING); + + public static void setFormatString(String pattern) { + defaultFormat.applyPattern(pattern); + } + + /** + * 默认格式化日期 + * + * @param Date date + * @return String + */ + public static String format(Date date) { + return defaultFormat.format(date); + } + + /** + * 日期格式化 + * + * @param date + * @return + */ + public static String formatDate(Date date) { + return TimeFormat.format(date, DATE_FORMAT_STRING); + } + + /** + * 时间格式化 + * + * @param date + * @return + */ + public static String formatTime(Date date) { + return TimeFormat.format(date, TIME_FORMAT_STRING); + } + + /** + * 时间戳格式化 + * + * @param date + * @return + */ + public static String formatTimestamp(Date date) { + return TimeFormat.format(date, TIMESTAMP_FORMAT_STRING); + } + + /** + * 以指定模式格式化日期 + * + * @param Date date + * @param String pattern + * @return String + */ + public static String format(Date date, String pattern) { + SimpleDateFormat formatter = new SimpleDateFormat(pattern); + return formatter.format(date); + } + + /** + * 根据起止日期生成日期序列 + * 包括start和end的日期 + * + * @param start + * @param end + * @return + */ + public static List generateDates(String start, String end) throws ParseException { + List dates = new ArrayList(); + Calendar s = Calendar.getInstance(); + Calendar e = Calendar.getInstance(); + s.setTime(TimeFormat.parse(start, DATE_FORMAT_STRING)); + s.set(Calendar.HOUR_OF_DAY, 0); + s.set(Calendar.MINUTE, 0); + s.set(Calendar.SECOND, 0); + e.setTime(TimeFormat.parse(end, DATE_FORMAT_STRING)); + e.set(Calendar.HOUR_OF_DAY, 0); + e.set(Calendar.MINUTE, 0); + e.set(Calendar.SECOND, 0); + while (s.before(e) == true) { + dates.add(TimeFormat.formatDate(s.getTime())); + s.add(Calendar.DATE, 1); + } + + dates.add(end); + return dates; + } + + + /** + * 解析日期字符串 + * + * @param String source + * @return Date + * + * @throws ParseException + */ + public static Date parse(String source) throws ParseException { + return defaultFormat.parse(source); + } + + /** + * 以指定模式解析日期 + * + * @param String source + * @param String pattern + * @return Date + * + * @throws ParseException + */ + public static Date parse(String source, String pattern) throws ParseException { + SimpleDateFormat formatter = new SimpleDateFormat(pattern); + return formatter.parse(source); + } + + + public static Date parseDateWithoutTime(String source) throws ParseException { + SimpleDateFormat formatter = new SimpleDateFormat(DATE_FORMAT_STRING); + Calendar date = Calendar.getInstance(); + date.setTime(formatter.parse(source)); + date.set(Calendar.HOUR, 0); + date.set(Calendar.HOUR, 0); + date.set(Calendar.MINUTE, 0); + return date.getTime(); + } + +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 53c91ea..cea976f 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -15,19 +15,17 @@ # ============================================================================ # db # ============================================================================ -#db.default.driverClassName=oracle.jdbc.driver.OracleDriver -#db.default.url=jdbc:oracle:thin:@192.168.0.203:1521:SZHTDB2 -#db.default.username=scott -#db.default.password=SZHTDB2 db.default.driverClassName=com.mysql.jdbc.Driver -db.default.url=jdbc:mysql://127.0.0.1:3306/ems?useUnicode=true&characterEncoding=UTF-8 -db.default.username=emsweb -db.default.password=emsweb +db.default.url=jdbc:mysql://127.0.0.1:3306/ems_tong?useUnicode=true&characterEncoding=UTF-8 +db.default.username=root +db.default.password=root +#db.default.username=emsweb +#db.default.password=emsweb #db.default.url=jdbc:mysql://119.254.110.71:3307/ems?useUnicode=true&characterEncoding=UTF-8 #db.default.username=root #db.default.password=rootems - -# ============================================================================ +# +## ============================================================================ # log4jdbc # ============================================================================ log4jdbc.enable=true diff --git a/src/main/resources/spring/applicationContext-filter.xml b/src/main/resources/spring/applicationContext-filter.xml index a08c5fc..98ac7d6 100644 --- a/src/main/resources/spring/applicationContext-filter.xml +++ b/src/main/resources/spring/applicationContext-filter.xml @@ -35,9 +35,13 @@ /user/ill-login.do /marker/exportMarker.do /marker/batchSave-na.do + /marker/batch-save-no-update.do + /marker/save-marker-photo.do /event/save-event.do /task/get-task.do + /app/get-latest-version.do /xls/* + /apk/* diff --git a/src/main/resources/spring/applicationContext-hibernate.xml b/src/main/resources/spring/applicationContext-hibernate.xml index 5bb1a7e..dc54192 100644 --- a/src/main/resources/spring/applicationContext-hibernate.xml +++ b/src/main/resources/spring/applicationContext-hibernate.xml @@ -65,6 +65,7 @@ com.casic.accessControl.task.domain.Position com.casic.accessControl.event.domain.Event com.casic.accessControl.marker.domain.OptionItem + com.casic.accessControl.app.domain.ApkVersion diff --git a/src/main/webapp/common/layout/menu_new.jsp b/src/main/webapp/common/layout/menu_new.jsp index 3cf4b4e..cbd822e 100644 --- a/src/main/webapp/common/layout/menu_new.jsp +++ b/src/main/webapp/common/layout/menu_new.jsp @@ -20,7 +20,7 @@
      • - + @@ -54,7 +54,7 @@
      • - + diff --git a/src/main/webapp/content/ems/ems-gd.jsp b/src/main/webapp/content/ems/ems-gd.jsp new file mode 100644 index 0000000..5137b49 --- /dev/null +++ b/src/main/webapp/content/ems/ems-gd.jsp @@ -0,0 +1,604 @@ +<%@page contentType="text/html;charset=UTF-8" %> + +<%@include file="/taglibs.jsp" %> + +<%pageContext.setAttribute("currentMenu", "ems");%> + + + + + + + + + + + + + 地下管线电子标识系统 + + + + + + + + + + + + + + + + + + +<%-- + +--%> + + + + + + + + + + + + + + +<%@include file="/common/layout/header.jsp" %> + +
        + + + + <%@include file="/common/layout/menu_new.jsp" %> + + + +
        + + + +
        + +
        + + +
        +
        +
        +
        + +
        +
        + +
        +
        + +
        +
        + +
        +
        + +
        + +
        + +
        + +
        + +
        + +
        +
        +
        + + + + +
        +
        +
        +
        + + + + +
        +
        +
        + +
        + +
        + +<%--todo list:错误使用方法 + +--%> +
        + +
        +
        + +
        + +
        + +
        + + +
        + +
        + + 移动 + 绘制区域 + 新增标识器 + 删除标识器 + 保存标识器 + 批量导入 + 导出Excel + 清空 + +
        + +
        +
        + +
        + + + +
        + +
        + +
        + + + + +
        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/webapp/content/task/task-gd.jsp b/src/main/webapp/content/task/task-gd.jsp new file mode 100644 index 0000000..d2d5549 --- /dev/null +++ b/src/main/webapp/content/task/task-gd.jsp @@ -0,0 +1,374 @@ +<%@page contentType="text/html;charset=UTF-8" %> + +<%@include file="/taglibs.jsp" %> + +<%pageContext.setAttribute("currentMenu", "task");%> + + + + + + + + + + + + + 地下管线电子标识系统 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +<%@include file="/common/layout/header.jsp" %> + +
        + + + + <%@include file="/common/layout/menu_new.jsp" %> + + + +
        + + + +
        + +
        + +
        + + 移动 + 绘制区域 + 选择多点创建工单 + 清空选择 + +
        + +
        + +
        + + +
        + +
        + +
        + +
        历史工单
        + +
        + +
        + +
        + <%--巡检员:--%> +
        +
        + + +
        +
        + + +
          +
        +
          +
          + +
          + +
          + +
          + +
          +
          + +
          + + + +
          + +
          + +
          + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/webapp/images/drop/0.png b/src/main/webapp/images/drop/0.png new file mode 100644 index 0000000..f4b966b --- /dev/null +++ b/src/main/webapp/images/drop/0.png Binary files differ diff --git a/src/main/webapp/images/drop/1.png b/src/main/webapp/images/drop/1.png new file mode 100644 index 0000000..9284b64 --- /dev/null +++ b/src/main/webapp/images/drop/1.png Binary files differ diff --git a/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java new file mode 100644 index 0000000..634ceae --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java @@ -0,0 +1,46 @@ +package com.casic.accessControl.app.domain; + +import javax.persistence.*; +import java.util.Date; + +/** + * app的版本信息 + */ +//工单 +@Entity +@Table(name = "apkVersion") +public class ApkVersion { + private String version; + private String path; + private Date ts;//时间戳 + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "version") + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + @Column(name = "path") + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + @Column(name = "ts") + public Date getTs() { + return ts; + } + + public void setTs(Date ts) { + this.ts = ts; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java new file mode 100644 index 0000000..1d0242a --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java @@ -0,0 +1,50 @@ +package com.casic.accessControl.app.dto; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.util.TimeFormat; + +/** + * Created by lenovo on 2016/4/13. + */ +public class ApkVersionDto { + private String version; + private String path; + private String ts; + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public String getTs() { + return ts; + } + + public void setTs(String ts) { + this.ts = ts; + } + + public static ApkVersionDto Convert(ApkVersion version) { + if (version == null) { + return null; + } + ApkVersionDto versionDto = new ApkVersionDto(); + versionDto.setVersion(version.getVersion()); + versionDto.setPath(version.getVersion()); + versionDto.setTs(TimeFormat.formatTimestamp(version.getTs())); + + return versionDto; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java b/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java new file mode 100644 index 0000000..28b12a7 --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java @@ -0,0 +1,27 @@ +package com.casic.accessControl.app.manager; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.core.hibernate.HibernateEntityDao; +import org.hibernate.Query; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * + */ +@Service("apkVersionManager") +public class ApkVersionManager extends HibernateEntityDao { + + public ApkVersion getLatestVersion() { + String sql = "from ApkVersion order by ts desc"; + Query query = getSession().createQuery(sql); + List list = query.list(); + if (null != list && list.isEmpty() == false) { + return list.get(0); + } + + return null; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java b/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java new file mode 100644 index 0000000..065d3cc --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java @@ -0,0 +1,66 @@ +package com.casic.accessControl.app.web; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.app.manager.ApkVersionManager; +import com.casic.accessControl.marker.domain.Marker; +import com.casic.accessControl.marker.manager.MarkerManager; +import com.casic.accessControl.task.domain.Task; +import com.casic.accessControl.task.domain.TaskDetail; +import com.casic.accessControl.task.dto.TaskDetailDto; +import com.casic.accessControl.task.dto.TaskDto; +import com.casic.accessControl.task.dto.TaskStatus; +import com.casic.accessControl.task.manager.TaskDetailManager; +import com.casic.accessControl.task.manager.TaskManager; +import com.casic.accessControl.user.domain.Company; +import com.casic.accessControl.user.domain.Role; +import com.casic.accessControl.user.domain.User; +import com.casic.accessControl.user.dto.UserDto; +import com.casic.accessControl.user.manager.RoleManager; +import com.casic.accessControl.user.manager.UserManager; +import com.casic.accessControl.util.DataTable; +import com.casic.accessControl.util.StringUtils; +import com.google.gson.Gson; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +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.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * Created by lenovo on 2016/4/13. + */ +@Controller +@RequestMapping("app") +public class ApkVersionController { + + @Resource + private ApkVersionManager apkVersionManager; + + @RequestMapping("get-latest-version") + @ResponseBody + public Map getLatestVersion(HttpServletResponse response, HttpSession session) { + Map result = new HashMap(); + try { + ApkVersion latest = apkVersionManager.getLatestVersion(); + if (null != latest) { + result.put("version", latest.getVersion()); + result.put("path", latest.getPath()); + } else { + result.put("version", "1.0.0"); + } + } catch (Exception e) { + e.printStackTrace(); + result.put("version", "1.0.0"); + } + + return result; + } + +} diff --git a/src/main/java/com/casic/accessControl/marker/domain/Marker.java b/src/main/java/com/casic/accessControl/marker/domain/Marker.java index 0575cfe..7d5b854 100644 --- a/src/main/java/com/casic/accessControl/marker/domain/Marker.java +++ b/src/main/java/com/casic/accessControl/marker/domain/Marker.java @@ -67,6 +67,10 @@ private String area; @Column(name = "line") private String line; + @Column(name = "colorType") + private String colorType; + @Column(name = "photos") + private String photos; @@ -315,4 +319,20 @@ public void setArea(String area) { this.area = area; } + + public String getColorType() { + return colorType; + } + + public void setColorType(String colorType) { + this.colorType = colorType; + } + + public String getPhotos() { + return photos; + } + + public void setPhotos(String photos) { + this.photos = photos; + } } diff --git a/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java b/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java index 506f31d..c5f8cf5 100644 --- a/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java +++ b/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java @@ -2,12 +2,12 @@ //import com.casic.accessControl.feature.domain.Feature; import com.casic.accessControl.marker.domain.Marker; +import com.casic.accessControl.util.StringUtils; +import com.casic.accessControl.util.TimeFormat; import org.apache.commons.collections.CollectionUtils; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.List; +import java.text.ParseException; +import java.util.*; /** * Created by lenovo on 2016/5/16. @@ -43,6 +43,8 @@ private Long userId; private String area; private String line; + private String colorType; + private String photos; private String btnEdit = "编辑"; private String btnDelete = "删除"; @@ -296,6 +298,23 @@ this.area = area; } + public String getColorType() { + if (StringUtils.isEmpty(colorType)) return "0"; + return colorType; + } + + public void setColorType(String colorType) { + this.colorType = colorType; + } + + public String getPhotos() { + return photos; + } + + public void setPhotos(String photos) { + this.photos = photos; + } + public String getLine() { return line; } @@ -335,6 +354,52 @@ result.setRoad(doNullChange(marker.getRoad())); result.setArea(doNullChange(marker.getArea())); result.setLine(doNullChange(marker.getLine())); + result.setColorType(marker.getColorType()); + result.setPhotos(marker.getPhotos()); + return result; + } + + public static Marker convert2Marker(MarkerDto markerDto) { + if (markerDto == null) return null; + Marker result = new Marker(); + if(markerDto.getLongitude()==null||markerDto.getLatitude()==null) return null; + if (null != markerDto.getCreateTime() && markerDto.getCreateTime().length() == 19) { + try { + result.setCreateTime(TimeFormat.parse(markerDto.getCreateTime(), "yyyy-MM-dd HH:mm:ss")); + } catch (ParseException pex) { + result.setCreateTime(Calendar.getInstance().getTime()); + } + } else { + result.setCreateTime(Calendar.getInstance().getTime()); + } + result.setDepth(doNullChange(markerDto.getDepth())); + result.setId(markerDto.getId()); + result.setLatitude(markerDto.getLatitude()); + result.setLongitude(markerDto.getLongitude()); + result.setMarkerId(markerDto.getMarkerId()); + result.setMarkerDepth(doNullChange(markerDto.getMarkerDepth())); + result.setMarkerObjectId(doNullChange(markerDto.getMarkerObjectId())); + result.setMarkerObjectType(doNullChange(markerDto.getMarkerObjectType())); + result.setOwnerComp(doNullChange(markerDto.getOwnerComp())); + result.setIsValid(markerDto.getIsValid()); + result.setMemo(doNullChange(markerDto.getMemo())); + result.setPipeDiameter(doNullChange(markerDto.getPipeDiameter())); + result.setPipeMaterial(doNullChange(markerDto.getPipeMaterial())); + result.setMarkerType(doNullChange(markerDto.getMarkerType())); + result.setCreator(doNullChange(markerDto.getCreator())); + + result.setLayStyle(doNullChange(markerDto.getLayStyle())); + result.setBelowDepth(doNullChange(markerDto.getBelowDepth())); + result.setBelowDiameter(doNullChange(markerDto.getBelowDiameter())); + result.setBelowMaterial(doNullChange(markerDto.getBelowMaterial())); + result.setBelowType(doNullChange(markerDto.getBelowType())); + result.setConstructTime(doNullChange(markerDto.getConstructTime())); + result.setRecordType(markerDto.getRecordType()); + result.setRoad(doNullChange(markerDto.getRoad())); + result.setArea(doNullChange(markerDto.getArea())); + result.setLine(doNullChange(markerDto.getLine())); + result.setColorType(markerDto.getColorType()); + result.setPhotos(markerDto.getPhotos()); return result; } diff --git a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java index dd0fa4b..ba5a1fb 100644 --- a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java +++ b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java @@ -9,10 +9,7 @@ import com.casic.accessControl.marker.domain.Marker; import com.casic.accessControl.user.domain.Company; import com.casic.accessControl.user.domain.User; -import com.casic.accessControl.util.DataTable; -import com.casic.accessControl.util.DataTableParameter; -import com.casic.accessControl.util.DataTableUtils; -import com.casic.accessControl.util.DateUtils; +import com.casic.accessControl.util.*; import com.google.gson.Gson; import jxl.*; import jxl.read.biff.BiffException; @@ -31,11 +28,15 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; +import sun.misc.BASE64Decoder; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.File; +import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.text.ParseException; @@ -183,6 +184,53 @@ } /** + * 保存标识器和图片信息 + * @param markerDto + * @param companyId + * @param fileNames + * @param fileBuffers + * @return + */ + public boolean saveMarkerAndPhotos(MarkerDto markerDto, Long companyId, String[] fileNames, String[] fileBuffers) { + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + String strDirPath = request.getSession().getServletContext().getRealPath(""); + FileOutputStream fos = null; + String month = TimeFormat.format(Calendar.getInstance().getTime(), "yyyyMM"); + String webPath = "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String toDir = strDirPath + "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String filePaths = ""; + try { + for (int i = 0; i < fileBuffers.length; i++) { + if (fileBuffers[i] != null && fileNames[i] != null) { +// filePaths += toDir+fileNames[i]+","; + filePaths += webPath + fileNames[i] + ","; + byte[] buffer = new BASE64Decoder().decodeBuffer(fileBuffers[i]); //对android传过来的图片字符串进行解码 + File destDir = new File(toDir); + if (!destDir.exists()) + destDir.mkdirs(); + File imageFile = new File(destDir, fileNames[i]); + fos = new FileOutputStream(imageFile); //保存图片 + fos.write(buffer); + fos.flush(); + fos.close(); + } + } + if (filePaths.endsWith(",")) { + filePaths = filePaths.substring(0, filePaths.length() - 1); + } + } catch (Exception e) { + return false; + } + Marker marker = MarkerDto.convert2Marker(markerDto); + marker.setIsValid(1); + marker.setCompanyId(companyId); + marker.setPhotos(filePaths); + save(marker); + return true; + + } + + /** * 新增标识器 8-9 * * @param markers @@ -582,7 +630,7 @@ "所属区域","所属线路","所属道路","建设年代","权属单位","标示对象ID", "标识器ID","标识器类型","标识器埋深","安装部门","经度", "纬度", "最后修改时间","备注","下层管种类", "下层管埋深", - "下层管直径", "下层管材料", "标识对象类别"}; + "下层管直径", "下层管材料", "标识对象类别", "标识点颜色", "图片地址"}; Label[][] labels = new Label[markerDtos.size() + 1][titleTxt.length]; for(int k=0;k saveMarkerAndPhotos(@RequestParam(value = "fileBuffer1", required = false) MultipartFile fileBuffer1, + @RequestParam(value = "fileBuffer2", required = false) MultipartFile fileBuffer2, + @RequestParam(value = "fileBuffer3", required = false) MultipartFile fileBuffer3, + @RequestParam(value = "jsonMarker", required = true) String jsonMarker) { + Map map = new HashMap(); + map.put("message", "安装无标识器信息"); + Gson gson = new Gson(); + try { + MarkerDto marker = gson.fromJson(jsonMarker, MarkerDto.class); + + if (null == marker.getMarkerId()) { + map.put("message", "无标识器ID"); + map.put("success", "false"); + return map; + } else if (markerManager.getMarkerByMarkerId(marker.getMarkerId()).size() > 0) { + map.put("message", "已安装过该标识器[" + marker.getMarkerId() + "]"); + map.put("success", "false"); + return map; + } else { + String[] fileNames = new String[3]; + String[] fileBuffers = new String[3]; + if (fileBuffer1 != null) { + fileNames[0] = marker.getMarkerId() + "_" + fileBuffer1.getOriginalFilename(); + byte[] fis = fileBuffer1.getBytes(); + fileBuffers[0] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, com.sun.org.apache.xml.internal.security.utils.Base64.BASE64DEFAULTLENGTH)); + } + if (fileBuffer2 != null) { + fileNames[1] = marker.getMarkerId() + "_" + fileBuffer2.getOriginalFilename(); + byte[] fis = fileBuffer2.getBytes(); + fileBuffers[1] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, com.sun.org.apache.xml.internal.security.utils.Base64.BASE64DEFAULTLENGTH)); + } + if (fileBuffer3 != null) { + fileNames[2] = marker.getMarkerId() + "_" + fileBuffer3.getOriginalFilename(); + byte[] fis = fileBuffer3.getBytes(); + fileBuffers[2] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, Base64.BASE64DEFAULTLENGTH)); + } + Long companyId = marker.getCompanyId(); + if (companyId == null) { + return map; + } + boolean result = markerManager.saveMarkerAndPhotos(marker, companyId, fileNames, fileBuffers); + if (!result) { + return map; + } + } + } catch (Exception e) { + return map; + } + map.put("success", "true"); + map.put("message", "保存成功"); + return map; + } + + @RequestMapping("marker-info-delete") @ResponseBody public Map delete(@RequestParam(value = "id", required = true) Long id) { @@ -144,6 +208,9 @@ map.put("message", "删除需要ID信息"); return map; } + + System.out.println(ids); + markerManager.delMarkerByIds(ids); map.put("success", true); map.put("message", "删除成功"); @@ -240,6 +307,54 @@ return map; } + /** + * 批量上传标识点,用于无信号地区标识器信息统一上传,不修改已有标识点信息 + * @param strMarkers + * @return + */ + @RequestMapping("batch-save-no-update") + @ResponseBody + public Map batchSaveOrUpdate(@RequestParam(value = "markers", required = true) String strMarkers) { + strMarkers = strMarkers.replace('\n',' '); + Map map = new HashMap(); + map.put("message", "批量导入失败,或无导入标识器信息"); + Gson gson = new Gson(); + try { + List markers = gson.fromJson(strMarkers, new TypeToken>() { + }.getType()); + if (CollectionUtils.isEmpty(markers)) {//批量导入数据不存在,直接返回 + map.put("message", "批量导入数据不存在"); + return map; + } + + Long companyId = markers.get(0).getCompanyId(); + if (companyId == null) { + map.put("message", "未找到所属公司属性"); + return map; + } + + List markerDtoForSave = new ArrayList(); + for (MarkerDto markerDto : markers) { + // 上传marker的Id不为空且数据库中不存在记录,经纬度不为空,允许保存 + if (StringUtils.isNotBlank(markerDto.getMarkerId()) && markerManager.getMarkerByMarkerId(markerDto.getMarkerId()).size() <= 0) { + if (null != markerDto.getLongitude() && null != markerDto.getLatitude()) { + markerDtoForSave.add(markerDto); + } + } + } + boolean result = markerManager.batchSave(markerDtoForSave, companyId); + if (!result) { + return map; + } + } catch (Exception e) { + e.printStackTrace(); + return map; + } + map.put("success", true); + map.put("message", "保存成功"); + return map; + } + @RequestMapping("getMarkerListByCondition") @ResponseBody @POST diff --git a/src/main/java/com/casic/accessControl/user/web/UserController.java b/src/main/java/com/casic/accessControl/user/web/UserController.java index feab678..3534a97 100644 --- a/src/main/java/com/casic/accessControl/user/web/UserController.java +++ b/src/main/java/com/casic/accessControl/user/web/UserController.java @@ -46,6 +46,7 @@ @ResponseBody public Map login(@ModelAttribute User userInfo, HttpSession session) { Map result = new HashMap(); + User user = null; try{ user = userManager.login(userInfo); diff --git a/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java b/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java new file mode 100644 index 0000000..582120f --- /dev/null +++ b/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java @@ -0,0 +1,129 @@ +package com.casic.accessControl.util; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.net.URL; +import java.net.URLConnection; +import java.util.List; +import java.util.Map; + +/** + * Created by lenovo on 2016/8/31. + */ +public class HttpRequestUtils { + + /** + * 向指定URL发送GET方法的请求 + * + * @param url + * 发送请求的URL + * @param param + * 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 + * @return URL 所代表远程资源的响应结果 + */ + public static String sendGet(String url, String param) { + String result = ""; + BufferedReader in = null; + try { + String urlNameString = url + "?" + param; + URL realUrl = new URL(urlNameString); + // 打开和URL之间的连接 + URLConnection connection = realUrl.openConnection(); + // 设置通用的请求属性 + connection.setRequestProperty("accept", "*/*"); + connection.setRequestProperty("connection", "Keep-Alive"); + connection.setRequestProperty("user-agent", + "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + // 建立实际的连接 + connection.connect(); + // 获取所有响应头字段 + Map> map = connection.getHeaderFields(); + // 遍历所有的响应头字段 + for (String key : map.keySet()) { + System.out.println(key + "--->" + map.get(key)); + } + // 定义 BufferedReader输入流来读取URL的响应 + in = new BufferedReader(new InputStreamReader( + connection.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + result += line; + } + } catch (Exception e) { + System.out.println("发送GET请求出现异常!" + e); + e.printStackTrace(); + } + // 使用finally块来关闭输入流 + finally { + try { + if (in != null) { + in.close(); + } + } catch (Exception e2) { + e2.printStackTrace(); + } + } + return result; + } + + /** + * 向指定 URL 发送POST方法的请求 + * + * @param url + * 发送请求的 URL + * @param param + * 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 + * @return 所代表远程资源的响应结果 + */ + public static String sendPost(String url, String param) { + PrintWriter out = null; + BufferedReader in = null; + String result = ""; + try { + URL realUrl = new URL(url); + // 打开和URL之间的连接 + URLConnection conn = realUrl.openConnection(); + // 设置通用的请求属性 + conn.setRequestProperty("accept", "*/*"); + conn.setRequestProperty("connection", "Keep-Alive"); + conn.setRequestProperty("user-agent", + "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + // 发送POST请求必须设置如下两行 + conn.setDoOutput(true); + conn.setDoInput(true); + // 获取URLConnection对象对应的输出流 + out = new PrintWriter(conn.getOutputStream()); + // 发送请求参数 + out.print(param); + // flush输出流的缓冲 + out.flush(); + // 定义BufferedReader输入流来读取URL的响应 + in = new BufferedReader( + new InputStreamReader(conn.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + result += line; + } + } catch (Exception e) { + System.out.println("发送 POST 请求出现异常!"+e); + e.printStackTrace(); + } + //使用finally块来关闭输出流、输入流 + finally{ + try{ + if(out!=null){ + out.close(); + } + if(in!=null){ + in.close(); + } + } + catch(IOException ex){ + ex.printStackTrace(); + } + } + return result; + } + } \ No newline at end of file diff --git a/src/main/java/com/casic/accessControl/util/TimeFormat.java b/src/main/java/com/casic/accessControl/util/TimeFormat.java new file mode 100644 index 0000000..e9168d5 --- /dev/null +++ b/src/main/java/com/casic/accessControl/util/TimeFormat.java @@ -0,0 +1,148 @@ +package com.casic.accessControl.util; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +/** + * 格式化日期工具类 + * 默认模式yyyy-MM-dd HH:mm:ss + * @author Administrator + * + */ +public class TimeFormat { + + private static final String DATE_FORMAT_STRING = "yyyy-MM-dd"; + private static final String TIME_FORMAT_STRING = "HH:mm:ss"; + private static final String TIMESTAMP_FORMAT_STRING = "yyyy-MM-dd HH:mm:ss"; + + // 默认格式化格式 + private static SimpleDateFormat defaultFormat = new SimpleDateFormat(TIMESTAMP_FORMAT_STRING); + + public static void setFormatString(String pattern) { + defaultFormat.applyPattern(pattern); + } + + /** + * 默认格式化日期 + * + * @param Date date + * @return String + */ + public static String format(Date date) { + return defaultFormat.format(date); + } + + /** + * 日期格式化 + * + * @param date + * @return + */ + public static String formatDate(Date date) { + return TimeFormat.format(date, DATE_FORMAT_STRING); + } + + /** + * 时间格式化 + * + * @param date + * @return + */ + public static String formatTime(Date date) { + return TimeFormat.format(date, TIME_FORMAT_STRING); + } + + /** + * 时间戳格式化 + * + * @param date + * @return + */ + public static String formatTimestamp(Date date) { + return TimeFormat.format(date, TIMESTAMP_FORMAT_STRING); + } + + /** + * 以指定模式格式化日期 + * + * @param Date date + * @param String pattern + * @return String + */ + public static String format(Date date, String pattern) { + SimpleDateFormat formatter = new SimpleDateFormat(pattern); + return formatter.format(date); + } + + /** + * 根据起止日期生成日期序列 + * 包括start和end的日期 + * + * @param start + * @param end + * @return + */ + public static List generateDates(String start, String end) throws ParseException { + List dates = new ArrayList(); + Calendar s = Calendar.getInstance(); + Calendar e = Calendar.getInstance(); + s.setTime(TimeFormat.parse(start, DATE_FORMAT_STRING)); + s.set(Calendar.HOUR_OF_DAY, 0); + s.set(Calendar.MINUTE, 0); + s.set(Calendar.SECOND, 0); + e.setTime(TimeFormat.parse(end, DATE_FORMAT_STRING)); + e.set(Calendar.HOUR_OF_DAY, 0); + e.set(Calendar.MINUTE, 0); + e.set(Calendar.SECOND, 0); + while (s.before(e) == true) { + dates.add(TimeFormat.formatDate(s.getTime())); + s.add(Calendar.DATE, 1); + } + + dates.add(end); + return dates; + } + + + /** + * 解析日期字符串 + * + * @param String source + * @return Date + * + * @throws ParseException + */ + public static Date parse(String source) throws ParseException { + return defaultFormat.parse(source); + } + + /** + * 以指定模式解析日期 + * + * @param String source + * @param String pattern + * @return Date + * + * @throws ParseException + */ + public static Date parse(String source, String pattern) throws ParseException { + SimpleDateFormat formatter = new SimpleDateFormat(pattern); + return formatter.parse(source); + } + + + public static Date parseDateWithoutTime(String source) throws ParseException { + SimpleDateFormat formatter = new SimpleDateFormat(DATE_FORMAT_STRING); + Calendar date = Calendar.getInstance(); + date.setTime(formatter.parse(source)); + date.set(Calendar.HOUR, 0); + date.set(Calendar.HOUR, 0); + date.set(Calendar.MINUTE, 0); + return date.getTime(); + } + +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 53c91ea..cea976f 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -15,19 +15,17 @@ # ============================================================================ # db # ============================================================================ -#db.default.driverClassName=oracle.jdbc.driver.OracleDriver -#db.default.url=jdbc:oracle:thin:@192.168.0.203:1521:SZHTDB2 -#db.default.username=scott -#db.default.password=SZHTDB2 db.default.driverClassName=com.mysql.jdbc.Driver -db.default.url=jdbc:mysql://127.0.0.1:3306/ems?useUnicode=true&characterEncoding=UTF-8 -db.default.username=emsweb -db.default.password=emsweb +db.default.url=jdbc:mysql://127.0.0.1:3306/ems_tong?useUnicode=true&characterEncoding=UTF-8 +db.default.username=root +db.default.password=root +#db.default.username=emsweb +#db.default.password=emsweb #db.default.url=jdbc:mysql://119.254.110.71:3307/ems?useUnicode=true&characterEncoding=UTF-8 #db.default.username=root #db.default.password=rootems - -# ============================================================================ +# +## ============================================================================ # log4jdbc # ============================================================================ log4jdbc.enable=true diff --git a/src/main/resources/spring/applicationContext-filter.xml b/src/main/resources/spring/applicationContext-filter.xml index a08c5fc..98ac7d6 100644 --- a/src/main/resources/spring/applicationContext-filter.xml +++ b/src/main/resources/spring/applicationContext-filter.xml @@ -35,9 +35,13 @@ /user/ill-login.do /marker/exportMarker.do /marker/batchSave-na.do + /marker/batch-save-no-update.do + /marker/save-marker-photo.do /event/save-event.do /task/get-task.do + /app/get-latest-version.do /xls/* + /apk/* diff --git a/src/main/resources/spring/applicationContext-hibernate.xml b/src/main/resources/spring/applicationContext-hibernate.xml index 5bb1a7e..dc54192 100644 --- a/src/main/resources/spring/applicationContext-hibernate.xml +++ b/src/main/resources/spring/applicationContext-hibernate.xml @@ -65,6 +65,7 @@ com.casic.accessControl.task.domain.Position com.casic.accessControl.event.domain.Event com.casic.accessControl.marker.domain.OptionItem + com.casic.accessControl.app.domain.ApkVersion diff --git a/src/main/webapp/common/layout/menu_new.jsp b/src/main/webapp/common/layout/menu_new.jsp index 3cf4b4e..cbd822e 100644 --- a/src/main/webapp/common/layout/menu_new.jsp +++ b/src/main/webapp/common/layout/menu_new.jsp @@ -20,7 +20,7 @@
        • - + @@ -54,7 +54,7 @@
        • - + diff --git a/src/main/webapp/content/ems/ems-gd.jsp b/src/main/webapp/content/ems/ems-gd.jsp new file mode 100644 index 0000000..5137b49 --- /dev/null +++ b/src/main/webapp/content/ems/ems-gd.jsp @@ -0,0 +1,604 @@ +<%@page contentType="text/html;charset=UTF-8" %> + +<%@include file="/taglibs.jsp" %> + +<%pageContext.setAttribute("currentMenu", "ems");%> + + + + + + + + + + + + + 地下管线电子标识系统 + + + + + + + + + + + + + + + + + + +<%-- + +--%> + + + + + + + + + + + + + + +<%@include file="/common/layout/header.jsp" %> + +
          + + + + <%@include file="/common/layout/menu_new.jsp" %> + + + +
          + + + +
          + +
          + + +
          +
          +
          +
          + +
          +
          + +
          +
          + +
          +
          + +
          +
          + +
          + +
          + +
          + +
          + +
          + +
          +
          +
          + + + + +
          +
          +
          +
          + + + + +
          +
          +
          + +
          + +
          + +<%--todo list:错误使用方法 + +--%> +
          + +
          +
          + +
          + +
          + +
          + + +
          + +
          + + 移动 + 绘制区域 + 新增标识器 + 删除标识器 + 保存标识器 + 批量导入 + 导出Excel + 清空 + +
          + +
          +
          + +
          + + + +
          + +
          + +
          + + + + +
          + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/webapp/content/task/task-gd.jsp b/src/main/webapp/content/task/task-gd.jsp new file mode 100644 index 0000000..d2d5549 --- /dev/null +++ b/src/main/webapp/content/task/task-gd.jsp @@ -0,0 +1,374 @@ +<%@page contentType="text/html;charset=UTF-8" %> + +<%@include file="/taglibs.jsp" %> + +<%pageContext.setAttribute("currentMenu", "task");%> + + + + + + + + + + + + + 地下管线电子标识系统 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +<%@include file="/common/layout/header.jsp" %> + +
          + + + + <%@include file="/common/layout/menu_new.jsp" %> + + + +
          + + + +
          + +
          + +
          + + 移动 + 绘制区域 + 选择多点创建工单 + 清空选择 + +
          + +
          + +
          + + +
          + +
          + +
          + +
          历史工单
          + +
          + +
          + +
          + <%--巡检员:--%> +
          +
          + + +
          +
          + + +
            +
          +
            +
            + +
            + +
            + +
            + +
            +
            + +
            + + + +
            + +
            + +
            + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/webapp/images/drop/0.png b/src/main/webapp/images/drop/0.png new file mode 100644 index 0000000..f4b966b --- /dev/null +++ b/src/main/webapp/images/drop/0.png Binary files differ diff --git a/src/main/webapp/images/drop/1.png b/src/main/webapp/images/drop/1.png new file mode 100644 index 0000000..9284b64 --- /dev/null +++ b/src/main/webapp/images/drop/1.png Binary files differ diff --git a/src/main/webapp/images/drop/2.png b/src/main/webapp/images/drop/2.png new file mode 100644 index 0000000..b5425db --- /dev/null +++ b/src/main/webapp/images/drop/2.png Binary files differ diff --git a/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java new file mode 100644 index 0000000..634ceae --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java @@ -0,0 +1,46 @@ +package com.casic.accessControl.app.domain; + +import javax.persistence.*; +import java.util.Date; + +/** + * app的版本信息 + */ +//工单 +@Entity +@Table(name = "apkVersion") +public class ApkVersion { + private String version; + private String path; + private Date ts;//时间戳 + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "version") + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + @Column(name = "path") + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + @Column(name = "ts") + public Date getTs() { + return ts; + } + + public void setTs(Date ts) { + this.ts = ts; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java new file mode 100644 index 0000000..1d0242a --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java @@ -0,0 +1,50 @@ +package com.casic.accessControl.app.dto; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.util.TimeFormat; + +/** + * Created by lenovo on 2016/4/13. + */ +public class ApkVersionDto { + private String version; + private String path; + private String ts; + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public String getTs() { + return ts; + } + + public void setTs(String ts) { + this.ts = ts; + } + + public static ApkVersionDto Convert(ApkVersion version) { + if (version == null) { + return null; + } + ApkVersionDto versionDto = new ApkVersionDto(); + versionDto.setVersion(version.getVersion()); + versionDto.setPath(version.getVersion()); + versionDto.setTs(TimeFormat.formatTimestamp(version.getTs())); + + return versionDto; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java b/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java new file mode 100644 index 0000000..28b12a7 --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java @@ -0,0 +1,27 @@ +package com.casic.accessControl.app.manager; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.core.hibernate.HibernateEntityDao; +import org.hibernate.Query; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * + */ +@Service("apkVersionManager") +public class ApkVersionManager extends HibernateEntityDao { + + public ApkVersion getLatestVersion() { + String sql = "from ApkVersion order by ts desc"; + Query query = getSession().createQuery(sql); + List list = query.list(); + if (null != list && list.isEmpty() == false) { + return list.get(0); + } + + return null; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java b/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java new file mode 100644 index 0000000..065d3cc --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java @@ -0,0 +1,66 @@ +package com.casic.accessControl.app.web; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.app.manager.ApkVersionManager; +import com.casic.accessControl.marker.domain.Marker; +import com.casic.accessControl.marker.manager.MarkerManager; +import com.casic.accessControl.task.domain.Task; +import com.casic.accessControl.task.domain.TaskDetail; +import com.casic.accessControl.task.dto.TaskDetailDto; +import com.casic.accessControl.task.dto.TaskDto; +import com.casic.accessControl.task.dto.TaskStatus; +import com.casic.accessControl.task.manager.TaskDetailManager; +import com.casic.accessControl.task.manager.TaskManager; +import com.casic.accessControl.user.domain.Company; +import com.casic.accessControl.user.domain.Role; +import com.casic.accessControl.user.domain.User; +import com.casic.accessControl.user.dto.UserDto; +import com.casic.accessControl.user.manager.RoleManager; +import com.casic.accessControl.user.manager.UserManager; +import com.casic.accessControl.util.DataTable; +import com.casic.accessControl.util.StringUtils; +import com.google.gson.Gson; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +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.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * Created by lenovo on 2016/4/13. + */ +@Controller +@RequestMapping("app") +public class ApkVersionController { + + @Resource + private ApkVersionManager apkVersionManager; + + @RequestMapping("get-latest-version") + @ResponseBody + public Map getLatestVersion(HttpServletResponse response, HttpSession session) { + Map result = new HashMap(); + try { + ApkVersion latest = apkVersionManager.getLatestVersion(); + if (null != latest) { + result.put("version", latest.getVersion()); + result.put("path", latest.getPath()); + } else { + result.put("version", "1.0.0"); + } + } catch (Exception e) { + e.printStackTrace(); + result.put("version", "1.0.0"); + } + + return result; + } + +} diff --git a/src/main/java/com/casic/accessControl/marker/domain/Marker.java b/src/main/java/com/casic/accessControl/marker/domain/Marker.java index 0575cfe..7d5b854 100644 --- a/src/main/java/com/casic/accessControl/marker/domain/Marker.java +++ b/src/main/java/com/casic/accessControl/marker/domain/Marker.java @@ -67,6 +67,10 @@ private String area; @Column(name = "line") private String line; + @Column(name = "colorType") + private String colorType; + @Column(name = "photos") + private String photos; @@ -315,4 +319,20 @@ public void setArea(String area) { this.area = area; } + + public String getColorType() { + return colorType; + } + + public void setColorType(String colorType) { + this.colorType = colorType; + } + + public String getPhotos() { + return photos; + } + + public void setPhotos(String photos) { + this.photos = photos; + } } diff --git a/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java b/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java index 506f31d..c5f8cf5 100644 --- a/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java +++ b/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java @@ -2,12 +2,12 @@ //import com.casic.accessControl.feature.domain.Feature; import com.casic.accessControl.marker.domain.Marker; +import com.casic.accessControl.util.StringUtils; +import com.casic.accessControl.util.TimeFormat; import org.apache.commons.collections.CollectionUtils; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.List; +import java.text.ParseException; +import java.util.*; /** * Created by lenovo on 2016/5/16. @@ -43,6 +43,8 @@ private Long userId; private String area; private String line; + private String colorType; + private String photos; private String btnEdit = "编辑"; private String btnDelete = "删除"; @@ -296,6 +298,23 @@ this.area = area; } + public String getColorType() { + if (StringUtils.isEmpty(colorType)) return "0"; + return colorType; + } + + public void setColorType(String colorType) { + this.colorType = colorType; + } + + public String getPhotos() { + return photos; + } + + public void setPhotos(String photos) { + this.photos = photos; + } + public String getLine() { return line; } @@ -335,6 +354,52 @@ result.setRoad(doNullChange(marker.getRoad())); result.setArea(doNullChange(marker.getArea())); result.setLine(doNullChange(marker.getLine())); + result.setColorType(marker.getColorType()); + result.setPhotos(marker.getPhotos()); + return result; + } + + public static Marker convert2Marker(MarkerDto markerDto) { + if (markerDto == null) return null; + Marker result = new Marker(); + if(markerDto.getLongitude()==null||markerDto.getLatitude()==null) return null; + if (null != markerDto.getCreateTime() && markerDto.getCreateTime().length() == 19) { + try { + result.setCreateTime(TimeFormat.parse(markerDto.getCreateTime(), "yyyy-MM-dd HH:mm:ss")); + } catch (ParseException pex) { + result.setCreateTime(Calendar.getInstance().getTime()); + } + } else { + result.setCreateTime(Calendar.getInstance().getTime()); + } + result.setDepth(doNullChange(markerDto.getDepth())); + result.setId(markerDto.getId()); + result.setLatitude(markerDto.getLatitude()); + result.setLongitude(markerDto.getLongitude()); + result.setMarkerId(markerDto.getMarkerId()); + result.setMarkerDepth(doNullChange(markerDto.getMarkerDepth())); + result.setMarkerObjectId(doNullChange(markerDto.getMarkerObjectId())); + result.setMarkerObjectType(doNullChange(markerDto.getMarkerObjectType())); + result.setOwnerComp(doNullChange(markerDto.getOwnerComp())); + result.setIsValid(markerDto.getIsValid()); + result.setMemo(doNullChange(markerDto.getMemo())); + result.setPipeDiameter(doNullChange(markerDto.getPipeDiameter())); + result.setPipeMaterial(doNullChange(markerDto.getPipeMaterial())); + result.setMarkerType(doNullChange(markerDto.getMarkerType())); + result.setCreator(doNullChange(markerDto.getCreator())); + + result.setLayStyle(doNullChange(markerDto.getLayStyle())); + result.setBelowDepth(doNullChange(markerDto.getBelowDepth())); + result.setBelowDiameter(doNullChange(markerDto.getBelowDiameter())); + result.setBelowMaterial(doNullChange(markerDto.getBelowMaterial())); + result.setBelowType(doNullChange(markerDto.getBelowType())); + result.setConstructTime(doNullChange(markerDto.getConstructTime())); + result.setRecordType(markerDto.getRecordType()); + result.setRoad(doNullChange(markerDto.getRoad())); + result.setArea(doNullChange(markerDto.getArea())); + result.setLine(doNullChange(markerDto.getLine())); + result.setColorType(markerDto.getColorType()); + result.setPhotos(markerDto.getPhotos()); return result; } diff --git a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java index dd0fa4b..ba5a1fb 100644 --- a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java +++ b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java @@ -9,10 +9,7 @@ import com.casic.accessControl.marker.domain.Marker; import com.casic.accessControl.user.domain.Company; import com.casic.accessControl.user.domain.User; -import com.casic.accessControl.util.DataTable; -import com.casic.accessControl.util.DataTableParameter; -import com.casic.accessControl.util.DataTableUtils; -import com.casic.accessControl.util.DateUtils; +import com.casic.accessControl.util.*; import com.google.gson.Gson; import jxl.*; import jxl.read.biff.BiffException; @@ -31,11 +28,15 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; +import sun.misc.BASE64Decoder; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.File; +import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.text.ParseException; @@ -183,6 +184,53 @@ } /** + * 保存标识器和图片信息 + * @param markerDto + * @param companyId + * @param fileNames + * @param fileBuffers + * @return + */ + public boolean saveMarkerAndPhotos(MarkerDto markerDto, Long companyId, String[] fileNames, String[] fileBuffers) { + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + String strDirPath = request.getSession().getServletContext().getRealPath(""); + FileOutputStream fos = null; + String month = TimeFormat.format(Calendar.getInstance().getTime(), "yyyyMM"); + String webPath = "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String toDir = strDirPath + "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String filePaths = ""; + try { + for (int i = 0; i < fileBuffers.length; i++) { + if (fileBuffers[i] != null && fileNames[i] != null) { +// filePaths += toDir+fileNames[i]+","; + filePaths += webPath + fileNames[i] + ","; + byte[] buffer = new BASE64Decoder().decodeBuffer(fileBuffers[i]); //对android传过来的图片字符串进行解码 + File destDir = new File(toDir); + if (!destDir.exists()) + destDir.mkdirs(); + File imageFile = new File(destDir, fileNames[i]); + fos = new FileOutputStream(imageFile); //保存图片 + fos.write(buffer); + fos.flush(); + fos.close(); + } + } + if (filePaths.endsWith(",")) { + filePaths = filePaths.substring(0, filePaths.length() - 1); + } + } catch (Exception e) { + return false; + } + Marker marker = MarkerDto.convert2Marker(markerDto); + marker.setIsValid(1); + marker.setCompanyId(companyId); + marker.setPhotos(filePaths); + save(marker); + return true; + + } + + /** * 新增标识器 8-9 * * @param markers @@ -582,7 +630,7 @@ "所属区域","所属线路","所属道路","建设年代","权属单位","标示对象ID", "标识器ID","标识器类型","标识器埋深","安装部门","经度", "纬度", "最后修改时间","备注","下层管种类", "下层管埋深", - "下层管直径", "下层管材料", "标识对象类别"}; + "下层管直径", "下层管材料", "标识对象类别", "标识点颜色", "图片地址"}; Label[][] labels = new Label[markerDtos.size() + 1][titleTxt.length]; for(int k=0;k saveMarkerAndPhotos(@RequestParam(value = "fileBuffer1", required = false) MultipartFile fileBuffer1, + @RequestParam(value = "fileBuffer2", required = false) MultipartFile fileBuffer2, + @RequestParam(value = "fileBuffer3", required = false) MultipartFile fileBuffer3, + @RequestParam(value = "jsonMarker", required = true) String jsonMarker) { + Map map = new HashMap(); + map.put("message", "安装无标识器信息"); + Gson gson = new Gson(); + try { + MarkerDto marker = gson.fromJson(jsonMarker, MarkerDto.class); + + if (null == marker.getMarkerId()) { + map.put("message", "无标识器ID"); + map.put("success", "false"); + return map; + } else if (markerManager.getMarkerByMarkerId(marker.getMarkerId()).size() > 0) { + map.put("message", "已安装过该标识器[" + marker.getMarkerId() + "]"); + map.put("success", "false"); + return map; + } else { + String[] fileNames = new String[3]; + String[] fileBuffers = new String[3]; + if (fileBuffer1 != null) { + fileNames[0] = marker.getMarkerId() + "_" + fileBuffer1.getOriginalFilename(); + byte[] fis = fileBuffer1.getBytes(); + fileBuffers[0] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, com.sun.org.apache.xml.internal.security.utils.Base64.BASE64DEFAULTLENGTH)); + } + if (fileBuffer2 != null) { + fileNames[1] = marker.getMarkerId() + "_" + fileBuffer2.getOriginalFilename(); + byte[] fis = fileBuffer2.getBytes(); + fileBuffers[1] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, com.sun.org.apache.xml.internal.security.utils.Base64.BASE64DEFAULTLENGTH)); + } + if (fileBuffer3 != null) { + fileNames[2] = marker.getMarkerId() + "_" + fileBuffer3.getOriginalFilename(); + byte[] fis = fileBuffer3.getBytes(); + fileBuffers[2] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, Base64.BASE64DEFAULTLENGTH)); + } + Long companyId = marker.getCompanyId(); + if (companyId == null) { + return map; + } + boolean result = markerManager.saveMarkerAndPhotos(marker, companyId, fileNames, fileBuffers); + if (!result) { + return map; + } + } + } catch (Exception e) { + return map; + } + map.put("success", "true"); + map.put("message", "保存成功"); + return map; + } + + @RequestMapping("marker-info-delete") @ResponseBody public Map delete(@RequestParam(value = "id", required = true) Long id) { @@ -144,6 +208,9 @@ map.put("message", "删除需要ID信息"); return map; } + + System.out.println(ids); + markerManager.delMarkerByIds(ids); map.put("success", true); map.put("message", "删除成功"); @@ -240,6 +307,54 @@ return map; } + /** + * 批量上传标识点,用于无信号地区标识器信息统一上传,不修改已有标识点信息 + * @param strMarkers + * @return + */ + @RequestMapping("batch-save-no-update") + @ResponseBody + public Map batchSaveOrUpdate(@RequestParam(value = "markers", required = true) String strMarkers) { + strMarkers = strMarkers.replace('\n',' '); + Map map = new HashMap(); + map.put("message", "批量导入失败,或无导入标识器信息"); + Gson gson = new Gson(); + try { + List markers = gson.fromJson(strMarkers, new TypeToken>() { + }.getType()); + if (CollectionUtils.isEmpty(markers)) {//批量导入数据不存在,直接返回 + map.put("message", "批量导入数据不存在"); + return map; + } + + Long companyId = markers.get(0).getCompanyId(); + if (companyId == null) { + map.put("message", "未找到所属公司属性"); + return map; + } + + List markerDtoForSave = new ArrayList(); + for (MarkerDto markerDto : markers) { + // 上传marker的Id不为空且数据库中不存在记录,经纬度不为空,允许保存 + if (StringUtils.isNotBlank(markerDto.getMarkerId()) && markerManager.getMarkerByMarkerId(markerDto.getMarkerId()).size() <= 0) { + if (null != markerDto.getLongitude() && null != markerDto.getLatitude()) { + markerDtoForSave.add(markerDto); + } + } + } + boolean result = markerManager.batchSave(markerDtoForSave, companyId); + if (!result) { + return map; + } + } catch (Exception e) { + e.printStackTrace(); + return map; + } + map.put("success", true); + map.put("message", "保存成功"); + return map; + } + @RequestMapping("getMarkerListByCondition") @ResponseBody @POST diff --git a/src/main/java/com/casic/accessControl/user/web/UserController.java b/src/main/java/com/casic/accessControl/user/web/UserController.java index feab678..3534a97 100644 --- a/src/main/java/com/casic/accessControl/user/web/UserController.java +++ b/src/main/java/com/casic/accessControl/user/web/UserController.java @@ -46,6 +46,7 @@ @ResponseBody public Map login(@ModelAttribute User userInfo, HttpSession session) { Map result = new HashMap(); + User user = null; try{ user = userManager.login(userInfo); diff --git a/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java b/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java new file mode 100644 index 0000000..582120f --- /dev/null +++ b/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java @@ -0,0 +1,129 @@ +package com.casic.accessControl.util; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.net.URL; +import java.net.URLConnection; +import java.util.List; +import java.util.Map; + +/** + * Created by lenovo on 2016/8/31. + */ +public class HttpRequestUtils { + + /** + * 向指定URL发送GET方法的请求 + * + * @param url + * 发送请求的URL + * @param param + * 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 + * @return URL 所代表远程资源的响应结果 + */ + public static String sendGet(String url, String param) { + String result = ""; + BufferedReader in = null; + try { + String urlNameString = url + "?" + param; + URL realUrl = new URL(urlNameString); + // 打开和URL之间的连接 + URLConnection connection = realUrl.openConnection(); + // 设置通用的请求属性 + connection.setRequestProperty("accept", "*/*"); + connection.setRequestProperty("connection", "Keep-Alive"); + connection.setRequestProperty("user-agent", + "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + // 建立实际的连接 + connection.connect(); + // 获取所有响应头字段 + Map> map = connection.getHeaderFields(); + // 遍历所有的响应头字段 + for (String key : map.keySet()) { + System.out.println(key + "--->" + map.get(key)); + } + // 定义 BufferedReader输入流来读取URL的响应 + in = new BufferedReader(new InputStreamReader( + connection.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + result += line; + } + } catch (Exception e) { + System.out.println("发送GET请求出现异常!" + e); + e.printStackTrace(); + } + // 使用finally块来关闭输入流 + finally { + try { + if (in != null) { + in.close(); + } + } catch (Exception e2) { + e2.printStackTrace(); + } + } + return result; + } + + /** + * 向指定 URL 发送POST方法的请求 + * + * @param url + * 发送请求的 URL + * @param param + * 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 + * @return 所代表远程资源的响应结果 + */ + public static String sendPost(String url, String param) { + PrintWriter out = null; + BufferedReader in = null; + String result = ""; + try { + URL realUrl = new URL(url); + // 打开和URL之间的连接 + URLConnection conn = realUrl.openConnection(); + // 设置通用的请求属性 + conn.setRequestProperty("accept", "*/*"); + conn.setRequestProperty("connection", "Keep-Alive"); + conn.setRequestProperty("user-agent", + "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + // 发送POST请求必须设置如下两行 + conn.setDoOutput(true); + conn.setDoInput(true); + // 获取URLConnection对象对应的输出流 + out = new PrintWriter(conn.getOutputStream()); + // 发送请求参数 + out.print(param); + // flush输出流的缓冲 + out.flush(); + // 定义BufferedReader输入流来读取URL的响应 + in = new BufferedReader( + new InputStreamReader(conn.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + result += line; + } + } catch (Exception e) { + System.out.println("发送 POST 请求出现异常!"+e); + e.printStackTrace(); + } + //使用finally块来关闭输出流、输入流 + finally{ + try{ + if(out!=null){ + out.close(); + } + if(in!=null){ + in.close(); + } + } + catch(IOException ex){ + ex.printStackTrace(); + } + } + return result; + } + } \ No newline at end of file diff --git a/src/main/java/com/casic/accessControl/util/TimeFormat.java b/src/main/java/com/casic/accessControl/util/TimeFormat.java new file mode 100644 index 0000000..e9168d5 --- /dev/null +++ b/src/main/java/com/casic/accessControl/util/TimeFormat.java @@ -0,0 +1,148 @@ +package com.casic.accessControl.util; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +/** + * 格式化日期工具类 + * 默认模式yyyy-MM-dd HH:mm:ss + * @author Administrator + * + */ +public class TimeFormat { + + private static final String DATE_FORMAT_STRING = "yyyy-MM-dd"; + private static final String TIME_FORMAT_STRING = "HH:mm:ss"; + private static final String TIMESTAMP_FORMAT_STRING = "yyyy-MM-dd HH:mm:ss"; + + // 默认格式化格式 + private static SimpleDateFormat defaultFormat = new SimpleDateFormat(TIMESTAMP_FORMAT_STRING); + + public static void setFormatString(String pattern) { + defaultFormat.applyPattern(pattern); + } + + /** + * 默认格式化日期 + * + * @param Date date + * @return String + */ + public static String format(Date date) { + return defaultFormat.format(date); + } + + /** + * 日期格式化 + * + * @param date + * @return + */ + public static String formatDate(Date date) { + return TimeFormat.format(date, DATE_FORMAT_STRING); + } + + /** + * 时间格式化 + * + * @param date + * @return + */ + public static String formatTime(Date date) { + return TimeFormat.format(date, TIME_FORMAT_STRING); + } + + /** + * 时间戳格式化 + * + * @param date + * @return + */ + public static String formatTimestamp(Date date) { + return TimeFormat.format(date, TIMESTAMP_FORMAT_STRING); + } + + /** + * 以指定模式格式化日期 + * + * @param Date date + * @param String pattern + * @return String + */ + public static String format(Date date, String pattern) { + SimpleDateFormat formatter = new SimpleDateFormat(pattern); + return formatter.format(date); + } + + /** + * 根据起止日期生成日期序列 + * 包括start和end的日期 + * + * @param start + * @param end + * @return + */ + public static List generateDates(String start, String end) throws ParseException { + List dates = new ArrayList(); + Calendar s = Calendar.getInstance(); + Calendar e = Calendar.getInstance(); + s.setTime(TimeFormat.parse(start, DATE_FORMAT_STRING)); + s.set(Calendar.HOUR_OF_DAY, 0); + s.set(Calendar.MINUTE, 0); + s.set(Calendar.SECOND, 0); + e.setTime(TimeFormat.parse(end, DATE_FORMAT_STRING)); + e.set(Calendar.HOUR_OF_DAY, 0); + e.set(Calendar.MINUTE, 0); + e.set(Calendar.SECOND, 0); + while (s.before(e) == true) { + dates.add(TimeFormat.formatDate(s.getTime())); + s.add(Calendar.DATE, 1); + } + + dates.add(end); + return dates; + } + + + /** + * 解析日期字符串 + * + * @param String source + * @return Date + * + * @throws ParseException + */ + public static Date parse(String source) throws ParseException { + return defaultFormat.parse(source); + } + + /** + * 以指定模式解析日期 + * + * @param String source + * @param String pattern + * @return Date + * + * @throws ParseException + */ + public static Date parse(String source, String pattern) throws ParseException { + SimpleDateFormat formatter = new SimpleDateFormat(pattern); + return formatter.parse(source); + } + + + public static Date parseDateWithoutTime(String source) throws ParseException { + SimpleDateFormat formatter = new SimpleDateFormat(DATE_FORMAT_STRING); + Calendar date = Calendar.getInstance(); + date.setTime(formatter.parse(source)); + date.set(Calendar.HOUR, 0); + date.set(Calendar.HOUR, 0); + date.set(Calendar.MINUTE, 0); + return date.getTime(); + } + +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 53c91ea..cea976f 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -15,19 +15,17 @@ # ============================================================================ # db # ============================================================================ -#db.default.driverClassName=oracle.jdbc.driver.OracleDriver -#db.default.url=jdbc:oracle:thin:@192.168.0.203:1521:SZHTDB2 -#db.default.username=scott -#db.default.password=SZHTDB2 db.default.driverClassName=com.mysql.jdbc.Driver -db.default.url=jdbc:mysql://127.0.0.1:3306/ems?useUnicode=true&characterEncoding=UTF-8 -db.default.username=emsweb -db.default.password=emsweb +db.default.url=jdbc:mysql://127.0.0.1:3306/ems_tong?useUnicode=true&characterEncoding=UTF-8 +db.default.username=root +db.default.password=root +#db.default.username=emsweb +#db.default.password=emsweb #db.default.url=jdbc:mysql://119.254.110.71:3307/ems?useUnicode=true&characterEncoding=UTF-8 #db.default.username=root #db.default.password=rootems - -# ============================================================================ +# +## ============================================================================ # log4jdbc # ============================================================================ log4jdbc.enable=true diff --git a/src/main/resources/spring/applicationContext-filter.xml b/src/main/resources/spring/applicationContext-filter.xml index a08c5fc..98ac7d6 100644 --- a/src/main/resources/spring/applicationContext-filter.xml +++ b/src/main/resources/spring/applicationContext-filter.xml @@ -35,9 +35,13 @@ /user/ill-login.do /marker/exportMarker.do /marker/batchSave-na.do + /marker/batch-save-no-update.do + /marker/save-marker-photo.do /event/save-event.do /task/get-task.do + /app/get-latest-version.do /xls/* + /apk/* diff --git a/src/main/resources/spring/applicationContext-hibernate.xml b/src/main/resources/spring/applicationContext-hibernate.xml index 5bb1a7e..dc54192 100644 --- a/src/main/resources/spring/applicationContext-hibernate.xml +++ b/src/main/resources/spring/applicationContext-hibernate.xml @@ -65,6 +65,7 @@ com.casic.accessControl.task.domain.Position com.casic.accessControl.event.domain.Event com.casic.accessControl.marker.domain.OptionItem + com.casic.accessControl.app.domain.ApkVersion diff --git a/src/main/webapp/common/layout/menu_new.jsp b/src/main/webapp/common/layout/menu_new.jsp index 3cf4b4e..cbd822e 100644 --- a/src/main/webapp/common/layout/menu_new.jsp +++ b/src/main/webapp/common/layout/menu_new.jsp @@ -20,7 +20,7 @@
          • - + @@ -54,7 +54,7 @@
          • - + diff --git a/src/main/webapp/content/ems/ems-gd.jsp b/src/main/webapp/content/ems/ems-gd.jsp new file mode 100644 index 0000000..5137b49 --- /dev/null +++ b/src/main/webapp/content/ems/ems-gd.jsp @@ -0,0 +1,604 @@ +<%@page contentType="text/html;charset=UTF-8" %> + +<%@include file="/taglibs.jsp" %> + +<%pageContext.setAttribute("currentMenu", "ems");%> + + + + + + + + + + + + + 地下管线电子标识系统 + + + + + + + + + + + + + + + + + + +<%-- + +--%> + + + + + + + + + + + + + + +<%@include file="/common/layout/header.jsp" %> + +
            + + + + <%@include file="/common/layout/menu_new.jsp" %> + + + +
            + + + +
            + +
            + + +
            +
            +
            +
            + +
            +
            + +
            +
            + +
            +
            + +
            +
            + +
            + +
            + +
            + +
            + +
            + +
            +
            +
            + + + + +
            +
            +
            +
            + + + + +
            +
            +
            + +
            + +
            + +<%--todo list:错误使用方法 + +--%> +
            + +
            +
            + +
            + +
            + +
            + + +
            + +
            + + 移动 + 绘制区域 + 新增标识器 + 删除标识器 + 保存标识器 + 批量导入 + 导出Excel + 清空 + +
            + +
            +
            + +
            + + + +
            + +
            + +
            + + + + +
            + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/webapp/content/task/task-gd.jsp b/src/main/webapp/content/task/task-gd.jsp new file mode 100644 index 0000000..d2d5549 --- /dev/null +++ b/src/main/webapp/content/task/task-gd.jsp @@ -0,0 +1,374 @@ +<%@page contentType="text/html;charset=UTF-8" %> + +<%@include file="/taglibs.jsp" %> + +<%pageContext.setAttribute("currentMenu", "task");%> + + + + + + + + + + + + + 地下管线电子标识系统 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +<%@include file="/common/layout/header.jsp" %> + +
            + + + + <%@include file="/common/layout/menu_new.jsp" %> + + + +
            + + + +
            + +
            + +
            + + 移动 + 绘制区域 + 选择多点创建工单 + 清空选择 + +
            + +
            + +
            + + +
            + +
            + +
            + +
            历史工单
            + +
            + +
            + +
            + <%--巡检员:--%> +
            +
            + + +
            +
            + + +
              +
            +
              +
              + +
              + +
              + +
              + +
              +
              + +
              + + + +
              + +
              + +
              + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/webapp/images/drop/0.png b/src/main/webapp/images/drop/0.png new file mode 100644 index 0000000..f4b966b --- /dev/null +++ b/src/main/webapp/images/drop/0.png Binary files differ diff --git a/src/main/webapp/images/drop/1.png b/src/main/webapp/images/drop/1.png new file mode 100644 index 0000000..9284b64 --- /dev/null +++ b/src/main/webapp/images/drop/1.png Binary files differ diff --git a/src/main/webapp/images/drop/2.png b/src/main/webapp/images/drop/2.png new file mode 100644 index 0000000..b5425db --- /dev/null +++ b/src/main/webapp/images/drop/2.png Binary files differ diff --git a/src/main/webapp/images/drop/3.png b/src/main/webapp/images/drop/3.png new file mode 100644 index 0000000..dd09655 --- /dev/null +++ b/src/main/webapp/images/drop/3.png Binary files differ diff --git a/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java new file mode 100644 index 0000000..634ceae --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java @@ -0,0 +1,46 @@ +package com.casic.accessControl.app.domain; + +import javax.persistence.*; +import java.util.Date; + +/** + * app的版本信息 + */ +//工单 +@Entity +@Table(name = "apkVersion") +public class ApkVersion { + private String version; + private String path; + private Date ts;//时间戳 + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "version") + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + @Column(name = "path") + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + @Column(name = "ts") + public Date getTs() { + return ts; + } + + public void setTs(Date ts) { + this.ts = ts; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java new file mode 100644 index 0000000..1d0242a --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java @@ -0,0 +1,50 @@ +package com.casic.accessControl.app.dto; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.util.TimeFormat; + +/** + * Created by lenovo on 2016/4/13. + */ +public class ApkVersionDto { + private String version; + private String path; + private String ts; + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public String getTs() { + return ts; + } + + public void setTs(String ts) { + this.ts = ts; + } + + public static ApkVersionDto Convert(ApkVersion version) { + if (version == null) { + return null; + } + ApkVersionDto versionDto = new ApkVersionDto(); + versionDto.setVersion(version.getVersion()); + versionDto.setPath(version.getVersion()); + versionDto.setTs(TimeFormat.formatTimestamp(version.getTs())); + + return versionDto; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java b/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java new file mode 100644 index 0000000..28b12a7 --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java @@ -0,0 +1,27 @@ +package com.casic.accessControl.app.manager; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.core.hibernate.HibernateEntityDao; +import org.hibernate.Query; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * + */ +@Service("apkVersionManager") +public class ApkVersionManager extends HibernateEntityDao { + + public ApkVersion getLatestVersion() { + String sql = "from ApkVersion order by ts desc"; + Query query = getSession().createQuery(sql); + List list = query.list(); + if (null != list && list.isEmpty() == false) { + return list.get(0); + } + + return null; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java b/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java new file mode 100644 index 0000000..065d3cc --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java @@ -0,0 +1,66 @@ +package com.casic.accessControl.app.web; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.app.manager.ApkVersionManager; +import com.casic.accessControl.marker.domain.Marker; +import com.casic.accessControl.marker.manager.MarkerManager; +import com.casic.accessControl.task.domain.Task; +import com.casic.accessControl.task.domain.TaskDetail; +import com.casic.accessControl.task.dto.TaskDetailDto; +import com.casic.accessControl.task.dto.TaskDto; +import com.casic.accessControl.task.dto.TaskStatus; +import com.casic.accessControl.task.manager.TaskDetailManager; +import com.casic.accessControl.task.manager.TaskManager; +import com.casic.accessControl.user.domain.Company; +import com.casic.accessControl.user.domain.Role; +import com.casic.accessControl.user.domain.User; +import com.casic.accessControl.user.dto.UserDto; +import com.casic.accessControl.user.manager.RoleManager; +import com.casic.accessControl.user.manager.UserManager; +import com.casic.accessControl.util.DataTable; +import com.casic.accessControl.util.StringUtils; +import com.google.gson.Gson; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +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.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * Created by lenovo on 2016/4/13. + */ +@Controller +@RequestMapping("app") +public class ApkVersionController { + + @Resource + private ApkVersionManager apkVersionManager; + + @RequestMapping("get-latest-version") + @ResponseBody + public Map getLatestVersion(HttpServletResponse response, HttpSession session) { + Map result = new HashMap(); + try { + ApkVersion latest = apkVersionManager.getLatestVersion(); + if (null != latest) { + result.put("version", latest.getVersion()); + result.put("path", latest.getPath()); + } else { + result.put("version", "1.0.0"); + } + } catch (Exception e) { + e.printStackTrace(); + result.put("version", "1.0.0"); + } + + return result; + } + +} diff --git a/src/main/java/com/casic/accessControl/marker/domain/Marker.java b/src/main/java/com/casic/accessControl/marker/domain/Marker.java index 0575cfe..7d5b854 100644 --- a/src/main/java/com/casic/accessControl/marker/domain/Marker.java +++ b/src/main/java/com/casic/accessControl/marker/domain/Marker.java @@ -67,6 +67,10 @@ private String area; @Column(name = "line") private String line; + @Column(name = "colorType") + private String colorType; + @Column(name = "photos") + private String photos; @@ -315,4 +319,20 @@ public void setArea(String area) { this.area = area; } + + public String getColorType() { + return colorType; + } + + public void setColorType(String colorType) { + this.colorType = colorType; + } + + public String getPhotos() { + return photos; + } + + public void setPhotos(String photos) { + this.photos = photos; + } } diff --git a/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java b/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java index 506f31d..c5f8cf5 100644 --- a/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java +++ b/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java @@ -2,12 +2,12 @@ //import com.casic.accessControl.feature.domain.Feature; import com.casic.accessControl.marker.domain.Marker; +import com.casic.accessControl.util.StringUtils; +import com.casic.accessControl.util.TimeFormat; import org.apache.commons.collections.CollectionUtils; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.List; +import java.text.ParseException; +import java.util.*; /** * Created by lenovo on 2016/5/16. @@ -43,6 +43,8 @@ private Long userId; private String area; private String line; + private String colorType; + private String photos; private String btnEdit = "编辑"; private String btnDelete = "删除"; @@ -296,6 +298,23 @@ this.area = area; } + public String getColorType() { + if (StringUtils.isEmpty(colorType)) return "0"; + return colorType; + } + + public void setColorType(String colorType) { + this.colorType = colorType; + } + + public String getPhotos() { + return photos; + } + + public void setPhotos(String photos) { + this.photos = photos; + } + public String getLine() { return line; } @@ -335,6 +354,52 @@ result.setRoad(doNullChange(marker.getRoad())); result.setArea(doNullChange(marker.getArea())); result.setLine(doNullChange(marker.getLine())); + result.setColorType(marker.getColorType()); + result.setPhotos(marker.getPhotos()); + return result; + } + + public static Marker convert2Marker(MarkerDto markerDto) { + if (markerDto == null) return null; + Marker result = new Marker(); + if(markerDto.getLongitude()==null||markerDto.getLatitude()==null) return null; + if (null != markerDto.getCreateTime() && markerDto.getCreateTime().length() == 19) { + try { + result.setCreateTime(TimeFormat.parse(markerDto.getCreateTime(), "yyyy-MM-dd HH:mm:ss")); + } catch (ParseException pex) { + result.setCreateTime(Calendar.getInstance().getTime()); + } + } else { + result.setCreateTime(Calendar.getInstance().getTime()); + } + result.setDepth(doNullChange(markerDto.getDepth())); + result.setId(markerDto.getId()); + result.setLatitude(markerDto.getLatitude()); + result.setLongitude(markerDto.getLongitude()); + result.setMarkerId(markerDto.getMarkerId()); + result.setMarkerDepth(doNullChange(markerDto.getMarkerDepth())); + result.setMarkerObjectId(doNullChange(markerDto.getMarkerObjectId())); + result.setMarkerObjectType(doNullChange(markerDto.getMarkerObjectType())); + result.setOwnerComp(doNullChange(markerDto.getOwnerComp())); + result.setIsValid(markerDto.getIsValid()); + result.setMemo(doNullChange(markerDto.getMemo())); + result.setPipeDiameter(doNullChange(markerDto.getPipeDiameter())); + result.setPipeMaterial(doNullChange(markerDto.getPipeMaterial())); + result.setMarkerType(doNullChange(markerDto.getMarkerType())); + result.setCreator(doNullChange(markerDto.getCreator())); + + result.setLayStyle(doNullChange(markerDto.getLayStyle())); + result.setBelowDepth(doNullChange(markerDto.getBelowDepth())); + result.setBelowDiameter(doNullChange(markerDto.getBelowDiameter())); + result.setBelowMaterial(doNullChange(markerDto.getBelowMaterial())); + result.setBelowType(doNullChange(markerDto.getBelowType())); + result.setConstructTime(doNullChange(markerDto.getConstructTime())); + result.setRecordType(markerDto.getRecordType()); + result.setRoad(doNullChange(markerDto.getRoad())); + result.setArea(doNullChange(markerDto.getArea())); + result.setLine(doNullChange(markerDto.getLine())); + result.setColorType(markerDto.getColorType()); + result.setPhotos(markerDto.getPhotos()); return result; } diff --git a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java index dd0fa4b..ba5a1fb 100644 --- a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java +++ b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java @@ -9,10 +9,7 @@ import com.casic.accessControl.marker.domain.Marker; import com.casic.accessControl.user.domain.Company; import com.casic.accessControl.user.domain.User; -import com.casic.accessControl.util.DataTable; -import com.casic.accessControl.util.DataTableParameter; -import com.casic.accessControl.util.DataTableUtils; -import com.casic.accessControl.util.DateUtils; +import com.casic.accessControl.util.*; import com.google.gson.Gson; import jxl.*; import jxl.read.biff.BiffException; @@ -31,11 +28,15 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; +import sun.misc.BASE64Decoder; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.File; +import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.text.ParseException; @@ -183,6 +184,53 @@ } /** + * 保存标识器和图片信息 + * @param markerDto + * @param companyId + * @param fileNames + * @param fileBuffers + * @return + */ + public boolean saveMarkerAndPhotos(MarkerDto markerDto, Long companyId, String[] fileNames, String[] fileBuffers) { + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + String strDirPath = request.getSession().getServletContext().getRealPath(""); + FileOutputStream fos = null; + String month = TimeFormat.format(Calendar.getInstance().getTime(), "yyyyMM"); + String webPath = "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String toDir = strDirPath + "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String filePaths = ""; + try { + for (int i = 0; i < fileBuffers.length; i++) { + if (fileBuffers[i] != null && fileNames[i] != null) { +// filePaths += toDir+fileNames[i]+","; + filePaths += webPath + fileNames[i] + ","; + byte[] buffer = new BASE64Decoder().decodeBuffer(fileBuffers[i]); //对android传过来的图片字符串进行解码 + File destDir = new File(toDir); + if (!destDir.exists()) + destDir.mkdirs(); + File imageFile = new File(destDir, fileNames[i]); + fos = new FileOutputStream(imageFile); //保存图片 + fos.write(buffer); + fos.flush(); + fos.close(); + } + } + if (filePaths.endsWith(",")) { + filePaths = filePaths.substring(0, filePaths.length() - 1); + } + } catch (Exception e) { + return false; + } + Marker marker = MarkerDto.convert2Marker(markerDto); + marker.setIsValid(1); + marker.setCompanyId(companyId); + marker.setPhotos(filePaths); + save(marker); + return true; + + } + + /** * 新增标识器 8-9 * * @param markers @@ -582,7 +630,7 @@ "所属区域","所属线路","所属道路","建设年代","权属单位","标示对象ID", "标识器ID","标识器类型","标识器埋深","安装部门","经度", "纬度", "最后修改时间","备注","下层管种类", "下层管埋深", - "下层管直径", "下层管材料", "标识对象类别"}; + "下层管直径", "下层管材料", "标识对象类别", "标识点颜色", "图片地址"}; Label[][] labels = new Label[markerDtos.size() + 1][titleTxt.length]; for(int k=0;k saveMarkerAndPhotos(@RequestParam(value = "fileBuffer1", required = false) MultipartFile fileBuffer1, + @RequestParam(value = "fileBuffer2", required = false) MultipartFile fileBuffer2, + @RequestParam(value = "fileBuffer3", required = false) MultipartFile fileBuffer3, + @RequestParam(value = "jsonMarker", required = true) String jsonMarker) { + Map map = new HashMap(); + map.put("message", "安装无标识器信息"); + Gson gson = new Gson(); + try { + MarkerDto marker = gson.fromJson(jsonMarker, MarkerDto.class); + + if (null == marker.getMarkerId()) { + map.put("message", "无标识器ID"); + map.put("success", "false"); + return map; + } else if (markerManager.getMarkerByMarkerId(marker.getMarkerId()).size() > 0) { + map.put("message", "已安装过该标识器[" + marker.getMarkerId() + "]"); + map.put("success", "false"); + return map; + } else { + String[] fileNames = new String[3]; + String[] fileBuffers = new String[3]; + if (fileBuffer1 != null) { + fileNames[0] = marker.getMarkerId() + "_" + fileBuffer1.getOriginalFilename(); + byte[] fis = fileBuffer1.getBytes(); + fileBuffers[0] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, com.sun.org.apache.xml.internal.security.utils.Base64.BASE64DEFAULTLENGTH)); + } + if (fileBuffer2 != null) { + fileNames[1] = marker.getMarkerId() + "_" + fileBuffer2.getOriginalFilename(); + byte[] fis = fileBuffer2.getBytes(); + fileBuffers[1] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, com.sun.org.apache.xml.internal.security.utils.Base64.BASE64DEFAULTLENGTH)); + } + if (fileBuffer3 != null) { + fileNames[2] = marker.getMarkerId() + "_" + fileBuffer3.getOriginalFilename(); + byte[] fis = fileBuffer3.getBytes(); + fileBuffers[2] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, Base64.BASE64DEFAULTLENGTH)); + } + Long companyId = marker.getCompanyId(); + if (companyId == null) { + return map; + } + boolean result = markerManager.saveMarkerAndPhotos(marker, companyId, fileNames, fileBuffers); + if (!result) { + return map; + } + } + } catch (Exception e) { + return map; + } + map.put("success", "true"); + map.put("message", "保存成功"); + return map; + } + + @RequestMapping("marker-info-delete") @ResponseBody public Map delete(@RequestParam(value = "id", required = true) Long id) { @@ -144,6 +208,9 @@ map.put("message", "删除需要ID信息"); return map; } + + System.out.println(ids); + markerManager.delMarkerByIds(ids); map.put("success", true); map.put("message", "删除成功"); @@ -240,6 +307,54 @@ return map; } + /** + * 批量上传标识点,用于无信号地区标识器信息统一上传,不修改已有标识点信息 + * @param strMarkers + * @return + */ + @RequestMapping("batch-save-no-update") + @ResponseBody + public Map batchSaveOrUpdate(@RequestParam(value = "markers", required = true) String strMarkers) { + strMarkers = strMarkers.replace('\n',' '); + Map map = new HashMap(); + map.put("message", "批量导入失败,或无导入标识器信息"); + Gson gson = new Gson(); + try { + List markers = gson.fromJson(strMarkers, new TypeToken>() { + }.getType()); + if (CollectionUtils.isEmpty(markers)) {//批量导入数据不存在,直接返回 + map.put("message", "批量导入数据不存在"); + return map; + } + + Long companyId = markers.get(0).getCompanyId(); + if (companyId == null) { + map.put("message", "未找到所属公司属性"); + return map; + } + + List markerDtoForSave = new ArrayList(); + for (MarkerDto markerDto : markers) { + // 上传marker的Id不为空且数据库中不存在记录,经纬度不为空,允许保存 + if (StringUtils.isNotBlank(markerDto.getMarkerId()) && markerManager.getMarkerByMarkerId(markerDto.getMarkerId()).size() <= 0) { + if (null != markerDto.getLongitude() && null != markerDto.getLatitude()) { + markerDtoForSave.add(markerDto); + } + } + } + boolean result = markerManager.batchSave(markerDtoForSave, companyId); + if (!result) { + return map; + } + } catch (Exception e) { + e.printStackTrace(); + return map; + } + map.put("success", true); + map.put("message", "保存成功"); + return map; + } + @RequestMapping("getMarkerListByCondition") @ResponseBody @POST diff --git a/src/main/java/com/casic/accessControl/user/web/UserController.java b/src/main/java/com/casic/accessControl/user/web/UserController.java index feab678..3534a97 100644 --- a/src/main/java/com/casic/accessControl/user/web/UserController.java +++ b/src/main/java/com/casic/accessControl/user/web/UserController.java @@ -46,6 +46,7 @@ @ResponseBody public Map login(@ModelAttribute User userInfo, HttpSession session) { Map result = new HashMap(); + User user = null; try{ user = userManager.login(userInfo); diff --git a/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java b/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java new file mode 100644 index 0000000..582120f --- /dev/null +++ b/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java @@ -0,0 +1,129 @@ +package com.casic.accessControl.util; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.net.URL; +import java.net.URLConnection; +import java.util.List; +import java.util.Map; + +/** + * Created by lenovo on 2016/8/31. + */ +public class HttpRequestUtils { + + /** + * 向指定URL发送GET方法的请求 + * + * @param url + * 发送请求的URL + * @param param + * 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 + * @return URL 所代表远程资源的响应结果 + */ + public static String sendGet(String url, String param) { + String result = ""; + BufferedReader in = null; + try { + String urlNameString = url + "?" + param; + URL realUrl = new URL(urlNameString); + // 打开和URL之间的连接 + URLConnection connection = realUrl.openConnection(); + // 设置通用的请求属性 + connection.setRequestProperty("accept", "*/*"); + connection.setRequestProperty("connection", "Keep-Alive"); + connection.setRequestProperty("user-agent", + "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + // 建立实际的连接 + connection.connect(); + // 获取所有响应头字段 + Map> map = connection.getHeaderFields(); + // 遍历所有的响应头字段 + for (String key : map.keySet()) { + System.out.println(key + "--->" + map.get(key)); + } + // 定义 BufferedReader输入流来读取URL的响应 + in = new BufferedReader(new InputStreamReader( + connection.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + result += line; + } + } catch (Exception e) { + System.out.println("发送GET请求出现异常!" + e); + e.printStackTrace(); + } + // 使用finally块来关闭输入流 + finally { + try { + if (in != null) { + in.close(); + } + } catch (Exception e2) { + e2.printStackTrace(); + } + } + return result; + } + + /** + * 向指定 URL 发送POST方法的请求 + * + * @param url + * 发送请求的 URL + * @param param + * 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 + * @return 所代表远程资源的响应结果 + */ + public static String sendPost(String url, String param) { + PrintWriter out = null; + BufferedReader in = null; + String result = ""; + try { + URL realUrl = new URL(url); + // 打开和URL之间的连接 + URLConnection conn = realUrl.openConnection(); + // 设置通用的请求属性 + conn.setRequestProperty("accept", "*/*"); + conn.setRequestProperty("connection", "Keep-Alive"); + conn.setRequestProperty("user-agent", + "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + // 发送POST请求必须设置如下两行 + conn.setDoOutput(true); + conn.setDoInput(true); + // 获取URLConnection对象对应的输出流 + out = new PrintWriter(conn.getOutputStream()); + // 发送请求参数 + out.print(param); + // flush输出流的缓冲 + out.flush(); + // 定义BufferedReader输入流来读取URL的响应 + in = new BufferedReader( + new InputStreamReader(conn.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + result += line; + } + } catch (Exception e) { + System.out.println("发送 POST 请求出现异常!"+e); + e.printStackTrace(); + } + //使用finally块来关闭输出流、输入流 + finally{ + try{ + if(out!=null){ + out.close(); + } + if(in!=null){ + in.close(); + } + } + catch(IOException ex){ + ex.printStackTrace(); + } + } + return result; + } + } \ No newline at end of file diff --git a/src/main/java/com/casic/accessControl/util/TimeFormat.java b/src/main/java/com/casic/accessControl/util/TimeFormat.java new file mode 100644 index 0000000..e9168d5 --- /dev/null +++ b/src/main/java/com/casic/accessControl/util/TimeFormat.java @@ -0,0 +1,148 @@ +package com.casic.accessControl.util; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +/** + * 格式化日期工具类 + * 默认模式yyyy-MM-dd HH:mm:ss + * @author Administrator + * + */ +public class TimeFormat { + + private static final String DATE_FORMAT_STRING = "yyyy-MM-dd"; + private static final String TIME_FORMAT_STRING = "HH:mm:ss"; + private static final String TIMESTAMP_FORMAT_STRING = "yyyy-MM-dd HH:mm:ss"; + + // 默认格式化格式 + private static SimpleDateFormat defaultFormat = new SimpleDateFormat(TIMESTAMP_FORMAT_STRING); + + public static void setFormatString(String pattern) { + defaultFormat.applyPattern(pattern); + } + + /** + * 默认格式化日期 + * + * @param Date date + * @return String + */ + public static String format(Date date) { + return defaultFormat.format(date); + } + + /** + * 日期格式化 + * + * @param date + * @return + */ + public static String formatDate(Date date) { + return TimeFormat.format(date, DATE_FORMAT_STRING); + } + + /** + * 时间格式化 + * + * @param date + * @return + */ + public static String formatTime(Date date) { + return TimeFormat.format(date, TIME_FORMAT_STRING); + } + + /** + * 时间戳格式化 + * + * @param date + * @return + */ + public static String formatTimestamp(Date date) { + return TimeFormat.format(date, TIMESTAMP_FORMAT_STRING); + } + + /** + * 以指定模式格式化日期 + * + * @param Date date + * @param String pattern + * @return String + */ + public static String format(Date date, String pattern) { + SimpleDateFormat formatter = new SimpleDateFormat(pattern); + return formatter.format(date); + } + + /** + * 根据起止日期生成日期序列 + * 包括start和end的日期 + * + * @param start + * @param end + * @return + */ + public static List generateDates(String start, String end) throws ParseException { + List dates = new ArrayList(); + Calendar s = Calendar.getInstance(); + Calendar e = Calendar.getInstance(); + s.setTime(TimeFormat.parse(start, DATE_FORMAT_STRING)); + s.set(Calendar.HOUR_OF_DAY, 0); + s.set(Calendar.MINUTE, 0); + s.set(Calendar.SECOND, 0); + e.setTime(TimeFormat.parse(end, DATE_FORMAT_STRING)); + e.set(Calendar.HOUR_OF_DAY, 0); + e.set(Calendar.MINUTE, 0); + e.set(Calendar.SECOND, 0); + while (s.before(e) == true) { + dates.add(TimeFormat.formatDate(s.getTime())); + s.add(Calendar.DATE, 1); + } + + dates.add(end); + return dates; + } + + + /** + * 解析日期字符串 + * + * @param String source + * @return Date + * + * @throws ParseException + */ + public static Date parse(String source) throws ParseException { + return defaultFormat.parse(source); + } + + /** + * 以指定模式解析日期 + * + * @param String source + * @param String pattern + * @return Date + * + * @throws ParseException + */ + public static Date parse(String source, String pattern) throws ParseException { + SimpleDateFormat formatter = new SimpleDateFormat(pattern); + return formatter.parse(source); + } + + + public static Date parseDateWithoutTime(String source) throws ParseException { + SimpleDateFormat formatter = new SimpleDateFormat(DATE_FORMAT_STRING); + Calendar date = Calendar.getInstance(); + date.setTime(formatter.parse(source)); + date.set(Calendar.HOUR, 0); + date.set(Calendar.HOUR, 0); + date.set(Calendar.MINUTE, 0); + return date.getTime(); + } + +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 53c91ea..cea976f 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -15,19 +15,17 @@ # ============================================================================ # db # ============================================================================ -#db.default.driverClassName=oracle.jdbc.driver.OracleDriver -#db.default.url=jdbc:oracle:thin:@192.168.0.203:1521:SZHTDB2 -#db.default.username=scott -#db.default.password=SZHTDB2 db.default.driverClassName=com.mysql.jdbc.Driver -db.default.url=jdbc:mysql://127.0.0.1:3306/ems?useUnicode=true&characterEncoding=UTF-8 -db.default.username=emsweb -db.default.password=emsweb +db.default.url=jdbc:mysql://127.0.0.1:3306/ems_tong?useUnicode=true&characterEncoding=UTF-8 +db.default.username=root +db.default.password=root +#db.default.username=emsweb +#db.default.password=emsweb #db.default.url=jdbc:mysql://119.254.110.71:3307/ems?useUnicode=true&characterEncoding=UTF-8 #db.default.username=root #db.default.password=rootems - -# ============================================================================ +# +## ============================================================================ # log4jdbc # ============================================================================ log4jdbc.enable=true diff --git a/src/main/resources/spring/applicationContext-filter.xml b/src/main/resources/spring/applicationContext-filter.xml index a08c5fc..98ac7d6 100644 --- a/src/main/resources/spring/applicationContext-filter.xml +++ b/src/main/resources/spring/applicationContext-filter.xml @@ -35,9 +35,13 @@ /user/ill-login.do /marker/exportMarker.do /marker/batchSave-na.do + /marker/batch-save-no-update.do + /marker/save-marker-photo.do /event/save-event.do /task/get-task.do + /app/get-latest-version.do /xls/* + /apk/* diff --git a/src/main/resources/spring/applicationContext-hibernate.xml b/src/main/resources/spring/applicationContext-hibernate.xml index 5bb1a7e..dc54192 100644 --- a/src/main/resources/spring/applicationContext-hibernate.xml +++ b/src/main/resources/spring/applicationContext-hibernate.xml @@ -65,6 +65,7 @@ com.casic.accessControl.task.domain.Position com.casic.accessControl.event.domain.Event com.casic.accessControl.marker.domain.OptionItem + com.casic.accessControl.app.domain.ApkVersion diff --git a/src/main/webapp/common/layout/menu_new.jsp b/src/main/webapp/common/layout/menu_new.jsp index 3cf4b4e..cbd822e 100644 --- a/src/main/webapp/common/layout/menu_new.jsp +++ b/src/main/webapp/common/layout/menu_new.jsp @@ -20,7 +20,7 @@
            • - + @@ -54,7 +54,7 @@
            • - + diff --git a/src/main/webapp/content/ems/ems-gd.jsp b/src/main/webapp/content/ems/ems-gd.jsp new file mode 100644 index 0000000..5137b49 --- /dev/null +++ b/src/main/webapp/content/ems/ems-gd.jsp @@ -0,0 +1,604 @@ +<%@page contentType="text/html;charset=UTF-8" %> + +<%@include file="/taglibs.jsp" %> + +<%pageContext.setAttribute("currentMenu", "ems");%> + + + + + + + + + + + + + 地下管线电子标识系统 + + + + + + + + + + + + + + + + + + +<%-- + +--%> + + + + + + + + + + + + + + +<%@include file="/common/layout/header.jsp" %> + +
              + + + + <%@include file="/common/layout/menu_new.jsp" %> + + + +
              + + + +
              + +
              + + +
              +
              +
              +
              + +
              +
              + +
              +
              + +
              +
              + +
              +
              + +
              + +
              + +
              + +
              + +
              + +
              +
              +
              + + + + +
              +
              +
              +
              + + + + +
              +
              +
              + +
              + +
              + +<%--todo list:错误使用方法 + +--%> +
              + +
              +
              + +
              + +
              + +
              + + +
              + +
              + + 移动 + 绘制区域 + 新增标识器 + 删除标识器 + 保存标识器 + 批量导入 + 导出Excel + 清空 + +
              + +
              +
              + +
              + + + +
              + +
              + +
              + + + + +
              + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/webapp/content/task/task-gd.jsp b/src/main/webapp/content/task/task-gd.jsp new file mode 100644 index 0000000..d2d5549 --- /dev/null +++ b/src/main/webapp/content/task/task-gd.jsp @@ -0,0 +1,374 @@ +<%@page contentType="text/html;charset=UTF-8" %> + +<%@include file="/taglibs.jsp" %> + +<%pageContext.setAttribute("currentMenu", "task");%> + + + + + + + + + + + + + 地下管线电子标识系统 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +<%@include file="/common/layout/header.jsp" %> + +
              + + + + <%@include file="/common/layout/menu_new.jsp" %> + + + +
              + + + +
              + +
              + +
              + + 移动 + 绘制区域 + 选择多点创建工单 + 清空选择 + +
              + +
              + +
              + + +
              + +
              + +
              + +
              历史工单
              + +
              + +
              + +
              + <%--巡检员:--%> +
              +
              + + +
              +
              + + +
                +
              +
                +
                + +
                + +
                + +
                + +
                +
                + +
                + + + +
                + +
                + +
                + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/webapp/images/drop/0.png b/src/main/webapp/images/drop/0.png new file mode 100644 index 0000000..f4b966b --- /dev/null +++ b/src/main/webapp/images/drop/0.png Binary files differ diff --git a/src/main/webapp/images/drop/1.png b/src/main/webapp/images/drop/1.png new file mode 100644 index 0000000..9284b64 --- /dev/null +++ b/src/main/webapp/images/drop/1.png Binary files differ diff --git a/src/main/webapp/images/drop/2.png b/src/main/webapp/images/drop/2.png new file mode 100644 index 0000000..b5425db --- /dev/null +++ b/src/main/webapp/images/drop/2.png Binary files differ diff --git a/src/main/webapp/images/drop/3.png b/src/main/webapp/images/drop/3.png new file mode 100644 index 0000000..dd09655 --- /dev/null +++ b/src/main/webapp/images/drop/3.png Binary files differ diff --git a/src/main/webapp/images/drop/4.png b/src/main/webapp/images/drop/4.png new file mode 100644 index 0000000..50cf1f7 --- /dev/null +++ b/src/main/webapp/images/drop/4.png Binary files differ diff --git a/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java new file mode 100644 index 0000000..634ceae --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java @@ -0,0 +1,46 @@ +package com.casic.accessControl.app.domain; + +import javax.persistence.*; +import java.util.Date; + +/** + * app的版本信息 + */ +//工单 +@Entity +@Table(name = "apkVersion") +public class ApkVersion { + private String version; + private String path; + private Date ts;//时间戳 + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "version") + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + @Column(name = "path") + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + @Column(name = "ts") + public Date getTs() { + return ts; + } + + public void setTs(Date ts) { + this.ts = ts; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java new file mode 100644 index 0000000..1d0242a --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java @@ -0,0 +1,50 @@ +package com.casic.accessControl.app.dto; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.util.TimeFormat; + +/** + * Created by lenovo on 2016/4/13. + */ +public class ApkVersionDto { + private String version; + private String path; + private String ts; + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public String getTs() { + return ts; + } + + public void setTs(String ts) { + this.ts = ts; + } + + public static ApkVersionDto Convert(ApkVersion version) { + if (version == null) { + return null; + } + ApkVersionDto versionDto = new ApkVersionDto(); + versionDto.setVersion(version.getVersion()); + versionDto.setPath(version.getVersion()); + versionDto.setTs(TimeFormat.formatTimestamp(version.getTs())); + + return versionDto; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java b/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java new file mode 100644 index 0000000..28b12a7 --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java @@ -0,0 +1,27 @@ +package com.casic.accessControl.app.manager; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.core.hibernate.HibernateEntityDao; +import org.hibernate.Query; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * + */ +@Service("apkVersionManager") +public class ApkVersionManager extends HibernateEntityDao { + + public ApkVersion getLatestVersion() { + String sql = "from ApkVersion order by ts desc"; + Query query = getSession().createQuery(sql); + List list = query.list(); + if (null != list && list.isEmpty() == false) { + return list.get(0); + } + + return null; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java b/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java new file mode 100644 index 0000000..065d3cc --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java @@ -0,0 +1,66 @@ +package com.casic.accessControl.app.web; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.app.manager.ApkVersionManager; +import com.casic.accessControl.marker.domain.Marker; +import com.casic.accessControl.marker.manager.MarkerManager; +import com.casic.accessControl.task.domain.Task; +import com.casic.accessControl.task.domain.TaskDetail; +import com.casic.accessControl.task.dto.TaskDetailDto; +import com.casic.accessControl.task.dto.TaskDto; +import com.casic.accessControl.task.dto.TaskStatus; +import com.casic.accessControl.task.manager.TaskDetailManager; +import com.casic.accessControl.task.manager.TaskManager; +import com.casic.accessControl.user.domain.Company; +import com.casic.accessControl.user.domain.Role; +import com.casic.accessControl.user.domain.User; +import com.casic.accessControl.user.dto.UserDto; +import com.casic.accessControl.user.manager.RoleManager; +import com.casic.accessControl.user.manager.UserManager; +import com.casic.accessControl.util.DataTable; +import com.casic.accessControl.util.StringUtils; +import com.google.gson.Gson; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +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.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * Created by lenovo on 2016/4/13. + */ +@Controller +@RequestMapping("app") +public class ApkVersionController { + + @Resource + private ApkVersionManager apkVersionManager; + + @RequestMapping("get-latest-version") + @ResponseBody + public Map getLatestVersion(HttpServletResponse response, HttpSession session) { + Map result = new HashMap(); + try { + ApkVersion latest = apkVersionManager.getLatestVersion(); + if (null != latest) { + result.put("version", latest.getVersion()); + result.put("path", latest.getPath()); + } else { + result.put("version", "1.0.0"); + } + } catch (Exception e) { + e.printStackTrace(); + result.put("version", "1.0.0"); + } + + return result; + } + +} diff --git a/src/main/java/com/casic/accessControl/marker/domain/Marker.java b/src/main/java/com/casic/accessControl/marker/domain/Marker.java index 0575cfe..7d5b854 100644 --- a/src/main/java/com/casic/accessControl/marker/domain/Marker.java +++ b/src/main/java/com/casic/accessControl/marker/domain/Marker.java @@ -67,6 +67,10 @@ private String area; @Column(name = "line") private String line; + @Column(name = "colorType") + private String colorType; + @Column(name = "photos") + private String photos; @@ -315,4 +319,20 @@ public void setArea(String area) { this.area = area; } + + public String getColorType() { + return colorType; + } + + public void setColorType(String colorType) { + this.colorType = colorType; + } + + public String getPhotos() { + return photos; + } + + public void setPhotos(String photos) { + this.photos = photos; + } } diff --git a/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java b/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java index 506f31d..c5f8cf5 100644 --- a/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java +++ b/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java @@ -2,12 +2,12 @@ //import com.casic.accessControl.feature.domain.Feature; import com.casic.accessControl.marker.domain.Marker; +import com.casic.accessControl.util.StringUtils; +import com.casic.accessControl.util.TimeFormat; import org.apache.commons.collections.CollectionUtils; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.List; +import java.text.ParseException; +import java.util.*; /** * Created by lenovo on 2016/5/16. @@ -43,6 +43,8 @@ private Long userId; private String area; private String line; + private String colorType; + private String photos; private String btnEdit = "编辑"; private String btnDelete = "删除"; @@ -296,6 +298,23 @@ this.area = area; } + public String getColorType() { + if (StringUtils.isEmpty(colorType)) return "0"; + return colorType; + } + + public void setColorType(String colorType) { + this.colorType = colorType; + } + + public String getPhotos() { + return photos; + } + + public void setPhotos(String photos) { + this.photos = photos; + } + public String getLine() { return line; } @@ -335,6 +354,52 @@ result.setRoad(doNullChange(marker.getRoad())); result.setArea(doNullChange(marker.getArea())); result.setLine(doNullChange(marker.getLine())); + result.setColorType(marker.getColorType()); + result.setPhotos(marker.getPhotos()); + return result; + } + + public static Marker convert2Marker(MarkerDto markerDto) { + if (markerDto == null) return null; + Marker result = new Marker(); + if(markerDto.getLongitude()==null||markerDto.getLatitude()==null) return null; + if (null != markerDto.getCreateTime() && markerDto.getCreateTime().length() == 19) { + try { + result.setCreateTime(TimeFormat.parse(markerDto.getCreateTime(), "yyyy-MM-dd HH:mm:ss")); + } catch (ParseException pex) { + result.setCreateTime(Calendar.getInstance().getTime()); + } + } else { + result.setCreateTime(Calendar.getInstance().getTime()); + } + result.setDepth(doNullChange(markerDto.getDepth())); + result.setId(markerDto.getId()); + result.setLatitude(markerDto.getLatitude()); + result.setLongitude(markerDto.getLongitude()); + result.setMarkerId(markerDto.getMarkerId()); + result.setMarkerDepth(doNullChange(markerDto.getMarkerDepth())); + result.setMarkerObjectId(doNullChange(markerDto.getMarkerObjectId())); + result.setMarkerObjectType(doNullChange(markerDto.getMarkerObjectType())); + result.setOwnerComp(doNullChange(markerDto.getOwnerComp())); + result.setIsValid(markerDto.getIsValid()); + result.setMemo(doNullChange(markerDto.getMemo())); + result.setPipeDiameter(doNullChange(markerDto.getPipeDiameter())); + result.setPipeMaterial(doNullChange(markerDto.getPipeMaterial())); + result.setMarkerType(doNullChange(markerDto.getMarkerType())); + result.setCreator(doNullChange(markerDto.getCreator())); + + result.setLayStyle(doNullChange(markerDto.getLayStyle())); + result.setBelowDepth(doNullChange(markerDto.getBelowDepth())); + result.setBelowDiameter(doNullChange(markerDto.getBelowDiameter())); + result.setBelowMaterial(doNullChange(markerDto.getBelowMaterial())); + result.setBelowType(doNullChange(markerDto.getBelowType())); + result.setConstructTime(doNullChange(markerDto.getConstructTime())); + result.setRecordType(markerDto.getRecordType()); + result.setRoad(doNullChange(markerDto.getRoad())); + result.setArea(doNullChange(markerDto.getArea())); + result.setLine(doNullChange(markerDto.getLine())); + result.setColorType(markerDto.getColorType()); + result.setPhotos(markerDto.getPhotos()); return result; } diff --git a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java index dd0fa4b..ba5a1fb 100644 --- a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java +++ b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java @@ -9,10 +9,7 @@ import com.casic.accessControl.marker.domain.Marker; import com.casic.accessControl.user.domain.Company; import com.casic.accessControl.user.domain.User; -import com.casic.accessControl.util.DataTable; -import com.casic.accessControl.util.DataTableParameter; -import com.casic.accessControl.util.DataTableUtils; -import com.casic.accessControl.util.DateUtils; +import com.casic.accessControl.util.*; import com.google.gson.Gson; import jxl.*; import jxl.read.biff.BiffException; @@ -31,11 +28,15 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; +import sun.misc.BASE64Decoder; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.File; +import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.text.ParseException; @@ -183,6 +184,53 @@ } /** + * 保存标识器和图片信息 + * @param markerDto + * @param companyId + * @param fileNames + * @param fileBuffers + * @return + */ + public boolean saveMarkerAndPhotos(MarkerDto markerDto, Long companyId, String[] fileNames, String[] fileBuffers) { + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + String strDirPath = request.getSession().getServletContext().getRealPath(""); + FileOutputStream fos = null; + String month = TimeFormat.format(Calendar.getInstance().getTime(), "yyyyMM"); + String webPath = "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String toDir = strDirPath + "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String filePaths = ""; + try { + for (int i = 0; i < fileBuffers.length; i++) { + if (fileBuffers[i] != null && fileNames[i] != null) { +// filePaths += toDir+fileNames[i]+","; + filePaths += webPath + fileNames[i] + ","; + byte[] buffer = new BASE64Decoder().decodeBuffer(fileBuffers[i]); //对android传过来的图片字符串进行解码 + File destDir = new File(toDir); + if (!destDir.exists()) + destDir.mkdirs(); + File imageFile = new File(destDir, fileNames[i]); + fos = new FileOutputStream(imageFile); //保存图片 + fos.write(buffer); + fos.flush(); + fos.close(); + } + } + if (filePaths.endsWith(",")) { + filePaths = filePaths.substring(0, filePaths.length() - 1); + } + } catch (Exception e) { + return false; + } + Marker marker = MarkerDto.convert2Marker(markerDto); + marker.setIsValid(1); + marker.setCompanyId(companyId); + marker.setPhotos(filePaths); + save(marker); + return true; + + } + + /** * 新增标识器 8-9 * * @param markers @@ -582,7 +630,7 @@ "所属区域","所属线路","所属道路","建设年代","权属单位","标示对象ID", "标识器ID","标识器类型","标识器埋深","安装部门","经度", "纬度", "最后修改时间","备注","下层管种类", "下层管埋深", - "下层管直径", "下层管材料", "标识对象类别"}; + "下层管直径", "下层管材料", "标识对象类别", "标识点颜色", "图片地址"}; Label[][] labels = new Label[markerDtos.size() + 1][titleTxt.length]; for(int k=0;k saveMarkerAndPhotos(@RequestParam(value = "fileBuffer1", required = false) MultipartFile fileBuffer1, + @RequestParam(value = "fileBuffer2", required = false) MultipartFile fileBuffer2, + @RequestParam(value = "fileBuffer3", required = false) MultipartFile fileBuffer3, + @RequestParam(value = "jsonMarker", required = true) String jsonMarker) { + Map map = new HashMap(); + map.put("message", "安装无标识器信息"); + Gson gson = new Gson(); + try { + MarkerDto marker = gson.fromJson(jsonMarker, MarkerDto.class); + + if (null == marker.getMarkerId()) { + map.put("message", "无标识器ID"); + map.put("success", "false"); + return map; + } else if (markerManager.getMarkerByMarkerId(marker.getMarkerId()).size() > 0) { + map.put("message", "已安装过该标识器[" + marker.getMarkerId() + "]"); + map.put("success", "false"); + return map; + } else { + String[] fileNames = new String[3]; + String[] fileBuffers = new String[3]; + if (fileBuffer1 != null) { + fileNames[0] = marker.getMarkerId() + "_" + fileBuffer1.getOriginalFilename(); + byte[] fis = fileBuffer1.getBytes(); + fileBuffers[0] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, com.sun.org.apache.xml.internal.security.utils.Base64.BASE64DEFAULTLENGTH)); + } + if (fileBuffer2 != null) { + fileNames[1] = marker.getMarkerId() + "_" + fileBuffer2.getOriginalFilename(); + byte[] fis = fileBuffer2.getBytes(); + fileBuffers[1] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, com.sun.org.apache.xml.internal.security.utils.Base64.BASE64DEFAULTLENGTH)); + } + if (fileBuffer3 != null) { + fileNames[2] = marker.getMarkerId() + "_" + fileBuffer3.getOriginalFilename(); + byte[] fis = fileBuffer3.getBytes(); + fileBuffers[2] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, Base64.BASE64DEFAULTLENGTH)); + } + Long companyId = marker.getCompanyId(); + if (companyId == null) { + return map; + } + boolean result = markerManager.saveMarkerAndPhotos(marker, companyId, fileNames, fileBuffers); + if (!result) { + return map; + } + } + } catch (Exception e) { + return map; + } + map.put("success", "true"); + map.put("message", "保存成功"); + return map; + } + + @RequestMapping("marker-info-delete") @ResponseBody public Map delete(@RequestParam(value = "id", required = true) Long id) { @@ -144,6 +208,9 @@ map.put("message", "删除需要ID信息"); return map; } + + System.out.println(ids); + markerManager.delMarkerByIds(ids); map.put("success", true); map.put("message", "删除成功"); @@ -240,6 +307,54 @@ return map; } + /** + * 批量上传标识点,用于无信号地区标识器信息统一上传,不修改已有标识点信息 + * @param strMarkers + * @return + */ + @RequestMapping("batch-save-no-update") + @ResponseBody + public Map batchSaveOrUpdate(@RequestParam(value = "markers", required = true) String strMarkers) { + strMarkers = strMarkers.replace('\n',' '); + Map map = new HashMap(); + map.put("message", "批量导入失败,或无导入标识器信息"); + Gson gson = new Gson(); + try { + List markers = gson.fromJson(strMarkers, new TypeToken>() { + }.getType()); + if (CollectionUtils.isEmpty(markers)) {//批量导入数据不存在,直接返回 + map.put("message", "批量导入数据不存在"); + return map; + } + + Long companyId = markers.get(0).getCompanyId(); + if (companyId == null) { + map.put("message", "未找到所属公司属性"); + return map; + } + + List markerDtoForSave = new ArrayList(); + for (MarkerDto markerDto : markers) { + // 上传marker的Id不为空且数据库中不存在记录,经纬度不为空,允许保存 + if (StringUtils.isNotBlank(markerDto.getMarkerId()) && markerManager.getMarkerByMarkerId(markerDto.getMarkerId()).size() <= 0) { + if (null != markerDto.getLongitude() && null != markerDto.getLatitude()) { + markerDtoForSave.add(markerDto); + } + } + } + boolean result = markerManager.batchSave(markerDtoForSave, companyId); + if (!result) { + return map; + } + } catch (Exception e) { + e.printStackTrace(); + return map; + } + map.put("success", true); + map.put("message", "保存成功"); + return map; + } + @RequestMapping("getMarkerListByCondition") @ResponseBody @POST diff --git a/src/main/java/com/casic/accessControl/user/web/UserController.java b/src/main/java/com/casic/accessControl/user/web/UserController.java index feab678..3534a97 100644 --- a/src/main/java/com/casic/accessControl/user/web/UserController.java +++ b/src/main/java/com/casic/accessControl/user/web/UserController.java @@ -46,6 +46,7 @@ @ResponseBody public Map login(@ModelAttribute User userInfo, HttpSession session) { Map result = new HashMap(); + User user = null; try{ user = userManager.login(userInfo); diff --git a/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java b/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java new file mode 100644 index 0000000..582120f --- /dev/null +++ b/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java @@ -0,0 +1,129 @@ +package com.casic.accessControl.util; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.net.URL; +import java.net.URLConnection; +import java.util.List; +import java.util.Map; + +/** + * Created by lenovo on 2016/8/31. + */ +public class HttpRequestUtils { + + /** + * 向指定URL发送GET方法的请求 + * + * @param url + * 发送请求的URL + * @param param + * 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 + * @return URL 所代表远程资源的响应结果 + */ + public static String sendGet(String url, String param) { + String result = ""; + BufferedReader in = null; + try { + String urlNameString = url + "?" + param; + URL realUrl = new URL(urlNameString); + // 打开和URL之间的连接 + URLConnection connection = realUrl.openConnection(); + // 设置通用的请求属性 + connection.setRequestProperty("accept", "*/*"); + connection.setRequestProperty("connection", "Keep-Alive"); + connection.setRequestProperty("user-agent", + "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + // 建立实际的连接 + connection.connect(); + // 获取所有响应头字段 + Map> map = connection.getHeaderFields(); + // 遍历所有的响应头字段 + for (String key : map.keySet()) { + System.out.println(key + "--->" + map.get(key)); + } + // 定义 BufferedReader输入流来读取URL的响应 + in = new BufferedReader(new InputStreamReader( + connection.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + result += line; + } + } catch (Exception e) { + System.out.println("发送GET请求出现异常!" + e); + e.printStackTrace(); + } + // 使用finally块来关闭输入流 + finally { + try { + if (in != null) { + in.close(); + } + } catch (Exception e2) { + e2.printStackTrace(); + } + } + return result; + } + + /** + * 向指定 URL 发送POST方法的请求 + * + * @param url + * 发送请求的 URL + * @param param + * 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 + * @return 所代表远程资源的响应结果 + */ + public static String sendPost(String url, String param) { + PrintWriter out = null; + BufferedReader in = null; + String result = ""; + try { + URL realUrl = new URL(url); + // 打开和URL之间的连接 + URLConnection conn = realUrl.openConnection(); + // 设置通用的请求属性 + conn.setRequestProperty("accept", "*/*"); + conn.setRequestProperty("connection", "Keep-Alive"); + conn.setRequestProperty("user-agent", + "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + // 发送POST请求必须设置如下两行 + conn.setDoOutput(true); + conn.setDoInput(true); + // 获取URLConnection对象对应的输出流 + out = new PrintWriter(conn.getOutputStream()); + // 发送请求参数 + out.print(param); + // flush输出流的缓冲 + out.flush(); + // 定义BufferedReader输入流来读取URL的响应 + in = new BufferedReader( + new InputStreamReader(conn.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + result += line; + } + } catch (Exception e) { + System.out.println("发送 POST 请求出现异常!"+e); + e.printStackTrace(); + } + //使用finally块来关闭输出流、输入流 + finally{ + try{ + if(out!=null){ + out.close(); + } + if(in!=null){ + in.close(); + } + } + catch(IOException ex){ + ex.printStackTrace(); + } + } + return result; + } + } \ No newline at end of file diff --git a/src/main/java/com/casic/accessControl/util/TimeFormat.java b/src/main/java/com/casic/accessControl/util/TimeFormat.java new file mode 100644 index 0000000..e9168d5 --- /dev/null +++ b/src/main/java/com/casic/accessControl/util/TimeFormat.java @@ -0,0 +1,148 @@ +package com.casic.accessControl.util; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +/** + * 格式化日期工具类 + * 默认模式yyyy-MM-dd HH:mm:ss + * @author Administrator + * + */ +public class TimeFormat { + + private static final String DATE_FORMAT_STRING = "yyyy-MM-dd"; + private static final String TIME_FORMAT_STRING = "HH:mm:ss"; + private static final String TIMESTAMP_FORMAT_STRING = "yyyy-MM-dd HH:mm:ss"; + + // 默认格式化格式 + private static SimpleDateFormat defaultFormat = new SimpleDateFormat(TIMESTAMP_FORMAT_STRING); + + public static void setFormatString(String pattern) { + defaultFormat.applyPattern(pattern); + } + + /** + * 默认格式化日期 + * + * @param Date date + * @return String + */ + public static String format(Date date) { + return defaultFormat.format(date); + } + + /** + * 日期格式化 + * + * @param date + * @return + */ + public static String formatDate(Date date) { + return TimeFormat.format(date, DATE_FORMAT_STRING); + } + + /** + * 时间格式化 + * + * @param date + * @return + */ + public static String formatTime(Date date) { + return TimeFormat.format(date, TIME_FORMAT_STRING); + } + + /** + * 时间戳格式化 + * + * @param date + * @return + */ + public static String formatTimestamp(Date date) { + return TimeFormat.format(date, TIMESTAMP_FORMAT_STRING); + } + + /** + * 以指定模式格式化日期 + * + * @param Date date + * @param String pattern + * @return String + */ + public static String format(Date date, String pattern) { + SimpleDateFormat formatter = new SimpleDateFormat(pattern); + return formatter.format(date); + } + + /** + * 根据起止日期生成日期序列 + * 包括start和end的日期 + * + * @param start + * @param end + * @return + */ + public static List generateDates(String start, String end) throws ParseException { + List dates = new ArrayList(); + Calendar s = Calendar.getInstance(); + Calendar e = Calendar.getInstance(); + s.setTime(TimeFormat.parse(start, DATE_FORMAT_STRING)); + s.set(Calendar.HOUR_OF_DAY, 0); + s.set(Calendar.MINUTE, 0); + s.set(Calendar.SECOND, 0); + e.setTime(TimeFormat.parse(end, DATE_FORMAT_STRING)); + e.set(Calendar.HOUR_OF_DAY, 0); + e.set(Calendar.MINUTE, 0); + e.set(Calendar.SECOND, 0); + while (s.before(e) == true) { + dates.add(TimeFormat.formatDate(s.getTime())); + s.add(Calendar.DATE, 1); + } + + dates.add(end); + return dates; + } + + + /** + * 解析日期字符串 + * + * @param String source + * @return Date + * + * @throws ParseException + */ + public static Date parse(String source) throws ParseException { + return defaultFormat.parse(source); + } + + /** + * 以指定模式解析日期 + * + * @param String source + * @param String pattern + * @return Date + * + * @throws ParseException + */ + public static Date parse(String source, String pattern) throws ParseException { + SimpleDateFormat formatter = new SimpleDateFormat(pattern); + return formatter.parse(source); + } + + + public static Date parseDateWithoutTime(String source) throws ParseException { + SimpleDateFormat formatter = new SimpleDateFormat(DATE_FORMAT_STRING); + Calendar date = Calendar.getInstance(); + date.setTime(formatter.parse(source)); + date.set(Calendar.HOUR, 0); + date.set(Calendar.HOUR, 0); + date.set(Calendar.MINUTE, 0); + return date.getTime(); + } + +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 53c91ea..cea976f 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -15,19 +15,17 @@ # ============================================================================ # db # ============================================================================ -#db.default.driverClassName=oracle.jdbc.driver.OracleDriver -#db.default.url=jdbc:oracle:thin:@192.168.0.203:1521:SZHTDB2 -#db.default.username=scott -#db.default.password=SZHTDB2 db.default.driverClassName=com.mysql.jdbc.Driver -db.default.url=jdbc:mysql://127.0.0.1:3306/ems?useUnicode=true&characterEncoding=UTF-8 -db.default.username=emsweb -db.default.password=emsweb +db.default.url=jdbc:mysql://127.0.0.1:3306/ems_tong?useUnicode=true&characterEncoding=UTF-8 +db.default.username=root +db.default.password=root +#db.default.username=emsweb +#db.default.password=emsweb #db.default.url=jdbc:mysql://119.254.110.71:3307/ems?useUnicode=true&characterEncoding=UTF-8 #db.default.username=root #db.default.password=rootems - -# ============================================================================ +# +## ============================================================================ # log4jdbc # ============================================================================ log4jdbc.enable=true diff --git a/src/main/resources/spring/applicationContext-filter.xml b/src/main/resources/spring/applicationContext-filter.xml index a08c5fc..98ac7d6 100644 --- a/src/main/resources/spring/applicationContext-filter.xml +++ b/src/main/resources/spring/applicationContext-filter.xml @@ -35,9 +35,13 @@ /user/ill-login.do /marker/exportMarker.do /marker/batchSave-na.do + /marker/batch-save-no-update.do + /marker/save-marker-photo.do /event/save-event.do /task/get-task.do + /app/get-latest-version.do /xls/* + /apk/* diff --git a/src/main/resources/spring/applicationContext-hibernate.xml b/src/main/resources/spring/applicationContext-hibernate.xml index 5bb1a7e..dc54192 100644 --- a/src/main/resources/spring/applicationContext-hibernate.xml +++ b/src/main/resources/spring/applicationContext-hibernate.xml @@ -65,6 +65,7 @@ com.casic.accessControl.task.domain.Position com.casic.accessControl.event.domain.Event com.casic.accessControl.marker.domain.OptionItem + com.casic.accessControl.app.domain.ApkVersion diff --git a/src/main/webapp/common/layout/menu_new.jsp b/src/main/webapp/common/layout/menu_new.jsp index 3cf4b4e..cbd822e 100644 --- a/src/main/webapp/common/layout/menu_new.jsp +++ b/src/main/webapp/common/layout/menu_new.jsp @@ -20,7 +20,7 @@
              • - + @@ -54,7 +54,7 @@
              • - + diff --git a/src/main/webapp/content/ems/ems-gd.jsp b/src/main/webapp/content/ems/ems-gd.jsp new file mode 100644 index 0000000..5137b49 --- /dev/null +++ b/src/main/webapp/content/ems/ems-gd.jsp @@ -0,0 +1,604 @@ +<%@page contentType="text/html;charset=UTF-8" %> + +<%@include file="/taglibs.jsp" %> + +<%pageContext.setAttribute("currentMenu", "ems");%> + + + + + + + + + + + + + 地下管线电子标识系统 + + + + + + + + + + + + + + + + + + +<%-- + +--%> + + + + + + + + + + + + + + +<%@include file="/common/layout/header.jsp" %> + +
                + + + + <%@include file="/common/layout/menu_new.jsp" %> + + + +
                + + + +
                + +
                + + +
                +
                +
                +
                + +
                +
                + +
                +
                + +
                +
                + +
                +
                + +
                + +
                + +
                + +
                + +
                + +
                +
                +
                + + + + +
                +
                +
                +
                + + + + +
                +
                +
                + +
                + +
                + +<%--todo list:错误使用方法 + +--%> +
                + +
                +
                + +
                + +
                + +
                + + +
                + +
                + + 移动 + 绘制区域 + 新增标识器 + 删除标识器 + 保存标识器 + 批量导入 + 导出Excel + 清空 + +
                + +
                +
                + +
                + + + +
                + +
                + +
                + + + + +
                + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/webapp/content/task/task-gd.jsp b/src/main/webapp/content/task/task-gd.jsp new file mode 100644 index 0000000..d2d5549 --- /dev/null +++ b/src/main/webapp/content/task/task-gd.jsp @@ -0,0 +1,374 @@ +<%@page contentType="text/html;charset=UTF-8" %> + +<%@include file="/taglibs.jsp" %> + +<%pageContext.setAttribute("currentMenu", "task");%> + + + + + + + + + + + + + 地下管线电子标识系统 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +<%@include file="/common/layout/header.jsp" %> + +
                + + + + <%@include file="/common/layout/menu_new.jsp" %> + + + +
                + + + +
                + +
                + +
                + + 移动 + 绘制区域 + 选择多点创建工单 + 清空选择 + +
                + +
                + +
                + + +
                + +
                + +
                + +
                历史工单
                + +
                + +
                + +
                + <%--巡检员:--%> +
                +
                + + +
                +
                + + +
                  +
                +
                  +
                  + +
                  + +
                  + +
                  + +
                  +
                  + +
                  + + + +
                  + +
                  + +
                  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/webapp/images/drop/0.png b/src/main/webapp/images/drop/0.png new file mode 100644 index 0000000..f4b966b --- /dev/null +++ b/src/main/webapp/images/drop/0.png Binary files differ diff --git a/src/main/webapp/images/drop/1.png b/src/main/webapp/images/drop/1.png new file mode 100644 index 0000000..9284b64 --- /dev/null +++ b/src/main/webapp/images/drop/1.png Binary files differ diff --git a/src/main/webapp/images/drop/2.png b/src/main/webapp/images/drop/2.png new file mode 100644 index 0000000..b5425db --- /dev/null +++ b/src/main/webapp/images/drop/2.png Binary files differ diff --git a/src/main/webapp/images/drop/3.png b/src/main/webapp/images/drop/3.png new file mode 100644 index 0000000..dd09655 --- /dev/null +++ b/src/main/webapp/images/drop/3.png Binary files differ diff --git a/src/main/webapp/images/drop/4.png b/src/main/webapp/images/drop/4.png new file mode 100644 index 0000000..50cf1f7 --- /dev/null +++ b/src/main/webapp/images/drop/4.png Binary files differ diff --git a/src/main/webapp/images/drop/5.png b/src/main/webapp/images/drop/5.png new file mode 100644 index 0000000..a2029bd --- /dev/null +++ b/src/main/webapp/images/drop/5.png Binary files differ diff --git a/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java new file mode 100644 index 0000000..634ceae --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java @@ -0,0 +1,46 @@ +package com.casic.accessControl.app.domain; + +import javax.persistence.*; +import java.util.Date; + +/** + * app的版本信息 + */ +//工单 +@Entity +@Table(name = "apkVersion") +public class ApkVersion { + private String version; + private String path; + private Date ts;//时间戳 + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "version") + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + @Column(name = "path") + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + @Column(name = "ts") + public Date getTs() { + return ts; + } + + public void setTs(Date ts) { + this.ts = ts; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java new file mode 100644 index 0000000..1d0242a --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java @@ -0,0 +1,50 @@ +package com.casic.accessControl.app.dto; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.util.TimeFormat; + +/** + * Created by lenovo on 2016/4/13. + */ +public class ApkVersionDto { + private String version; + private String path; + private String ts; + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public String getTs() { + return ts; + } + + public void setTs(String ts) { + this.ts = ts; + } + + public static ApkVersionDto Convert(ApkVersion version) { + if (version == null) { + return null; + } + ApkVersionDto versionDto = new ApkVersionDto(); + versionDto.setVersion(version.getVersion()); + versionDto.setPath(version.getVersion()); + versionDto.setTs(TimeFormat.formatTimestamp(version.getTs())); + + return versionDto; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java b/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java new file mode 100644 index 0000000..28b12a7 --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java @@ -0,0 +1,27 @@ +package com.casic.accessControl.app.manager; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.core.hibernate.HibernateEntityDao; +import org.hibernate.Query; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * + */ +@Service("apkVersionManager") +public class ApkVersionManager extends HibernateEntityDao { + + public ApkVersion getLatestVersion() { + String sql = "from ApkVersion order by ts desc"; + Query query = getSession().createQuery(sql); + List list = query.list(); + if (null != list && list.isEmpty() == false) { + return list.get(0); + } + + return null; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java b/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java new file mode 100644 index 0000000..065d3cc --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java @@ -0,0 +1,66 @@ +package com.casic.accessControl.app.web; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.app.manager.ApkVersionManager; +import com.casic.accessControl.marker.domain.Marker; +import com.casic.accessControl.marker.manager.MarkerManager; +import com.casic.accessControl.task.domain.Task; +import com.casic.accessControl.task.domain.TaskDetail; +import com.casic.accessControl.task.dto.TaskDetailDto; +import com.casic.accessControl.task.dto.TaskDto; +import com.casic.accessControl.task.dto.TaskStatus; +import com.casic.accessControl.task.manager.TaskDetailManager; +import com.casic.accessControl.task.manager.TaskManager; +import com.casic.accessControl.user.domain.Company; +import com.casic.accessControl.user.domain.Role; +import com.casic.accessControl.user.domain.User; +import com.casic.accessControl.user.dto.UserDto; +import com.casic.accessControl.user.manager.RoleManager; +import com.casic.accessControl.user.manager.UserManager; +import com.casic.accessControl.util.DataTable; +import com.casic.accessControl.util.StringUtils; +import com.google.gson.Gson; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +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.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * Created by lenovo on 2016/4/13. + */ +@Controller +@RequestMapping("app") +public class ApkVersionController { + + @Resource + private ApkVersionManager apkVersionManager; + + @RequestMapping("get-latest-version") + @ResponseBody + public Map getLatestVersion(HttpServletResponse response, HttpSession session) { + Map result = new HashMap(); + try { + ApkVersion latest = apkVersionManager.getLatestVersion(); + if (null != latest) { + result.put("version", latest.getVersion()); + result.put("path", latest.getPath()); + } else { + result.put("version", "1.0.0"); + } + } catch (Exception e) { + e.printStackTrace(); + result.put("version", "1.0.0"); + } + + return result; + } + +} diff --git a/src/main/java/com/casic/accessControl/marker/domain/Marker.java b/src/main/java/com/casic/accessControl/marker/domain/Marker.java index 0575cfe..7d5b854 100644 --- a/src/main/java/com/casic/accessControl/marker/domain/Marker.java +++ b/src/main/java/com/casic/accessControl/marker/domain/Marker.java @@ -67,6 +67,10 @@ private String area; @Column(name = "line") private String line; + @Column(name = "colorType") + private String colorType; + @Column(name = "photos") + private String photos; @@ -315,4 +319,20 @@ public void setArea(String area) { this.area = area; } + + public String getColorType() { + return colorType; + } + + public void setColorType(String colorType) { + this.colorType = colorType; + } + + public String getPhotos() { + return photos; + } + + public void setPhotos(String photos) { + this.photos = photos; + } } diff --git a/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java b/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java index 506f31d..c5f8cf5 100644 --- a/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java +++ b/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java @@ -2,12 +2,12 @@ //import com.casic.accessControl.feature.domain.Feature; import com.casic.accessControl.marker.domain.Marker; +import com.casic.accessControl.util.StringUtils; +import com.casic.accessControl.util.TimeFormat; import org.apache.commons.collections.CollectionUtils; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.List; +import java.text.ParseException; +import java.util.*; /** * Created by lenovo on 2016/5/16. @@ -43,6 +43,8 @@ private Long userId; private String area; private String line; + private String colorType; + private String photos; private String btnEdit = "编辑"; private String btnDelete = "删除"; @@ -296,6 +298,23 @@ this.area = area; } + public String getColorType() { + if (StringUtils.isEmpty(colorType)) return "0"; + return colorType; + } + + public void setColorType(String colorType) { + this.colorType = colorType; + } + + public String getPhotos() { + return photos; + } + + public void setPhotos(String photos) { + this.photos = photos; + } + public String getLine() { return line; } @@ -335,6 +354,52 @@ result.setRoad(doNullChange(marker.getRoad())); result.setArea(doNullChange(marker.getArea())); result.setLine(doNullChange(marker.getLine())); + result.setColorType(marker.getColorType()); + result.setPhotos(marker.getPhotos()); + return result; + } + + public static Marker convert2Marker(MarkerDto markerDto) { + if (markerDto == null) return null; + Marker result = new Marker(); + if(markerDto.getLongitude()==null||markerDto.getLatitude()==null) return null; + if (null != markerDto.getCreateTime() && markerDto.getCreateTime().length() == 19) { + try { + result.setCreateTime(TimeFormat.parse(markerDto.getCreateTime(), "yyyy-MM-dd HH:mm:ss")); + } catch (ParseException pex) { + result.setCreateTime(Calendar.getInstance().getTime()); + } + } else { + result.setCreateTime(Calendar.getInstance().getTime()); + } + result.setDepth(doNullChange(markerDto.getDepth())); + result.setId(markerDto.getId()); + result.setLatitude(markerDto.getLatitude()); + result.setLongitude(markerDto.getLongitude()); + result.setMarkerId(markerDto.getMarkerId()); + result.setMarkerDepth(doNullChange(markerDto.getMarkerDepth())); + result.setMarkerObjectId(doNullChange(markerDto.getMarkerObjectId())); + result.setMarkerObjectType(doNullChange(markerDto.getMarkerObjectType())); + result.setOwnerComp(doNullChange(markerDto.getOwnerComp())); + result.setIsValid(markerDto.getIsValid()); + result.setMemo(doNullChange(markerDto.getMemo())); + result.setPipeDiameter(doNullChange(markerDto.getPipeDiameter())); + result.setPipeMaterial(doNullChange(markerDto.getPipeMaterial())); + result.setMarkerType(doNullChange(markerDto.getMarkerType())); + result.setCreator(doNullChange(markerDto.getCreator())); + + result.setLayStyle(doNullChange(markerDto.getLayStyle())); + result.setBelowDepth(doNullChange(markerDto.getBelowDepth())); + result.setBelowDiameter(doNullChange(markerDto.getBelowDiameter())); + result.setBelowMaterial(doNullChange(markerDto.getBelowMaterial())); + result.setBelowType(doNullChange(markerDto.getBelowType())); + result.setConstructTime(doNullChange(markerDto.getConstructTime())); + result.setRecordType(markerDto.getRecordType()); + result.setRoad(doNullChange(markerDto.getRoad())); + result.setArea(doNullChange(markerDto.getArea())); + result.setLine(doNullChange(markerDto.getLine())); + result.setColorType(markerDto.getColorType()); + result.setPhotos(markerDto.getPhotos()); return result; } diff --git a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java index dd0fa4b..ba5a1fb 100644 --- a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java +++ b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java @@ -9,10 +9,7 @@ import com.casic.accessControl.marker.domain.Marker; import com.casic.accessControl.user.domain.Company; import com.casic.accessControl.user.domain.User; -import com.casic.accessControl.util.DataTable; -import com.casic.accessControl.util.DataTableParameter; -import com.casic.accessControl.util.DataTableUtils; -import com.casic.accessControl.util.DateUtils; +import com.casic.accessControl.util.*; import com.google.gson.Gson; import jxl.*; import jxl.read.biff.BiffException; @@ -31,11 +28,15 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; +import sun.misc.BASE64Decoder; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.File; +import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.text.ParseException; @@ -183,6 +184,53 @@ } /** + * 保存标识器和图片信息 + * @param markerDto + * @param companyId + * @param fileNames + * @param fileBuffers + * @return + */ + public boolean saveMarkerAndPhotos(MarkerDto markerDto, Long companyId, String[] fileNames, String[] fileBuffers) { + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + String strDirPath = request.getSession().getServletContext().getRealPath(""); + FileOutputStream fos = null; + String month = TimeFormat.format(Calendar.getInstance().getTime(), "yyyyMM"); + String webPath = "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String toDir = strDirPath + "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String filePaths = ""; + try { + for (int i = 0; i < fileBuffers.length; i++) { + if (fileBuffers[i] != null && fileNames[i] != null) { +// filePaths += toDir+fileNames[i]+","; + filePaths += webPath + fileNames[i] + ","; + byte[] buffer = new BASE64Decoder().decodeBuffer(fileBuffers[i]); //对android传过来的图片字符串进行解码 + File destDir = new File(toDir); + if (!destDir.exists()) + destDir.mkdirs(); + File imageFile = new File(destDir, fileNames[i]); + fos = new FileOutputStream(imageFile); //保存图片 + fos.write(buffer); + fos.flush(); + fos.close(); + } + } + if (filePaths.endsWith(",")) { + filePaths = filePaths.substring(0, filePaths.length() - 1); + } + } catch (Exception e) { + return false; + } + Marker marker = MarkerDto.convert2Marker(markerDto); + marker.setIsValid(1); + marker.setCompanyId(companyId); + marker.setPhotos(filePaths); + save(marker); + return true; + + } + + /** * 新增标识器 8-9 * * @param markers @@ -582,7 +630,7 @@ "所属区域","所属线路","所属道路","建设年代","权属单位","标示对象ID", "标识器ID","标识器类型","标识器埋深","安装部门","经度", "纬度", "最后修改时间","备注","下层管种类", "下层管埋深", - "下层管直径", "下层管材料", "标识对象类别"}; + "下层管直径", "下层管材料", "标识对象类别", "标识点颜色", "图片地址"}; Label[][] labels = new Label[markerDtos.size() + 1][titleTxt.length]; for(int k=0;k saveMarkerAndPhotos(@RequestParam(value = "fileBuffer1", required = false) MultipartFile fileBuffer1, + @RequestParam(value = "fileBuffer2", required = false) MultipartFile fileBuffer2, + @RequestParam(value = "fileBuffer3", required = false) MultipartFile fileBuffer3, + @RequestParam(value = "jsonMarker", required = true) String jsonMarker) { + Map map = new HashMap(); + map.put("message", "安装无标识器信息"); + Gson gson = new Gson(); + try { + MarkerDto marker = gson.fromJson(jsonMarker, MarkerDto.class); + + if (null == marker.getMarkerId()) { + map.put("message", "无标识器ID"); + map.put("success", "false"); + return map; + } else if (markerManager.getMarkerByMarkerId(marker.getMarkerId()).size() > 0) { + map.put("message", "已安装过该标识器[" + marker.getMarkerId() + "]"); + map.put("success", "false"); + return map; + } else { + String[] fileNames = new String[3]; + String[] fileBuffers = new String[3]; + if (fileBuffer1 != null) { + fileNames[0] = marker.getMarkerId() + "_" + fileBuffer1.getOriginalFilename(); + byte[] fis = fileBuffer1.getBytes(); + fileBuffers[0] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, com.sun.org.apache.xml.internal.security.utils.Base64.BASE64DEFAULTLENGTH)); + } + if (fileBuffer2 != null) { + fileNames[1] = marker.getMarkerId() + "_" + fileBuffer2.getOriginalFilename(); + byte[] fis = fileBuffer2.getBytes(); + fileBuffers[1] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, com.sun.org.apache.xml.internal.security.utils.Base64.BASE64DEFAULTLENGTH)); + } + if (fileBuffer3 != null) { + fileNames[2] = marker.getMarkerId() + "_" + fileBuffer3.getOriginalFilename(); + byte[] fis = fileBuffer3.getBytes(); + fileBuffers[2] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, Base64.BASE64DEFAULTLENGTH)); + } + Long companyId = marker.getCompanyId(); + if (companyId == null) { + return map; + } + boolean result = markerManager.saveMarkerAndPhotos(marker, companyId, fileNames, fileBuffers); + if (!result) { + return map; + } + } + } catch (Exception e) { + return map; + } + map.put("success", "true"); + map.put("message", "保存成功"); + return map; + } + + @RequestMapping("marker-info-delete") @ResponseBody public Map delete(@RequestParam(value = "id", required = true) Long id) { @@ -144,6 +208,9 @@ map.put("message", "删除需要ID信息"); return map; } + + System.out.println(ids); + markerManager.delMarkerByIds(ids); map.put("success", true); map.put("message", "删除成功"); @@ -240,6 +307,54 @@ return map; } + /** + * 批量上传标识点,用于无信号地区标识器信息统一上传,不修改已有标识点信息 + * @param strMarkers + * @return + */ + @RequestMapping("batch-save-no-update") + @ResponseBody + public Map batchSaveOrUpdate(@RequestParam(value = "markers", required = true) String strMarkers) { + strMarkers = strMarkers.replace('\n',' '); + Map map = new HashMap(); + map.put("message", "批量导入失败,或无导入标识器信息"); + Gson gson = new Gson(); + try { + List markers = gson.fromJson(strMarkers, new TypeToken>() { + }.getType()); + if (CollectionUtils.isEmpty(markers)) {//批量导入数据不存在,直接返回 + map.put("message", "批量导入数据不存在"); + return map; + } + + Long companyId = markers.get(0).getCompanyId(); + if (companyId == null) { + map.put("message", "未找到所属公司属性"); + return map; + } + + List markerDtoForSave = new ArrayList(); + for (MarkerDto markerDto : markers) { + // 上传marker的Id不为空且数据库中不存在记录,经纬度不为空,允许保存 + if (StringUtils.isNotBlank(markerDto.getMarkerId()) && markerManager.getMarkerByMarkerId(markerDto.getMarkerId()).size() <= 0) { + if (null != markerDto.getLongitude() && null != markerDto.getLatitude()) { + markerDtoForSave.add(markerDto); + } + } + } + boolean result = markerManager.batchSave(markerDtoForSave, companyId); + if (!result) { + return map; + } + } catch (Exception e) { + e.printStackTrace(); + return map; + } + map.put("success", true); + map.put("message", "保存成功"); + return map; + } + @RequestMapping("getMarkerListByCondition") @ResponseBody @POST diff --git a/src/main/java/com/casic/accessControl/user/web/UserController.java b/src/main/java/com/casic/accessControl/user/web/UserController.java index feab678..3534a97 100644 --- a/src/main/java/com/casic/accessControl/user/web/UserController.java +++ b/src/main/java/com/casic/accessControl/user/web/UserController.java @@ -46,6 +46,7 @@ @ResponseBody public Map login(@ModelAttribute User userInfo, HttpSession session) { Map result = new HashMap(); + User user = null; try{ user = userManager.login(userInfo); diff --git a/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java b/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java new file mode 100644 index 0000000..582120f --- /dev/null +++ b/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java @@ -0,0 +1,129 @@ +package com.casic.accessControl.util; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.net.URL; +import java.net.URLConnection; +import java.util.List; +import java.util.Map; + +/** + * Created by lenovo on 2016/8/31. + */ +public class HttpRequestUtils { + + /** + * 向指定URL发送GET方法的请求 + * + * @param url + * 发送请求的URL + * @param param + * 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 + * @return URL 所代表远程资源的响应结果 + */ + public static String sendGet(String url, String param) { + String result = ""; + BufferedReader in = null; + try { + String urlNameString = url + "?" + param; + URL realUrl = new URL(urlNameString); + // 打开和URL之间的连接 + URLConnection connection = realUrl.openConnection(); + // 设置通用的请求属性 + connection.setRequestProperty("accept", "*/*"); + connection.setRequestProperty("connection", "Keep-Alive"); + connection.setRequestProperty("user-agent", + "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + // 建立实际的连接 + connection.connect(); + // 获取所有响应头字段 + Map> map = connection.getHeaderFields(); + // 遍历所有的响应头字段 + for (String key : map.keySet()) { + System.out.println(key + "--->" + map.get(key)); + } + // 定义 BufferedReader输入流来读取URL的响应 + in = new BufferedReader(new InputStreamReader( + connection.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + result += line; + } + } catch (Exception e) { + System.out.println("发送GET请求出现异常!" + e); + e.printStackTrace(); + } + // 使用finally块来关闭输入流 + finally { + try { + if (in != null) { + in.close(); + } + } catch (Exception e2) { + e2.printStackTrace(); + } + } + return result; + } + + /** + * 向指定 URL 发送POST方法的请求 + * + * @param url + * 发送请求的 URL + * @param param + * 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 + * @return 所代表远程资源的响应结果 + */ + public static String sendPost(String url, String param) { + PrintWriter out = null; + BufferedReader in = null; + String result = ""; + try { + URL realUrl = new URL(url); + // 打开和URL之间的连接 + URLConnection conn = realUrl.openConnection(); + // 设置通用的请求属性 + conn.setRequestProperty("accept", "*/*"); + conn.setRequestProperty("connection", "Keep-Alive"); + conn.setRequestProperty("user-agent", + "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + // 发送POST请求必须设置如下两行 + conn.setDoOutput(true); + conn.setDoInput(true); + // 获取URLConnection对象对应的输出流 + out = new PrintWriter(conn.getOutputStream()); + // 发送请求参数 + out.print(param); + // flush输出流的缓冲 + out.flush(); + // 定义BufferedReader输入流来读取URL的响应 + in = new BufferedReader( + new InputStreamReader(conn.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + result += line; + } + } catch (Exception e) { + System.out.println("发送 POST 请求出现异常!"+e); + e.printStackTrace(); + } + //使用finally块来关闭输出流、输入流 + finally{ + try{ + if(out!=null){ + out.close(); + } + if(in!=null){ + in.close(); + } + } + catch(IOException ex){ + ex.printStackTrace(); + } + } + return result; + } + } \ No newline at end of file diff --git a/src/main/java/com/casic/accessControl/util/TimeFormat.java b/src/main/java/com/casic/accessControl/util/TimeFormat.java new file mode 100644 index 0000000..e9168d5 --- /dev/null +++ b/src/main/java/com/casic/accessControl/util/TimeFormat.java @@ -0,0 +1,148 @@ +package com.casic.accessControl.util; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +/** + * 格式化日期工具类 + * 默认模式yyyy-MM-dd HH:mm:ss + * @author Administrator + * + */ +public class TimeFormat { + + private static final String DATE_FORMAT_STRING = "yyyy-MM-dd"; + private static final String TIME_FORMAT_STRING = "HH:mm:ss"; + private static final String TIMESTAMP_FORMAT_STRING = "yyyy-MM-dd HH:mm:ss"; + + // 默认格式化格式 + private static SimpleDateFormat defaultFormat = new SimpleDateFormat(TIMESTAMP_FORMAT_STRING); + + public static void setFormatString(String pattern) { + defaultFormat.applyPattern(pattern); + } + + /** + * 默认格式化日期 + * + * @param Date date + * @return String + */ + public static String format(Date date) { + return defaultFormat.format(date); + } + + /** + * 日期格式化 + * + * @param date + * @return + */ + public static String formatDate(Date date) { + return TimeFormat.format(date, DATE_FORMAT_STRING); + } + + /** + * 时间格式化 + * + * @param date + * @return + */ + public static String formatTime(Date date) { + return TimeFormat.format(date, TIME_FORMAT_STRING); + } + + /** + * 时间戳格式化 + * + * @param date + * @return + */ + public static String formatTimestamp(Date date) { + return TimeFormat.format(date, TIMESTAMP_FORMAT_STRING); + } + + /** + * 以指定模式格式化日期 + * + * @param Date date + * @param String pattern + * @return String + */ + public static String format(Date date, String pattern) { + SimpleDateFormat formatter = new SimpleDateFormat(pattern); + return formatter.format(date); + } + + /** + * 根据起止日期生成日期序列 + * 包括start和end的日期 + * + * @param start + * @param end + * @return + */ + public static List generateDates(String start, String end) throws ParseException { + List dates = new ArrayList(); + Calendar s = Calendar.getInstance(); + Calendar e = Calendar.getInstance(); + s.setTime(TimeFormat.parse(start, DATE_FORMAT_STRING)); + s.set(Calendar.HOUR_OF_DAY, 0); + s.set(Calendar.MINUTE, 0); + s.set(Calendar.SECOND, 0); + e.setTime(TimeFormat.parse(end, DATE_FORMAT_STRING)); + e.set(Calendar.HOUR_OF_DAY, 0); + e.set(Calendar.MINUTE, 0); + e.set(Calendar.SECOND, 0); + while (s.before(e) == true) { + dates.add(TimeFormat.formatDate(s.getTime())); + s.add(Calendar.DATE, 1); + } + + dates.add(end); + return dates; + } + + + /** + * 解析日期字符串 + * + * @param String source + * @return Date + * + * @throws ParseException + */ + public static Date parse(String source) throws ParseException { + return defaultFormat.parse(source); + } + + /** + * 以指定模式解析日期 + * + * @param String source + * @param String pattern + * @return Date + * + * @throws ParseException + */ + public static Date parse(String source, String pattern) throws ParseException { + SimpleDateFormat formatter = new SimpleDateFormat(pattern); + return formatter.parse(source); + } + + + public static Date parseDateWithoutTime(String source) throws ParseException { + SimpleDateFormat formatter = new SimpleDateFormat(DATE_FORMAT_STRING); + Calendar date = Calendar.getInstance(); + date.setTime(formatter.parse(source)); + date.set(Calendar.HOUR, 0); + date.set(Calendar.HOUR, 0); + date.set(Calendar.MINUTE, 0); + return date.getTime(); + } + +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 53c91ea..cea976f 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -15,19 +15,17 @@ # ============================================================================ # db # ============================================================================ -#db.default.driverClassName=oracle.jdbc.driver.OracleDriver -#db.default.url=jdbc:oracle:thin:@192.168.0.203:1521:SZHTDB2 -#db.default.username=scott -#db.default.password=SZHTDB2 db.default.driverClassName=com.mysql.jdbc.Driver -db.default.url=jdbc:mysql://127.0.0.1:3306/ems?useUnicode=true&characterEncoding=UTF-8 -db.default.username=emsweb -db.default.password=emsweb +db.default.url=jdbc:mysql://127.0.0.1:3306/ems_tong?useUnicode=true&characterEncoding=UTF-8 +db.default.username=root +db.default.password=root +#db.default.username=emsweb +#db.default.password=emsweb #db.default.url=jdbc:mysql://119.254.110.71:3307/ems?useUnicode=true&characterEncoding=UTF-8 #db.default.username=root #db.default.password=rootems - -# ============================================================================ +# +## ============================================================================ # log4jdbc # ============================================================================ log4jdbc.enable=true diff --git a/src/main/resources/spring/applicationContext-filter.xml b/src/main/resources/spring/applicationContext-filter.xml index a08c5fc..98ac7d6 100644 --- a/src/main/resources/spring/applicationContext-filter.xml +++ b/src/main/resources/spring/applicationContext-filter.xml @@ -35,9 +35,13 @@ /user/ill-login.do /marker/exportMarker.do /marker/batchSave-na.do + /marker/batch-save-no-update.do + /marker/save-marker-photo.do /event/save-event.do /task/get-task.do + /app/get-latest-version.do /xls/* + /apk/* diff --git a/src/main/resources/spring/applicationContext-hibernate.xml b/src/main/resources/spring/applicationContext-hibernate.xml index 5bb1a7e..dc54192 100644 --- a/src/main/resources/spring/applicationContext-hibernate.xml +++ b/src/main/resources/spring/applicationContext-hibernate.xml @@ -65,6 +65,7 @@ com.casic.accessControl.task.domain.Position com.casic.accessControl.event.domain.Event com.casic.accessControl.marker.domain.OptionItem + com.casic.accessControl.app.domain.ApkVersion diff --git a/src/main/webapp/common/layout/menu_new.jsp b/src/main/webapp/common/layout/menu_new.jsp index 3cf4b4e..cbd822e 100644 --- a/src/main/webapp/common/layout/menu_new.jsp +++ b/src/main/webapp/common/layout/menu_new.jsp @@ -20,7 +20,7 @@
                • - + @@ -54,7 +54,7 @@
                • - + diff --git a/src/main/webapp/content/ems/ems-gd.jsp b/src/main/webapp/content/ems/ems-gd.jsp new file mode 100644 index 0000000..5137b49 --- /dev/null +++ b/src/main/webapp/content/ems/ems-gd.jsp @@ -0,0 +1,604 @@ +<%@page contentType="text/html;charset=UTF-8" %> + +<%@include file="/taglibs.jsp" %> + +<%pageContext.setAttribute("currentMenu", "ems");%> + + + + + + + + + + + + + 地下管线电子标识系统 + + + + + + + + + + + + + + + + + + +<%-- + +--%> + + + + + + + + + + + + + + +<%@include file="/common/layout/header.jsp" %> + +
                  + + + + <%@include file="/common/layout/menu_new.jsp" %> + + + +
                  + + + +
                  + +
                  + + +
                  +
                  +
                  +
                  + +
                  +
                  + +
                  +
                  + +
                  +
                  + +
                  +
                  + +
                  + +
                  + +
                  + +
                  + +
                  + +
                  +
                  +
                  + + + + +
                  +
                  +
                  +
                  + + + + +
                  +
                  +
                  + +
                  + +
                  + +<%--todo list:错误使用方法 + +--%> +
                  + +
                  +
                  + +
                  + +
                  + +
                  + + +
                  + +
                  + + 移动 + 绘制区域 + 新增标识器 + 删除标识器 + 保存标识器 + 批量导入 + 导出Excel + 清空 + +
                  + +
                  +
                  + +
                  + + + +
                  + +
                  + +
                  + + + + +
                  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/webapp/content/task/task-gd.jsp b/src/main/webapp/content/task/task-gd.jsp new file mode 100644 index 0000000..d2d5549 --- /dev/null +++ b/src/main/webapp/content/task/task-gd.jsp @@ -0,0 +1,374 @@ +<%@page contentType="text/html;charset=UTF-8" %> + +<%@include file="/taglibs.jsp" %> + +<%pageContext.setAttribute("currentMenu", "task");%> + + + + + + + + + + + + + 地下管线电子标识系统 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +<%@include file="/common/layout/header.jsp" %> + +
                  + + + + <%@include file="/common/layout/menu_new.jsp" %> + + + +
                  + + + +
                  + +
                  + +
                  + + 移动 + 绘制区域 + 选择多点创建工单 + 清空选择 + +
                  + +
                  + +
                  + + +
                  + +
                  + +
                  + +
                  历史工单
                  + +
                  + +
                  + +
                  + <%--巡检员:--%> +
                  +
                  + + +
                  +
                  + + +
                    +
                  +
                    +
                    + +
                    + +
                    + +
                    + +
                    +
                    + +
                    + + + +
                    + +
                    + +
                    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/webapp/images/drop/0.png b/src/main/webapp/images/drop/0.png new file mode 100644 index 0000000..f4b966b --- /dev/null +++ b/src/main/webapp/images/drop/0.png Binary files differ diff --git a/src/main/webapp/images/drop/1.png b/src/main/webapp/images/drop/1.png new file mode 100644 index 0000000..9284b64 --- /dev/null +++ b/src/main/webapp/images/drop/1.png Binary files differ diff --git a/src/main/webapp/images/drop/2.png b/src/main/webapp/images/drop/2.png new file mode 100644 index 0000000..b5425db --- /dev/null +++ b/src/main/webapp/images/drop/2.png Binary files differ diff --git a/src/main/webapp/images/drop/3.png b/src/main/webapp/images/drop/3.png new file mode 100644 index 0000000..dd09655 --- /dev/null +++ b/src/main/webapp/images/drop/3.png Binary files differ diff --git a/src/main/webapp/images/drop/4.png b/src/main/webapp/images/drop/4.png new file mode 100644 index 0000000..50cf1f7 --- /dev/null +++ b/src/main/webapp/images/drop/4.png Binary files differ diff --git a/src/main/webapp/images/drop/5.png b/src/main/webapp/images/drop/5.png new file mode 100644 index 0000000..a2029bd --- /dev/null +++ b/src/main/webapp/images/drop/5.png Binary files differ diff --git a/src/main/webapp/images/drop/6.png b/src/main/webapp/images/drop/6.png new file mode 100644 index 0000000..b53248a --- /dev/null +++ b/src/main/webapp/images/drop/6.png Binary files differ diff --git a/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java new file mode 100644 index 0000000..634ceae --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java @@ -0,0 +1,46 @@ +package com.casic.accessControl.app.domain; + +import javax.persistence.*; +import java.util.Date; + +/** + * app的版本信息 + */ +//工单 +@Entity +@Table(name = "apkVersion") +public class ApkVersion { + private String version; + private String path; + private Date ts;//时间戳 + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "version") + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + @Column(name = "path") + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + @Column(name = "ts") + public Date getTs() { + return ts; + } + + public void setTs(Date ts) { + this.ts = ts; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java new file mode 100644 index 0000000..1d0242a --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java @@ -0,0 +1,50 @@ +package com.casic.accessControl.app.dto; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.util.TimeFormat; + +/** + * Created by lenovo on 2016/4/13. + */ +public class ApkVersionDto { + private String version; + private String path; + private String ts; + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public String getTs() { + return ts; + } + + public void setTs(String ts) { + this.ts = ts; + } + + public static ApkVersionDto Convert(ApkVersion version) { + if (version == null) { + return null; + } + ApkVersionDto versionDto = new ApkVersionDto(); + versionDto.setVersion(version.getVersion()); + versionDto.setPath(version.getVersion()); + versionDto.setTs(TimeFormat.formatTimestamp(version.getTs())); + + return versionDto; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java b/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java new file mode 100644 index 0000000..28b12a7 --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java @@ -0,0 +1,27 @@ +package com.casic.accessControl.app.manager; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.core.hibernate.HibernateEntityDao; +import org.hibernate.Query; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * + */ +@Service("apkVersionManager") +public class ApkVersionManager extends HibernateEntityDao { + + public ApkVersion getLatestVersion() { + String sql = "from ApkVersion order by ts desc"; + Query query = getSession().createQuery(sql); + List list = query.list(); + if (null != list && list.isEmpty() == false) { + return list.get(0); + } + + return null; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java b/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java new file mode 100644 index 0000000..065d3cc --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java @@ -0,0 +1,66 @@ +package com.casic.accessControl.app.web; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.app.manager.ApkVersionManager; +import com.casic.accessControl.marker.domain.Marker; +import com.casic.accessControl.marker.manager.MarkerManager; +import com.casic.accessControl.task.domain.Task; +import com.casic.accessControl.task.domain.TaskDetail; +import com.casic.accessControl.task.dto.TaskDetailDto; +import com.casic.accessControl.task.dto.TaskDto; +import com.casic.accessControl.task.dto.TaskStatus; +import com.casic.accessControl.task.manager.TaskDetailManager; +import com.casic.accessControl.task.manager.TaskManager; +import com.casic.accessControl.user.domain.Company; +import com.casic.accessControl.user.domain.Role; +import com.casic.accessControl.user.domain.User; +import com.casic.accessControl.user.dto.UserDto; +import com.casic.accessControl.user.manager.RoleManager; +import com.casic.accessControl.user.manager.UserManager; +import com.casic.accessControl.util.DataTable; +import com.casic.accessControl.util.StringUtils; +import com.google.gson.Gson; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +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.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * Created by lenovo on 2016/4/13. + */ +@Controller +@RequestMapping("app") +public class ApkVersionController { + + @Resource + private ApkVersionManager apkVersionManager; + + @RequestMapping("get-latest-version") + @ResponseBody + public Map getLatestVersion(HttpServletResponse response, HttpSession session) { + Map result = new HashMap(); + try { + ApkVersion latest = apkVersionManager.getLatestVersion(); + if (null != latest) { + result.put("version", latest.getVersion()); + result.put("path", latest.getPath()); + } else { + result.put("version", "1.0.0"); + } + } catch (Exception e) { + e.printStackTrace(); + result.put("version", "1.0.0"); + } + + return result; + } + +} diff --git a/src/main/java/com/casic/accessControl/marker/domain/Marker.java b/src/main/java/com/casic/accessControl/marker/domain/Marker.java index 0575cfe..7d5b854 100644 --- a/src/main/java/com/casic/accessControl/marker/domain/Marker.java +++ b/src/main/java/com/casic/accessControl/marker/domain/Marker.java @@ -67,6 +67,10 @@ private String area; @Column(name = "line") private String line; + @Column(name = "colorType") + private String colorType; + @Column(name = "photos") + private String photos; @@ -315,4 +319,20 @@ public void setArea(String area) { this.area = area; } + + public String getColorType() { + return colorType; + } + + public void setColorType(String colorType) { + this.colorType = colorType; + } + + public String getPhotos() { + return photos; + } + + public void setPhotos(String photos) { + this.photos = photos; + } } diff --git a/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java b/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java index 506f31d..c5f8cf5 100644 --- a/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java +++ b/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java @@ -2,12 +2,12 @@ //import com.casic.accessControl.feature.domain.Feature; import com.casic.accessControl.marker.domain.Marker; +import com.casic.accessControl.util.StringUtils; +import com.casic.accessControl.util.TimeFormat; import org.apache.commons.collections.CollectionUtils; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.List; +import java.text.ParseException; +import java.util.*; /** * Created by lenovo on 2016/5/16. @@ -43,6 +43,8 @@ private Long userId; private String area; private String line; + private String colorType; + private String photos; private String btnEdit = "编辑"; private String btnDelete = "删除"; @@ -296,6 +298,23 @@ this.area = area; } + public String getColorType() { + if (StringUtils.isEmpty(colorType)) return "0"; + return colorType; + } + + public void setColorType(String colorType) { + this.colorType = colorType; + } + + public String getPhotos() { + return photos; + } + + public void setPhotos(String photos) { + this.photos = photos; + } + public String getLine() { return line; } @@ -335,6 +354,52 @@ result.setRoad(doNullChange(marker.getRoad())); result.setArea(doNullChange(marker.getArea())); result.setLine(doNullChange(marker.getLine())); + result.setColorType(marker.getColorType()); + result.setPhotos(marker.getPhotos()); + return result; + } + + public static Marker convert2Marker(MarkerDto markerDto) { + if (markerDto == null) return null; + Marker result = new Marker(); + if(markerDto.getLongitude()==null||markerDto.getLatitude()==null) return null; + if (null != markerDto.getCreateTime() && markerDto.getCreateTime().length() == 19) { + try { + result.setCreateTime(TimeFormat.parse(markerDto.getCreateTime(), "yyyy-MM-dd HH:mm:ss")); + } catch (ParseException pex) { + result.setCreateTime(Calendar.getInstance().getTime()); + } + } else { + result.setCreateTime(Calendar.getInstance().getTime()); + } + result.setDepth(doNullChange(markerDto.getDepth())); + result.setId(markerDto.getId()); + result.setLatitude(markerDto.getLatitude()); + result.setLongitude(markerDto.getLongitude()); + result.setMarkerId(markerDto.getMarkerId()); + result.setMarkerDepth(doNullChange(markerDto.getMarkerDepth())); + result.setMarkerObjectId(doNullChange(markerDto.getMarkerObjectId())); + result.setMarkerObjectType(doNullChange(markerDto.getMarkerObjectType())); + result.setOwnerComp(doNullChange(markerDto.getOwnerComp())); + result.setIsValid(markerDto.getIsValid()); + result.setMemo(doNullChange(markerDto.getMemo())); + result.setPipeDiameter(doNullChange(markerDto.getPipeDiameter())); + result.setPipeMaterial(doNullChange(markerDto.getPipeMaterial())); + result.setMarkerType(doNullChange(markerDto.getMarkerType())); + result.setCreator(doNullChange(markerDto.getCreator())); + + result.setLayStyle(doNullChange(markerDto.getLayStyle())); + result.setBelowDepth(doNullChange(markerDto.getBelowDepth())); + result.setBelowDiameter(doNullChange(markerDto.getBelowDiameter())); + result.setBelowMaterial(doNullChange(markerDto.getBelowMaterial())); + result.setBelowType(doNullChange(markerDto.getBelowType())); + result.setConstructTime(doNullChange(markerDto.getConstructTime())); + result.setRecordType(markerDto.getRecordType()); + result.setRoad(doNullChange(markerDto.getRoad())); + result.setArea(doNullChange(markerDto.getArea())); + result.setLine(doNullChange(markerDto.getLine())); + result.setColorType(markerDto.getColorType()); + result.setPhotos(markerDto.getPhotos()); return result; } diff --git a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java index dd0fa4b..ba5a1fb 100644 --- a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java +++ b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java @@ -9,10 +9,7 @@ import com.casic.accessControl.marker.domain.Marker; import com.casic.accessControl.user.domain.Company; import com.casic.accessControl.user.domain.User; -import com.casic.accessControl.util.DataTable; -import com.casic.accessControl.util.DataTableParameter; -import com.casic.accessControl.util.DataTableUtils; -import com.casic.accessControl.util.DateUtils; +import com.casic.accessControl.util.*; import com.google.gson.Gson; import jxl.*; import jxl.read.biff.BiffException; @@ -31,11 +28,15 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; +import sun.misc.BASE64Decoder; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.File; +import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.text.ParseException; @@ -183,6 +184,53 @@ } /** + * 保存标识器和图片信息 + * @param markerDto + * @param companyId + * @param fileNames + * @param fileBuffers + * @return + */ + public boolean saveMarkerAndPhotos(MarkerDto markerDto, Long companyId, String[] fileNames, String[] fileBuffers) { + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + String strDirPath = request.getSession().getServletContext().getRealPath(""); + FileOutputStream fos = null; + String month = TimeFormat.format(Calendar.getInstance().getTime(), "yyyyMM"); + String webPath = "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String toDir = strDirPath + "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String filePaths = ""; + try { + for (int i = 0; i < fileBuffers.length; i++) { + if (fileBuffers[i] != null && fileNames[i] != null) { +// filePaths += toDir+fileNames[i]+","; + filePaths += webPath + fileNames[i] + ","; + byte[] buffer = new BASE64Decoder().decodeBuffer(fileBuffers[i]); //对android传过来的图片字符串进行解码 + File destDir = new File(toDir); + if (!destDir.exists()) + destDir.mkdirs(); + File imageFile = new File(destDir, fileNames[i]); + fos = new FileOutputStream(imageFile); //保存图片 + fos.write(buffer); + fos.flush(); + fos.close(); + } + } + if (filePaths.endsWith(",")) { + filePaths = filePaths.substring(0, filePaths.length() - 1); + } + } catch (Exception e) { + return false; + } + Marker marker = MarkerDto.convert2Marker(markerDto); + marker.setIsValid(1); + marker.setCompanyId(companyId); + marker.setPhotos(filePaths); + save(marker); + return true; + + } + + /** * 新增标识器 8-9 * * @param markers @@ -582,7 +630,7 @@ "所属区域","所属线路","所属道路","建设年代","权属单位","标示对象ID", "标识器ID","标识器类型","标识器埋深","安装部门","经度", "纬度", "最后修改时间","备注","下层管种类", "下层管埋深", - "下层管直径", "下层管材料", "标识对象类别"}; + "下层管直径", "下层管材料", "标识对象类别", "标识点颜色", "图片地址"}; Label[][] labels = new Label[markerDtos.size() + 1][titleTxt.length]; for(int k=0;k saveMarkerAndPhotos(@RequestParam(value = "fileBuffer1", required = false) MultipartFile fileBuffer1, + @RequestParam(value = "fileBuffer2", required = false) MultipartFile fileBuffer2, + @RequestParam(value = "fileBuffer3", required = false) MultipartFile fileBuffer3, + @RequestParam(value = "jsonMarker", required = true) String jsonMarker) { + Map map = new HashMap(); + map.put("message", "安装无标识器信息"); + Gson gson = new Gson(); + try { + MarkerDto marker = gson.fromJson(jsonMarker, MarkerDto.class); + + if (null == marker.getMarkerId()) { + map.put("message", "无标识器ID"); + map.put("success", "false"); + return map; + } else if (markerManager.getMarkerByMarkerId(marker.getMarkerId()).size() > 0) { + map.put("message", "已安装过该标识器[" + marker.getMarkerId() + "]"); + map.put("success", "false"); + return map; + } else { + String[] fileNames = new String[3]; + String[] fileBuffers = new String[3]; + if (fileBuffer1 != null) { + fileNames[0] = marker.getMarkerId() + "_" + fileBuffer1.getOriginalFilename(); + byte[] fis = fileBuffer1.getBytes(); + fileBuffers[0] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, com.sun.org.apache.xml.internal.security.utils.Base64.BASE64DEFAULTLENGTH)); + } + if (fileBuffer2 != null) { + fileNames[1] = marker.getMarkerId() + "_" + fileBuffer2.getOriginalFilename(); + byte[] fis = fileBuffer2.getBytes(); + fileBuffers[1] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, com.sun.org.apache.xml.internal.security.utils.Base64.BASE64DEFAULTLENGTH)); + } + if (fileBuffer3 != null) { + fileNames[2] = marker.getMarkerId() + "_" + fileBuffer3.getOriginalFilename(); + byte[] fis = fileBuffer3.getBytes(); + fileBuffers[2] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, Base64.BASE64DEFAULTLENGTH)); + } + Long companyId = marker.getCompanyId(); + if (companyId == null) { + return map; + } + boolean result = markerManager.saveMarkerAndPhotos(marker, companyId, fileNames, fileBuffers); + if (!result) { + return map; + } + } + } catch (Exception e) { + return map; + } + map.put("success", "true"); + map.put("message", "保存成功"); + return map; + } + + @RequestMapping("marker-info-delete") @ResponseBody public Map delete(@RequestParam(value = "id", required = true) Long id) { @@ -144,6 +208,9 @@ map.put("message", "删除需要ID信息"); return map; } + + System.out.println(ids); + markerManager.delMarkerByIds(ids); map.put("success", true); map.put("message", "删除成功"); @@ -240,6 +307,54 @@ return map; } + /** + * 批量上传标识点,用于无信号地区标识器信息统一上传,不修改已有标识点信息 + * @param strMarkers + * @return + */ + @RequestMapping("batch-save-no-update") + @ResponseBody + public Map batchSaveOrUpdate(@RequestParam(value = "markers", required = true) String strMarkers) { + strMarkers = strMarkers.replace('\n',' '); + Map map = new HashMap(); + map.put("message", "批量导入失败,或无导入标识器信息"); + Gson gson = new Gson(); + try { + List markers = gson.fromJson(strMarkers, new TypeToken>() { + }.getType()); + if (CollectionUtils.isEmpty(markers)) {//批量导入数据不存在,直接返回 + map.put("message", "批量导入数据不存在"); + return map; + } + + Long companyId = markers.get(0).getCompanyId(); + if (companyId == null) { + map.put("message", "未找到所属公司属性"); + return map; + } + + List markerDtoForSave = new ArrayList(); + for (MarkerDto markerDto : markers) { + // 上传marker的Id不为空且数据库中不存在记录,经纬度不为空,允许保存 + if (StringUtils.isNotBlank(markerDto.getMarkerId()) && markerManager.getMarkerByMarkerId(markerDto.getMarkerId()).size() <= 0) { + if (null != markerDto.getLongitude() && null != markerDto.getLatitude()) { + markerDtoForSave.add(markerDto); + } + } + } + boolean result = markerManager.batchSave(markerDtoForSave, companyId); + if (!result) { + return map; + } + } catch (Exception e) { + e.printStackTrace(); + return map; + } + map.put("success", true); + map.put("message", "保存成功"); + return map; + } + @RequestMapping("getMarkerListByCondition") @ResponseBody @POST diff --git a/src/main/java/com/casic/accessControl/user/web/UserController.java b/src/main/java/com/casic/accessControl/user/web/UserController.java index feab678..3534a97 100644 --- a/src/main/java/com/casic/accessControl/user/web/UserController.java +++ b/src/main/java/com/casic/accessControl/user/web/UserController.java @@ -46,6 +46,7 @@ @ResponseBody public Map login(@ModelAttribute User userInfo, HttpSession session) { Map result = new HashMap(); + User user = null; try{ user = userManager.login(userInfo); diff --git a/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java b/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java new file mode 100644 index 0000000..582120f --- /dev/null +++ b/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java @@ -0,0 +1,129 @@ +package com.casic.accessControl.util; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.net.URL; +import java.net.URLConnection; +import java.util.List; +import java.util.Map; + +/** + * Created by lenovo on 2016/8/31. + */ +public class HttpRequestUtils { + + /** + * 向指定URL发送GET方法的请求 + * + * @param url + * 发送请求的URL + * @param param + * 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 + * @return URL 所代表远程资源的响应结果 + */ + public static String sendGet(String url, String param) { + String result = ""; + BufferedReader in = null; + try { + String urlNameString = url + "?" + param; + URL realUrl = new URL(urlNameString); + // 打开和URL之间的连接 + URLConnection connection = realUrl.openConnection(); + // 设置通用的请求属性 + connection.setRequestProperty("accept", "*/*"); + connection.setRequestProperty("connection", "Keep-Alive"); + connection.setRequestProperty("user-agent", + "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + // 建立实际的连接 + connection.connect(); + // 获取所有响应头字段 + Map> map = connection.getHeaderFields(); + // 遍历所有的响应头字段 + for (String key : map.keySet()) { + System.out.println(key + "--->" + map.get(key)); + } + // 定义 BufferedReader输入流来读取URL的响应 + in = new BufferedReader(new InputStreamReader( + connection.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + result += line; + } + } catch (Exception e) { + System.out.println("发送GET请求出现异常!" + e); + e.printStackTrace(); + } + // 使用finally块来关闭输入流 + finally { + try { + if (in != null) { + in.close(); + } + } catch (Exception e2) { + e2.printStackTrace(); + } + } + return result; + } + + /** + * 向指定 URL 发送POST方法的请求 + * + * @param url + * 发送请求的 URL + * @param param + * 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 + * @return 所代表远程资源的响应结果 + */ + public static String sendPost(String url, String param) { + PrintWriter out = null; + BufferedReader in = null; + String result = ""; + try { + URL realUrl = new URL(url); + // 打开和URL之间的连接 + URLConnection conn = realUrl.openConnection(); + // 设置通用的请求属性 + conn.setRequestProperty("accept", "*/*"); + conn.setRequestProperty("connection", "Keep-Alive"); + conn.setRequestProperty("user-agent", + "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + // 发送POST请求必须设置如下两行 + conn.setDoOutput(true); + conn.setDoInput(true); + // 获取URLConnection对象对应的输出流 + out = new PrintWriter(conn.getOutputStream()); + // 发送请求参数 + out.print(param); + // flush输出流的缓冲 + out.flush(); + // 定义BufferedReader输入流来读取URL的响应 + in = new BufferedReader( + new InputStreamReader(conn.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + result += line; + } + } catch (Exception e) { + System.out.println("发送 POST 请求出现异常!"+e); + e.printStackTrace(); + } + //使用finally块来关闭输出流、输入流 + finally{ + try{ + if(out!=null){ + out.close(); + } + if(in!=null){ + in.close(); + } + } + catch(IOException ex){ + ex.printStackTrace(); + } + } + return result; + } + } \ No newline at end of file diff --git a/src/main/java/com/casic/accessControl/util/TimeFormat.java b/src/main/java/com/casic/accessControl/util/TimeFormat.java new file mode 100644 index 0000000..e9168d5 --- /dev/null +++ b/src/main/java/com/casic/accessControl/util/TimeFormat.java @@ -0,0 +1,148 @@ +package com.casic.accessControl.util; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +/** + * 格式化日期工具类 + * 默认模式yyyy-MM-dd HH:mm:ss + * @author Administrator + * + */ +public class TimeFormat { + + private static final String DATE_FORMAT_STRING = "yyyy-MM-dd"; + private static final String TIME_FORMAT_STRING = "HH:mm:ss"; + private static final String TIMESTAMP_FORMAT_STRING = "yyyy-MM-dd HH:mm:ss"; + + // 默认格式化格式 + private static SimpleDateFormat defaultFormat = new SimpleDateFormat(TIMESTAMP_FORMAT_STRING); + + public static void setFormatString(String pattern) { + defaultFormat.applyPattern(pattern); + } + + /** + * 默认格式化日期 + * + * @param Date date + * @return String + */ + public static String format(Date date) { + return defaultFormat.format(date); + } + + /** + * 日期格式化 + * + * @param date + * @return + */ + public static String formatDate(Date date) { + return TimeFormat.format(date, DATE_FORMAT_STRING); + } + + /** + * 时间格式化 + * + * @param date + * @return + */ + public static String formatTime(Date date) { + return TimeFormat.format(date, TIME_FORMAT_STRING); + } + + /** + * 时间戳格式化 + * + * @param date + * @return + */ + public static String formatTimestamp(Date date) { + return TimeFormat.format(date, TIMESTAMP_FORMAT_STRING); + } + + /** + * 以指定模式格式化日期 + * + * @param Date date + * @param String pattern + * @return String + */ + public static String format(Date date, String pattern) { + SimpleDateFormat formatter = new SimpleDateFormat(pattern); + return formatter.format(date); + } + + /** + * 根据起止日期生成日期序列 + * 包括start和end的日期 + * + * @param start + * @param end + * @return + */ + public static List generateDates(String start, String end) throws ParseException { + List dates = new ArrayList(); + Calendar s = Calendar.getInstance(); + Calendar e = Calendar.getInstance(); + s.setTime(TimeFormat.parse(start, DATE_FORMAT_STRING)); + s.set(Calendar.HOUR_OF_DAY, 0); + s.set(Calendar.MINUTE, 0); + s.set(Calendar.SECOND, 0); + e.setTime(TimeFormat.parse(end, DATE_FORMAT_STRING)); + e.set(Calendar.HOUR_OF_DAY, 0); + e.set(Calendar.MINUTE, 0); + e.set(Calendar.SECOND, 0); + while (s.before(e) == true) { + dates.add(TimeFormat.formatDate(s.getTime())); + s.add(Calendar.DATE, 1); + } + + dates.add(end); + return dates; + } + + + /** + * 解析日期字符串 + * + * @param String source + * @return Date + * + * @throws ParseException + */ + public static Date parse(String source) throws ParseException { + return defaultFormat.parse(source); + } + + /** + * 以指定模式解析日期 + * + * @param String source + * @param String pattern + * @return Date + * + * @throws ParseException + */ + public static Date parse(String source, String pattern) throws ParseException { + SimpleDateFormat formatter = new SimpleDateFormat(pattern); + return formatter.parse(source); + } + + + public static Date parseDateWithoutTime(String source) throws ParseException { + SimpleDateFormat formatter = new SimpleDateFormat(DATE_FORMAT_STRING); + Calendar date = Calendar.getInstance(); + date.setTime(formatter.parse(source)); + date.set(Calendar.HOUR, 0); + date.set(Calendar.HOUR, 0); + date.set(Calendar.MINUTE, 0); + return date.getTime(); + } + +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 53c91ea..cea976f 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -15,19 +15,17 @@ # ============================================================================ # db # ============================================================================ -#db.default.driverClassName=oracle.jdbc.driver.OracleDriver -#db.default.url=jdbc:oracle:thin:@192.168.0.203:1521:SZHTDB2 -#db.default.username=scott -#db.default.password=SZHTDB2 db.default.driverClassName=com.mysql.jdbc.Driver -db.default.url=jdbc:mysql://127.0.0.1:3306/ems?useUnicode=true&characterEncoding=UTF-8 -db.default.username=emsweb -db.default.password=emsweb +db.default.url=jdbc:mysql://127.0.0.1:3306/ems_tong?useUnicode=true&characterEncoding=UTF-8 +db.default.username=root +db.default.password=root +#db.default.username=emsweb +#db.default.password=emsweb #db.default.url=jdbc:mysql://119.254.110.71:3307/ems?useUnicode=true&characterEncoding=UTF-8 #db.default.username=root #db.default.password=rootems - -# ============================================================================ +# +## ============================================================================ # log4jdbc # ============================================================================ log4jdbc.enable=true diff --git a/src/main/resources/spring/applicationContext-filter.xml b/src/main/resources/spring/applicationContext-filter.xml index a08c5fc..98ac7d6 100644 --- a/src/main/resources/spring/applicationContext-filter.xml +++ b/src/main/resources/spring/applicationContext-filter.xml @@ -35,9 +35,13 @@ /user/ill-login.do /marker/exportMarker.do /marker/batchSave-na.do + /marker/batch-save-no-update.do + /marker/save-marker-photo.do /event/save-event.do /task/get-task.do + /app/get-latest-version.do /xls/* + /apk/* diff --git a/src/main/resources/spring/applicationContext-hibernate.xml b/src/main/resources/spring/applicationContext-hibernate.xml index 5bb1a7e..dc54192 100644 --- a/src/main/resources/spring/applicationContext-hibernate.xml +++ b/src/main/resources/spring/applicationContext-hibernate.xml @@ -65,6 +65,7 @@ com.casic.accessControl.task.domain.Position com.casic.accessControl.event.domain.Event com.casic.accessControl.marker.domain.OptionItem + com.casic.accessControl.app.domain.ApkVersion diff --git a/src/main/webapp/common/layout/menu_new.jsp b/src/main/webapp/common/layout/menu_new.jsp index 3cf4b4e..cbd822e 100644 --- a/src/main/webapp/common/layout/menu_new.jsp +++ b/src/main/webapp/common/layout/menu_new.jsp @@ -20,7 +20,7 @@
                  • - + @@ -54,7 +54,7 @@
                  • - + diff --git a/src/main/webapp/content/ems/ems-gd.jsp b/src/main/webapp/content/ems/ems-gd.jsp new file mode 100644 index 0000000..5137b49 --- /dev/null +++ b/src/main/webapp/content/ems/ems-gd.jsp @@ -0,0 +1,604 @@ +<%@page contentType="text/html;charset=UTF-8" %> + +<%@include file="/taglibs.jsp" %> + +<%pageContext.setAttribute("currentMenu", "ems");%> + + + + + + + + + + + + + 地下管线电子标识系统 + + + + + + + + + + + + + + + + + + +<%-- + +--%> + + + + + + + + + + + + + + +<%@include file="/common/layout/header.jsp" %> + +
                    + + + + <%@include file="/common/layout/menu_new.jsp" %> + + + +
                    + + + +
                    + +
                    + + +
                    +
                    +
                    +
                    + +
                    +
                    + +
                    +
                    + +
                    +
                    + +
                    +
                    + +
                    + +
                    + +
                    + +
                    + +
                    + +
                    +
                    +
                    + + + + +
                    +
                    +
                    +
                    + + + + +
                    +
                    +
                    + +
                    + +
                    + +<%--todo list:错误使用方法 + +--%> +
                    + +
                    +
                    + +
                    + +
                    + +
                    + + +
                    + +
                    + + 移动 + 绘制区域 + 新增标识器 + 删除标识器 + 保存标识器 + 批量导入 + 导出Excel + 清空 + +
                    + +
                    +
                    + +
                    + + + +
                    + +
                    + +
                    + + + + +
                    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/webapp/content/task/task-gd.jsp b/src/main/webapp/content/task/task-gd.jsp new file mode 100644 index 0000000..d2d5549 --- /dev/null +++ b/src/main/webapp/content/task/task-gd.jsp @@ -0,0 +1,374 @@ +<%@page contentType="text/html;charset=UTF-8" %> + +<%@include file="/taglibs.jsp" %> + +<%pageContext.setAttribute("currentMenu", "task");%> + + + + + + + + + + + + + 地下管线电子标识系统 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +<%@include file="/common/layout/header.jsp" %> + +
                    + + + + <%@include file="/common/layout/menu_new.jsp" %> + + + +
                    + + + +
                    + +
                    + +
                    + + 移动 + 绘制区域 + 选择多点创建工单 + 清空选择 + +
                    + +
                    + +
                    + + +
                    + +
                    + +
                    + +
                    历史工单
                    + +
                    + +
                    + +
                    + <%--巡检员:--%> +
                    +
                    + + +
                    +
                    + + +
                      +
                    +
                      +
                      + +
                      + +
                      + +
                      + +
                      +
                      + +
                      + + + +
                      + +
                      + +
                      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/webapp/images/drop/0.png b/src/main/webapp/images/drop/0.png new file mode 100644 index 0000000..f4b966b --- /dev/null +++ b/src/main/webapp/images/drop/0.png Binary files differ diff --git a/src/main/webapp/images/drop/1.png b/src/main/webapp/images/drop/1.png new file mode 100644 index 0000000..9284b64 --- /dev/null +++ b/src/main/webapp/images/drop/1.png Binary files differ diff --git a/src/main/webapp/images/drop/2.png b/src/main/webapp/images/drop/2.png new file mode 100644 index 0000000..b5425db --- /dev/null +++ b/src/main/webapp/images/drop/2.png Binary files differ diff --git a/src/main/webapp/images/drop/3.png b/src/main/webapp/images/drop/3.png new file mode 100644 index 0000000..dd09655 --- /dev/null +++ b/src/main/webapp/images/drop/3.png Binary files differ diff --git a/src/main/webapp/images/drop/4.png b/src/main/webapp/images/drop/4.png new file mode 100644 index 0000000..50cf1f7 --- /dev/null +++ b/src/main/webapp/images/drop/4.png Binary files differ diff --git a/src/main/webapp/images/drop/5.png b/src/main/webapp/images/drop/5.png new file mode 100644 index 0000000..a2029bd --- /dev/null +++ b/src/main/webapp/images/drop/5.png Binary files differ diff --git a/src/main/webapp/images/drop/6.png b/src/main/webapp/images/drop/6.png new file mode 100644 index 0000000..b53248a --- /dev/null +++ b/src/main/webapp/images/drop/6.png Binary files differ diff --git a/src/main/webapp/images/ems/point.png b/src/main/webapp/images/ems/point.png new file mode 100644 index 0000000..a814351 --- /dev/null +++ b/src/main/webapp/images/ems/point.png Binary files differ diff --git a/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java new file mode 100644 index 0000000..634ceae --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java @@ -0,0 +1,46 @@ +package com.casic.accessControl.app.domain; + +import javax.persistence.*; +import java.util.Date; + +/** + * app的版本信息 + */ +//工单 +@Entity +@Table(name = "apkVersion") +public class ApkVersion { + private String version; + private String path; + private Date ts;//时间戳 + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "version") + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + @Column(name = "path") + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + @Column(name = "ts") + public Date getTs() { + return ts; + } + + public void setTs(Date ts) { + this.ts = ts; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java new file mode 100644 index 0000000..1d0242a --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java @@ -0,0 +1,50 @@ +package com.casic.accessControl.app.dto; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.util.TimeFormat; + +/** + * Created by lenovo on 2016/4/13. + */ +public class ApkVersionDto { + private String version; + private String path; + private String ts; + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public String getTs() { + return ts; + } + + public void setTs(String ts) { + this.ts = ts; + } + + public static ApkVersionDto Convert(ApkVersion version) { + if (version == null) { + return null; + } + ApkVersionDto versionDto = new ApkVersionDto(); + versionDto.setVersion(version.getVersion()); + versionDto.setPath(version.getVersion()); + versionDto.setTs(TimeFormat.formatTimestamp(version.getTs())); + + return versionDto; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java b/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java new file mode 100644 index 0000000..28b12a7 --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java @@ -0,0 +1,27 @@ +package com.casic.accessControl.app.manager; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.core.hibernate.HibernateEntityDao; +import org.hibernate.Query; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * + */ +@Service("apkVersionManager") +public class ApkVersionManager extends HibernateEntityDao { + + public ApkVersion getLatestVersion() { + String sql = "from ApkVersion order by ts desc"; + Query query = getSession().createQuery(sql); + List list = query.list(); + if (null != list && list.isEmpty() == false) { + return list.get(0); + } + + return null; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java b/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java new file mode 100644 index 0000000..065d3cc --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java @@ -0,0 +1,66 @@ +package com.casic.accessControl.app.web; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.app.manager.ApkVersionManager; +import com.casic.accessControl.marker.domain.Marker; +import com.casic.accessControl.marker.manager.MarkerManager; +import com.casic.accessControl.task.domain.Task; +import com.casic.accessControl.task.domain.TaskDetail; +import com.casic.accessControl.task.dto.TaskDetailDto; +import com.casic.accessControl.task.dto.TaskDto; +import com.casic.accessControl.task.dto.TaskStatus; +import com.casic.accessControl.task.manager.TaskDetailManager; +import com.casic.accessControl.task.manager.TaskManager; +import com.casic.accessControl.user.domain.Company; +import com.casic.accessControl.user.domain.Role; +import com.casic.accessControl.user.domain.User; +import com.casic.accessControl.user.dto.UserDto; +import com.casic.accessControl.user.manager.RoleManager; +import com.casic.accessControl.user.manager.UserManager; +import com.casic.accessControl.util.DataTable; +import com.casic.accessControl.util.StringUtils; +import com.google.gson.Gson; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +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.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * Created by lenovo on 2016/4/13. + */ +@Controller +@RequestMapping("app") +public class ApkVersionController { + + @Resource + private ApkVersionManager apkVersionManager; + + @RequestMapping("get-latest-version") + @ResponseBody + public Map getLatestVersion(HttpServletResponse response, HttpSession session) { + Map result = new HashMap(); + try { + ApkVersion latest = apkVersionManager.getLatestVersion(); + if (null != latest) { + result.put("version", latest.getVersion()); + result.put("path", latest.getPath()); + } else { + result.put("version", "1.0.0"); + } + } catch (Exception e) { + e.printStackTrace(); + result.put("version", "1.0.0"); + } + + return result; + } + +} diff --git a/src/main/java/com/casic/accessControl/marker/domain/Marker.java b/src/main/java/com/casic/accessControl/marker/domain/Marker.java index 0575cfe..7d5b854 100644 --- a/src/main/java/com/casic/accessControl/marker/domain/Marker.java +++ b/src/main/java/com/casic/accessControl/marker/domain/Marker.java @@ -67,6 +67,10 @@ private String area; @Column(name = "line") private String line; + @Column(name = "colorType") + private String colorType; + @Column(name = "photos") + private String photos; @@ -315,4 +319,20 @@ public void setArea(String area) { this.area = area; } + + public String getColorType() { + return colorType; + } + + public void setColorType(String colorType) { + this.colorType = colorType; + } + + public String getPhotos() { + return photos; + } + + public void setPhotos(String photos) { + this.photos = photos; + } } diff --git a/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java b/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java index 506f31d..c5f8cf5 100644 --- a/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java +++ b/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java @@ -2,12 +2,12 @@ //import com.casic.accessControl.feature.domain.Feature; import com.casic.accessControl.marker.domain.Marker; +import com.casic.accessControl.util.StringUtils; +import com.casic.accessControl.util.TimeFormat; import org.apache.commons.collections.CollectionUtils; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.List; +import java.text.ParseException; +import java.util.*; /** * Created by lenovo on 2016/5/16. @@ -43,6 +43,8 @@ private Long userId; private String area; private String line; + private String colorType; + private String photos; private String btnEdit = "编辑"; private String btnDelete = "删除"; @@ -296,6 +298,23 @@ this.area = area; } + public String getColorType() { + if (StringUtils.isEmpty(colorType)) return "0"; + return colorType; + } + + public void setColorType(String colorType) { + this.colorType = colorType; + } + + public String getPhotos() { + return photos; + } + + public void setPhotos(String photos) { + this.photos = photos; + } + public String getLine() { return line; } @@ -335,6 +354,52 @@ result.setRoad(doNullChange(marker.getRoad())); result.setArea(doNullChange(marker.getArea())); result.setLine(doNullChange(marker.getLine())); + result.setColorType(marker.getColorType()); + result.setPhotos(marker.getPhotos()); + return result; + } + + public static Marker convert2Marker(MarkerDto markerDto) { + if (markerDto == null) return null; + Marker result = new Marker(); + if(markerDto.getLongitude()==null||markerDto.getLatitude()==null) return null; + if (null != markerDto.getCreateTime() && markerDto.getCreateTime().length() == 19) { + try { + result.setCreateTime(TimeFormat.parse(markerDto.getCreateTime(), "yyyy-MM-dd HH:mm:ss")); + } catch (ParseException pex) { + result.setCreateTime(Calendar.getInstance().getTime()); + } + } else { + result.setCreateTime(Calendar.getInstance().getTime()); + } + result.setDepth(doNullChange(markerDto.getDepth())); + result.setId(markerDto.getId()); + result.setLatitude(markerDto.getLatitude()); + result.setLongitude(markerDto.getLongitude()); + result.setMarkerId(markerDto.getMarkerId()); + result.setMarkerDepth(doNullChange(markerDto.getMarkerDepth())); + result.setMarkerObjectId(doNullChange(markerDto.getMarkerObjectId())); + result.setMarkerObjectType(doNullChange(markerDto.getMarkerObjectType())); + result.setOwnerComp(doNullChange(markerDto.getOwnerComp())); + result.setIsValid(markerDto.getIsValid()); + result.setMemo(doNullChange(markerDto.getMemo())); + result.setPipeDiameter(doNullChange(markerDto.getPipeDiameter())); + result.setPipeMaterial(doNullChange(markerDto.getPipeMaterial())); + result.setMarkerType(doNullChange(markerDto.getMarkerType())); + result.setCreator(doNullChange(markerDto.getCreator())); + + result.setLayStyle(doNullChange(markerDto.getLayStyle())); + result.setBelowDepth(doNullChange(markerDto.getBelowDepth())); + result.setBelowDiameter(doNullChange(markerDto.getBelowDiameter())); + result.setBelowMaterial(doNullChange(markerDto.getBelowMaterial())); + result.setBelowType(doNullChange(markerDto.getBelowType())); + result.setConstructTime(doNullChange(markerDto.getConstructTime())); + result.setRecordType(markerDto.getRecordType()); + result.setRoad(doNullChange(markerDto.getRoad())); + result.setArea(doNullChange(markerDto.getArea())); + result.setLine(doNullChange(markerDto.getLine())); + result.setColorType(markerDto.getColorType()); + result.setPhotos(markerDto.getPhotos()); return result; } diff --git a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java index dd0fa4b..ba5a1fb 100644 --- a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java +++ b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java @@ -9,10 +9,7 @@ import com.casic.accessControl.marker.domain.Marker; import com.casic.accessControl.user.domain.Company; import com.casic.accessControl.user.domain.User; -import com.casic.accessControl.util.DataTable; -import com.casic.accessControl.util.DataTableParameter; -import com.casic.accessControl.util.DataTableUtils; -import com.casic.accessControl.util.DateUtils; +import com.casic.accessControl.util.*; import com.google.gson.Gson; import jxl.*; import jxl.read.biff.BiffException; @@ -31,11 +28,15 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; +import sun.misc.BASE64Decoder; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.File; +import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.text.ParseException; @@ -183,6 +184,53 @@ } /** + * 保存标识器和图片信息 + * @param markerDto + * @param companyId + * @param fileNames + * @param fileBuffers + * @return + */ + public boolean saveMarkerAndPhotos(MarkerDto markerDto, Long companyId, String[] fileNames, String[] fileBuffers) { + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + String strDirPath = request.getSession().getServletContext().getRealPath(""); + FileOutputStream fos = null; + String month = TimeFormat.format(Calendar.getInstance().getTime(), "yyyyMM"); + String webPath = "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String toDir = strDirPath + "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String filePaths = ""; + try { + for (int i = 0; i < fileBuffers.length; i++) { + if (fileBuffers[i] != null && fileNames[i] != null) { +// filePaths += toDir+fileNames[i]+","; + filePaths += webPath + fileNames[i] + ","; + byte[] buffer = new BASE64Decoder().decodeBuffer(fileBuffers[i]); //对android传过来的图片字符串进行解码 + File destDir = new File(toDir); + if (!destDir.exists()) + destDir.mkdirs(); + File imageFile = new File(destDir, fileNames[i]); + fos = new FileOutputStream(imageFile); //保存图片 + fos.write(buffer); + fos.flush(); + fos.close(); + } + } + if (filePaths.endsWith(",")) { + filePaths = filePaths.substring(0, filePaths.length() - 1); + } + } catch (Exception e) { + return false; + } + Marker marker = MarkerDto.convert2Marker(markerDto); + marker.setIsValid(1); + marker.setCompanyId(companyId); + marker.setPhotos(filePaths); + save(marker); + return true; + + } + + /** * 新增标识器 8-9 * * @param markers @@ -582,7 +630,7 @@ "所属区域","所属线路","所属道路","建设年代","权属单位","标示对象ID", "标识器ID","标识器类型","标识器埋深","安装部门","经度", "纬度", "最后修改时间","备注","下层管种类", "下层管埋深", - "下层管直径", "下层管材料", "标识对象类别"}; + "下层管直径", "下层管材料", "标识对象类别", "标识点颜色", "图片地址"}; Label[][] labels = new Label[markerDtos.size() + 1][titleTxt.length]; for(int k=0;k saveMarkerAndPhotos(@RequestParam(value = "fileBuffer1", required = false) MultipartFile fileBuffer1, + @RequestParam(value = "fileBuffer2", required = false) MultipartFile fileBuffer2, + @RequestParam(value = "fileBuffer3", required = false) MultipartFile fileBuffer3, + @RequestParam(value = "jsonMarker", required = true) String jsonMarker) { + Map map = new HashMap(); + map.put("message", "安装无标识器信息"); + Gson gson = new Gson(); + try { + MarkerDto marker = gson.fromJson(jsonMarker, MarkerDto.class); + + if (null == marker.getMarkerId()) { + map.put("message", "无标识器ID"); + map.put("success", "false"); + return map; + } else if (markerManager.getMarkerByMarkerId(marker.getMarkerId()).size() > 0) { + map.put("message", "已安装过该标识器[" + marker.getMarkerId() + "]"); + map.put("success", "false"); + return map; + } else { + String[] fileNames = new String[3]; + String[] fileBuffers = new String[3]; + if (fileBuffer1 != null) { + fileNames[0] = marker.getMarkerId() + "_" + fileBuffer1.getOriginalFilename(); + byte[] fis = fileBuffer1.getBytes(); + fileBuffers[0] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, com.sun.org.apache.xml.internal.security.utils.Base64.BASE64DEFAULTLENGTH)); + } + if (fileBuffer2 != null) { + fileNames[1] = marker.getMarkerId() + "_" + fileBuffer2.getOriginalFilename(); + byte[] fis = fileBuffer2.getBytes(); + fileBuffers[1] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, com.sun.org.apache.xml.internal.security.utils.Base64.BASE64DEFAULTLENGTH)); + } + if (fileBuffer3 != null) { + fileNames[2] = marker.getMarkerId() + "_" + fileBuffer3.getOriginalFilename(); + byte[] fis = fileBuffer3.getBytes(); + fileBuffers[2] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, Base64.BASE64DEFAULTLENGTH)); + } + Long companyId = marker.getCompanyId(); + if (companyId == null) { + return map; + } + boolean result = markerManager.saveMarkerAndPhotos(marker, companyId, fileNames, fileBuffers); + if (!result) { + return map; + } + } + } catch (Exception e) { + return map; + } + map.put("success", "true"); + map.put("message", "保存成功"); + return map; + } + + @RequestMapping("marker-info-delete") @ResponseBody public Map delete(@RequestParam(value = "id", required = true) Long id) { @@ -144,6 +208,9 @@ map.put("message", "删除需要ID信息"); return map; } + + System.out.println(ids); + markerManager.delMarkerByIds(ids); map.put("success", true); map.put("message", "删除成功"); @@ -240,6 +307,54 @@ return map; } + /** + * 批量上传标识点,用于无信号地区标识器信息统一上传,不修改已有标识点信息 + * @param strMarkers + * @return + */ + @RequestMapping("batch-save-no-update") + @ResponseBody + public Map batchSaveOrUpdate(@RequestParam(value = "markers", required = true) String strMarkers) { + strMarkers = strMarkers.replace('\n',' '); + Map map = new HashMap(); + map.put("message", "批量导入失败,或无导入标识器信息"); + Gson gson = new Gson(); + try { + List markers = gson.fromJson(strMarkers, new TypeToken>() { + }.getType()); + if (CollectionUtils.isEmpty(markers)) {//批量导入数据不存在,直接返回 + map.put("message", "批量导入数据不存在"); + return map; + } + + Long companyId = markers.get(0).getCompanyId(); + if (companyId == null) { + map.put("message", "未找到所属公司属性"); + return map; + } + + List markerDtoForSave = new ArrayList(); + for (MarkerDto markerDto : markers) { + // 上传marker的Id不为空且数据库中不存在记录,经纬度不为空,允许保存 + if (StringUtils.isNotBlank(markerDto.getMarkerId()) && markerManager.getMarkerByMarkerId(markerDto.getMarkerId()).size() <= 0) { + if (null != markerDto.getLongitude() && null != markerDto.getLatitude()) { + markerDtoForSave.add(markerDto); + } + } + } + boolean result = markerManager.batchSave(markerDtoForSave, companyId); + if (!result) { + return map; + } + } catch (Exception e) { + e.printStackTrace(); + return map; + } + map.put("success", true); + map.put("message", "保存成功"); + return map; + } + @RequestMapping("getMarkerListByCondition") @ResponseBody @POST diff --git a/src/main/java/com/casic/accessControl/user/web/UserController.java b/src/main/java/com/casic/accessControl/user/web/UserController.java index feab678..3534a97 100644 --- a/src/main/java/com/casic/accessControl/user/web/UserController.java +++ b/src/main/java/com/casic/accessControl/user/web/UserController.java @@ -46,6 +46,7 @@ @ResponseBody public Map login(@ModelAttribute User userInfo, HttpSession session) { Map result = new HashMap(); + User user = null; try{ user = userManager.login(userInfo); diff --git a/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java b/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java new file mode 100644 index 0000000..582120f --- /dev/null +++ b/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java @@ -0,0 +1,129 @@ +package com.casic.accessControl.util; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.net.URL; +import java.net.URLConnection; +import java.util.List; +import java.util.Map; + +/** + * Created by lenovo on 2016/8/31. + */ +public class HttpRequestUtils { + + /** + * 向指定URL发送GET方法的请求 + * + * @param url + * 发送请求的URL + * @param param + * 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 + * @return URL 所代表远程资源的响应结果 + */ + public static String sendGet(String url, String param) { + String result = ""; + BufferedReader in = null; + try { + String urlNameString = url + "?" + param; + URL realUrl = new URL(urlNameString); + // 打开和URL之间的连接 + URLConnection connection = realUrl.openConnection(); + // 设置通用的请求属性 + connection.setRequestProperty("accept", "*/*"); + connection.setRequestProperty("connection", "Keep-Alive"); + connection.setRequestProperty("user-agent", + "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + // 建立实际的连接 + connection.connect(); + // 获取所有响应头字段 + Map> map = connection.getHeaderFields(); + // 遍历所有的响应头字段 + for (String key : map.keySet()) { + System.out.println(key + "--->" + map.get(key)); + } + // 定义 BufferedReader输入流来读取URL的响应 + in = new BufferedReader(new InputStreamReader( + connection.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + result += line; + } + } catch (Exception e) { + System.out.println("发送GET请求出现异常!" + e); + e.printStackTrace(); + } + // 使用finally块来关闭输入流 + finally { + try { + if (in != null) { + in.close(); + } + } catch (Exception e2) { + e2.printStackTrace(); + } + } + return result; + } + + /** + * 向指定 URL 发送POST方法的请求 + * + * @param url + * 发送请求的 URL + * @param param + * 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 + * @return 所代表远程资源的响应结果 + */ + public static String sendPost(String url, String param) { + PrintWriter out = null; + BufferedReader in = null; + String result = ""; + try { + URL realUrl = new URL(url); + // 打开和URL之间的连接 + URLConnection conn = realUrl.openConnection(); + // 设置通用的请求属性 + conn.setRequestProperty("accept", "*/*"); + conn.setRequestProperty("connection", "Keep-Alive"); + conn.setRequestProperty("user-agent", + "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + // 发送POST请求必须设置如下两行 + conn.setDoOutput(true); + conn.setDoInput(true); + // 获取URLConnection对象对应的输出流 + out = new PrintWriter(conn.getOutputStream()); + // 发送请求参数 + out.print(param); + // flush输出流的缓冲 + out.flush(); + // 定义BufferedReader输入流来读取URL的响应 + in = new BufferedReader( + new InputStreamReader(conn.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + result += line; + } + } catch (Exception e) { + System.out.println("发送 POST 请求出现异常!"+e); + e.printStackTrace(); + } + //使用finally块来关闭输出流、输入流 + finally{ + try{ + if(out!=null){ + out.close(); + } + if(in!=null){ + in.close(); + } + } + catch(IOException ex){ + ex.printStackTrace(); + } + } + return result; + } + } \ No newline at end of file diff --git a/src/main/java/com/casic/accessControl/util/TimeFormat.java b/src/main/java/com/casic/accessControl/util/TimeFormat.java new file mode 100644 index 0000000..e9168d5 --- /dev/null +++ b/src/main/java/com/casic/accessControl/util/TimeFormat.java @@ -0,0 +1,148 @@ +package com.casic.accessControl.util; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +/** + * 格式化日期工具类 + * 默认模式yyyy-MM-dd HH:mm:ss + * @author Administrator + * + */ +public class TimeFormat { + + private static final String DATE_FORMAT_STRING = "yyyy-MM-dd"; + private static final String TIME_FORMAT_STRING = "HH:mm:ss"; + private static final String TIMESTAMP_FORMAT_STRING = "yyyy-MM-dd HH:mm:ss"; + + // 默认格式化格式 + private static SimpleDateFormat defaultFormat = new SimpleDateFormat(TIMESTAMP_FORMAT_STRING); + + public static void setFormatString(String pattern) { + defaultFormat.applyPattern(pattern); + } + + /** + * 默认格式化日期 + * + * @param Date date + * @return String + */ + public static String format(Date date) { + return defaultFormat.format(date); + } + + /** + * 日期格式化 + * + * @param date + * @return + */ + public static String formatDate(Date date) { + return TimeFormat.format(date, DATE_FORMAT_STRING); + } + + /** + * 时间格式化 + * + * @param date + * @return + */ + public static String formatTime(Date date) { + return TimeFormat.format(date, TIME_FORMAT_STRING); + } + + /** + * 时间戳格式化 + * + * @param date + * @return + */ + public static String formatTimestamp(Date date) { + return TimeFormat.format(date, TIMESTAMP_FORMAT_STRING); + } + + /** + * 以指定模式格式化日期 + * + * @param Date date + * @param String pattern + * @return String + */ + public static String format(Date date, String pattern) { + SimpleDateFormat formatter = new SimpleDateFormat(pattern); + return formatter.format(date); + } + + /** + * 根据起止日期生成日期序列 + * 包括start和end的日期 + * + * @param start + * @param end + * @return + */ + public static List generateDates(String start, String end) throws ParseException { + List dates = new ArrayList(); + Calendar s = Calendar.getInstance(); + Calendar e = Calendar.getInstance(); + s.setTime(TimeFormat.parse(start, DATE_FORMAT_STRING)); + s.set(Calendar.HOUR_OF_DAY, 0); + s.set(Calendar.MINUTE, 0); + s.set(Calendar.SECOND, 0); + e.setTime(TimeFormat.parse(end, DATE_FORMAT_STRING)); + e.set(Calendar.HOUR_OF_DAY, 0); + e.set(Calendar.MINUTE, 0); + e.set(Calendar.SECOND, 0); + while (s.before(e) == true) { + dates.add(TimeFormat.formatDate(s.getTime())); + s.add(Calendar.DATE, 1); + } + + dates.add(end); + return dates; + } + + + /** + * 解析日期字符串 + * + * @param String source + * @return Date + * + * @throws ParseException + */ + public static Date parse(String source) throws ParseException { + return defaultFormat.parse(source); + } + + /** + * 以指定模式解析日期 + * + * @param String source + * @param String pattern + * @return Date + * + * @throws ParseException + */ + public static Date parse(String source, String pattern) throws ParseException { + SimpleDateFormat formatter = new SimpleDateFormat(pattern); + return formatter.parse(source); + } + + + public static Date parseDateWithoutTime(String source) throws ParseException { + SimpleDateFormat formatter = new SimpleDateFormat(DATE_FORMAT_STRING); + Calendar date = Calendar.getInstance(); + date.setTime(formatter.parse(source)); + date.set(Calendar.HOUR, 0); + date.set(Calendar.HOUR, 0); + date.set(Calendar.MINUTE, 0); + return date.getTime(); + } + +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 53c91ea..cea976f 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -15,19 +15,17 @@ # ============================================================================ # db # ============================================================================ -#db.default.driverClassName=oracle.jdbc.driver.OracleDriver -#db.default.url=jdbc:oracle:thin:@192.168.0.203:1521:SZHTDB2 -#db.default.username=scott -#db.default.password=SZHTDB2 db.default.driverClassName=com.mysql.jdbc.Driver -db.default.url=jdbc:mysql://127.0.0.1:3306/ems?useUnicode=true&characterEncoding=UTF-8 -db.default.username=emsweb -db.default.password=emsweb +db.default.url=jdbc:mysql://127.0.0.1:3306/ems_tong?useUnicode=true&characterEncoding=UTF-8 +db.default.username=root +db.default.password=root +#db.default.username=emsweb +#db.default.password=emsweb #db.default.url=jdbc:mysql://119.254.110.71:3307/ems?useUnicode=true&characterEncoding=UTF-8 #db.default.username=root #db.default.password=rootems - -# ============================================================================ +# +## ============================================================================ # log4jdbc # ============================================================================ log4jdbc.enable=true diff --git a/src/main/resources/spring/applicationContext-filter.xml b/src/main/resources/spring/applicationContext-filter.xml index a08c5fc..98ac7d6 100644 --- a/src/main/resources/spring/applicationContext-filter.xml +++ b/src/main/resources/spring/applicationContext-filter.xml @@ -35,9 +35,13 @@ /user/ill-login.do /marker/exportMarker.do /marker/batchSave-na.do + /marker/batch-save-no-update.do + /marker/save-marker-photo.do /event/save-event.do /task/get-task.do + /app/get-latest-version.do /xls/* + /apk/* diff --git a/src/main/resources/spring/applicationContext-hibernate.xml b/src/main/resources/spring/applicationContext-hibernate.xml index 5bb1a7e..dc54192 100644 --- a/src/main/resources/spring/applicationContext-hibernate.xml +++ b/src/main/resources/spring/applicationContext-hibernate.xml @@ -65,6 +65,7 @@ com.casic.accessControl.task.domain.Position com.casic.accessControl.event.domain.Event com.casic.accessControl.marker.domain.OptionItem + com.casic.accessControl.app.domain.ApkVersion diff --git a/src/main/webapp/common/layout/menu_new.jsp b/src/main/webapp/common/layout/menu_new.jsp index 3cf4b4e..cbd822e 100644 --- a/src/main/webapp/common/layout/menu_new.jsp +++ b/src/main/webapp/common/layout/menu_new.jsp @@ -20,7 +20,7 @@
                    • - + @@ -54,7 +54,7 @@
                    • - + diff --git a/src/main/webapp/content/ems/ems-gd.jsp b/src/main/webapp/content/ems/ems-gd.jsp new file mode 100644 index 0000000..5137b49 --- /dev/null +++ b/src/main/webapp/content/ems/ems-gd.jsp @@ -0,0 +1,604 @@ +<%@page contentType="text/html;charset=UTF-8" %> + +<%@include file="/taglibs.jsp" %> + +<%pageContext.setAttribute("currentMenu", "ems");%> + + + + + + + + + + + + + 地下管线电子标识系统 + + + + + + + + + + + + + + + + + + +<%-- + +--%> + + + + + + + + + + + + + + +<%@include file="/common/layout/header.jsp" %> + +
                      + + + + <%@include file="/common/layout/menu_new.jsp" %> + + + +
                      + + + +
                      + +
                      + + +
                      +
                      +
                      +
                      + +
                      +
                      + +
                      +
                      + +
                      +
                      + +
                      +
                      + +
                      + +
                      + +
                      + +
                      + +
                      + +
                      +
                      +
                      + + + + +
                      +
                      +
                      +
                      + + + + +
                      +
                      +
                      + +
                      + +
                      + +<%--todo list:错误使用方法 + +--%> +
                      + +
                      +
                      + +
                      + +
                      + +
                      + + +
                      + +
                      + + 移动 + 绘制区域 + 新增标识器 + 删除标识器 + 保存标识器 + 批量导入 + 导出Excel + 清空 + +
                      + +
                      +
                      + +
                      + + + +
                      + +
                      + +
                      + + + + +
                      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/webapp/content/task/task-gd.jsp b/src/main/webapp/content/task/task-gd.jsp new file mode 100644 index 0000000..d2d5549 --- /dev/null +++ b/src/main/webapp/content/task/task-gd.jsp @@ -0,0 +1,374 @@ +<%@page contentType="text/html;charset=UTF-8" %> + +<%@include file="/taglibs.jsp" %> + +<%pageContext.setAttribute("currentMenu", "task");%> + + + + + + + + + + + + + 地下管线电子标识系统 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +<%@include file="/common/layout/header.jsp" %> + +
                      + + + + <%@include file="/common/layout/menu_new.jsp" %> + + + +
                      + + + +
                      + +
                      + +
                      + + 移动 + 绘制区域 + 选择多点创建工单 + 清空选择 + +
                      + +
                      + +
                      + + +
                      + +
                      + +
                      + +
                      历史工单
                      + +
                      + +
                      + +
                      + <%--巡检员:--%> +
                      +
                      + + +
                      +
                      + + +
                        +
                      +
                        +
                        + +
                        + +
                        + +
                        + +
                        +
                        + +
                        + + + +
                        + +
                        + +
                        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/webapp/images/drop/0.png b/src/main/webapp/images/drop/0.png new file mode 100644 index 0000000..f4b966b --- /dev/null +++ b/src/main/webapp/images/drop/0.png Binary files differ diff --git a/src/main/webapp/images/drop/1.png b/src/main/webapp/images/drop/1.png new file mode 100644 index 0000000..9284b64 --- /dev/null +++ b/src/main/webapp/images/drop/1.png Binary files differ diff --git a/src/main/webapp/images/drop/2.png b/src/main/webapp/images/drop/2.png new file mode 100644 index 0000000..b5425db --- /dev/null +++ b/src/main/webapp/images/drop/2.png Binary files differ diff --git a/src/main/webapp/images/drop/3.png b/src/main/webapp/images/drop/3.png new file mode 100644 index 0000000..dd09655 --- /dev/null +++ b/src/main/webapp/images/drop/3.png Binary files differ diff --git a/src/main/webapp/images/drop/4.png b/src/main/webapp/images/drop/4.png new file mode 100644 index 0000000..50cf1f7 --- /dev/null +++ b/src/main/webapp/images/drop/4.png Binary files differ diff --git a/src/main/webapp/images/drop/5.png b/src/main/webapp/images/drop/5.png new file mode 100644 index 0000000..a2029bd --- /dev/null +++ b/src/main/webapp/images/drop/5.png Binary files differ diff --git a/src/main/webapp/images/drop/6.png b/src/main/webapp/images/drop/6.png new file mode 100644 index 0000000..b53248a --- /dev/null +++ b/src/main/webapp/images/drop/6.png Binary files differ diff --git a/src/main/webapp/images/ems/point.png b/src/main/webapp/images/ems/point.png new file mode 100644 index 0000000..a814351 --- /dev/null +++ b/src/main/webapp/images/ems/point.png Binary files differ diff --git a/src/main/webapp/images/ems/rect.png b/src/main/webapp/images/ems/rect.png new file mode 100644 index 0000000..99d0c9e --- /dev/null +++ b/src/main/webapp/images/ems/rect.png Binary files differ diff --git a/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java new file mode 100644 index 0000000..634ceae --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java @@ -0,0 +1,46 @@ +package com.casic.accessControl.app.domain; + +import javax.persistence.*; +import java.util.Date; + +/** + * app的版本信息 + */ +//工单 +@Entity +@Table(name = "apkVersion") +public class ApkVersion { + private String version; + private String path; + private Date ts;//时间戳 + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "version") + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + @Column(name = "path") + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + @Column(name = "ts") + public Date getTs() { + return ts; + } + + public void setTs(Date ts) { + this.ts = ts; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java new file mode 100644 index 0000000..1d0242a --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java @@ -0,0 +1,50 @@ +package com.casic.accessControl.app.dto; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.util.TimeFormat; + +/** + * Created by lenovo on 2016/4/13. + */ +public class ApkVersionDto { + private String version; + private String path; + private String ts; + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public String getTs() { + return ts; + } + + public void setTs(String ts) { + this.ts = ts; + } + + public static ApkVersionDto Convert(ApkVersion version) { + if (version == null) { + return null; + } + ApkVersionDto versionDto = new ApkVersionDto(); + versionDto.setVersion(version.getVersion()); + versionDto.setPath(version.getVersion()); + versionDto.setTs(TimeFormat.formatTimestamp(version.getTs())); + + return versionDto; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java b/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java new file mode 100644 index 0000000..28b12a7 --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java @@ -0,0 +1,27 @@ +package com.casic.accessControl.app.manager; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.core.hibernate.HibernateEntityDao; +import org.hibernate.Query; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * + */ +@Service("apkVersionManager") +public class ApkVersionManager extends HibernateEntityDao { + + public ApkVersion getLatestVersion() { + String sql = "from ApkVersion order by ts desc"; + Query query = getSession().createQuery(sql); + List list = query.list(); + if (null != list && list.isEmpty() == false) { + return list.get(0); + } + + return null; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java b/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java new file mode 100644 index 0000000..065d3cc --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java @@ -0,0 +1,66 @@ +package com.casic.accessControl.app.web; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.app.manager.ApkVersionManager; +import com.casic.accessControl.marker.domain.Marker; +import com.casic.accessControl.marker.manager.MarkerManager; +import com.casic.accessControl.task.domain.Task; +import com.casic.accessControl.task.domain.TaskDetail; +import com.casic.accessControl.task.dto.TaskDetailDto; +import com.casic.accessControl.task.dto.TaskDto; +import com.casic.accessControl.task.dto.TaskStatus; +import com.casic.accessControl.task.manager.TaskDetailManager; +import com.casic.accessControl.task.manager.TaskManager; +import com.casic.accessControl.user.domain.Company; +import com.casic.accessControl.user.domain.Role; +import com.casic.accessControl.user.domain.User; +import com.casic.accessControl.user.dto.UserDto; +import com.casic.accessControl.user.manager.RoleManager; +import com.casic.accessControl.user.manager.UserManager; +import com.casic.accessControl.util.DataTable; +import com.casic.accessControl.util.StringUtils; +import com.google.gson.Gson; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +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.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * Created by lenovo on 2016/4/13. + */ +@Controller +@RequestMapping("app") +public class ApkVersionController { + + @Resource + private ApkVersionManager apkVersionManager; + + @RequestMapping("get-latest-version") + @ResponseBody + public Map getLatestVersion(HttpServletResponse response, HttpSession session) { + Map result = new HashMap(); + try { + ApkVersion latest = apkVersionManager.getLatestVersion(); + if (null != latest) { + result.put("version", latest.getVersion()); + result.put("path", latest.getPath()); + } else { + result.put("version", "1.0.0"); + } + } catch (Exception e) { + e.printStackTrace(); + result.put("version", "1.0.0"); + } + + return result; + } + +} diff --git a/src/main/java/com/casic/accessControl/marker/domain/Marker.java b/src/main/java/com/casic/accessControl/marker/domain/Marker.java index 0575cfe..7d5b854 100644 --- a/src/main/java/com/casic/accessControl/marker/domain/Marker.java +++ b/src/main/java/com/casic/accessControl/marker/domain/Marker.java @@ -67,6 +67,10 @@ private String area; @Column(name = "line") private String line; + @Column(name = "colorType") + private String colorType; + @Column(name = "photos") + private String photos; @@ -315,4 +319,20 @@ public void setArea(String area) { this.area = area; } + + public String getColorType() { + return colorType; + } + + public void setColorType(String colorType) { + this.colorType = colorType; + } + + public String getPhotos() { + return photos; + } + + public void setPhotos(String photos) { + this.photos = photos; + } } diff --git a/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java b/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java index 506f31d..c5f8cf5 100644 --- a/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java +++ b/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java @@ -2,12 +2,12 @@ //import com.casic.accessControl.feature.domain.Feature; import com.casic.accessControl.marker.domain.Marker; +import com.casic.accessControl.util.StringUtils; +import com.casic.accessControl.util.TimeFormat; import org.apache.commons.collections.CollectionUtils; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.List; +import java.text.ParseException; +import java.util.*; /** * Created by lenovo on 2016/5/16. @@ -43,6 +43,8 @@ private Long userId; private String area; private String line; + private String colorType; + private String photos; private String btnEdit = "编辑"; private String btnDelete = "删除"; @@ -296,6 +298,23 @@ this.area = area; } + public String getColorType() { + if (StringUtils.isEmpty(colorType)) return "0"; + return colorType; + } + + public void setColorType(String colorType) { + this.colorType = colorType; + } + + public String getPhotos() { + return photos; + } + + public void setPhotos(String photos) { + this.photos = photos; + } + public String getLine() { return line; } @@ -335,6 +354,52 @@ result.setRoad(doNullChange(marker.getRoad())); result.setArea(doNullChange(marker.getArea())); result.setLine(doNullChange(marker.getLine())); + result.setColorType(marker.getColorType()); + result.setPhotos(marker.getPhotos()); + return result; + } + + public static Marker convert2Marker(MarkerDto markerDto) { + if (markerDto == null) return null; + Marker result = new Marker(); + if(markerDto.getLongitude()==null||markerDto.getLatitude()==null) return null; + if (null != markerDto.getCreateTime() && markerDto.getCreateTime().length() == 19) { + try { + result.setCreateTime(TimeFormat.parse(markerDto.getCreateTime(), "yyyy-MM-dd HH:mm:ss")); + } catch (ParseException pex) { + result.setCreateTime(Calendar.getInstance().getTime()); + } + } else { + result.setCreateTime(Calendar.getInstance().getTime()); + } + result.setDepth(doNullChange(markerDto.getDepth())); + result.setId(markerDto.getId()); + result.setLatitude(markerDto.getLatitude()); + result.setLongitude(markerDto.getLongitude()); + result.setMarkerId(markerDto.getMarkerId()); + result.setMarkerDepth(doNullChange(markerDto.getMarkerDepth())); + result.setMarkerObjectId(doNullChange(markerDto.getMarkerObjectId())); + result.setMarkerObjectType(doNullChange(markerDto.getMarkerObjectType())); + result.setOwnerComp(doNullChange(markerDto.getOwnerComp())); + result.setIsValid(markerDto.getIsValid()); + result.setMemo(doNullChange(markerDto.getMemo())); + result.setPipeDiameter(doNullChange(markerDto.getPipeDiameter())); + result.setPipeMaterial(doNullChange(markerDto.getPipeMaterial())); + result.setMarkerType(doNullChange(markerDto.getMarkerType())); + result.setCreator(doNullChange(markerDto.getCreator())); + + result.setLayStyle(doNullChange(markerDto.getLayStyle())); + result.setBelowDepth(doNullChange(markerDto.getBelowDepth())); + result.setBelowDiameter(doNullChange(markerDto.getBelowDiameter())); + result.setBelowMaterial(doNullChange(markerDto.getBelowMaterial())); + result.setBelowType(doNullChange(markerDto.getBelowType())); + result.setConstructTime(doNullChange(markerDto.getConstructTime())); + result.setRecordType(markerDto.getRecordType()); + result.setRoad(doNullChange(markerDto.getRoad())); + result.setArea(doNullChange(markerDto.getArea())); + result.setLine(doNullChange(markerDto.getLine())); + result.setColorType(markerDto.getColorType()); + result.setPhotos(markerDto.getPhotos()); return result; } diff --git a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java index dd0fa4b..ba5a1fb 100644 --- a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java +++ b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java @@ -9,10 +9,7 @@ import com.casic.accessControl.marker.domain.Marker; import com.casic.accessControl.user.domain.Company; import com.casic.accessControl.user.domain.User; -import com.casic.accessControl.util.DataTable; -import com.casic.accessControl.util.DataTableParameter; -import com.casic.accessControl.util.DataTableUtils; -import com.casic.accessControl.util.DateUtils; +import com.casic.accessControl.util.*; import com.google.gson.Gson; import jxl.*; import jxl.read.biff.BiffException; @@ -31,11 +28,15 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; +import sun.misc.BASE64Decoder; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.File; +import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.text.ParseException; @@ -183,6 +184,53 @@ } /** + * 保存标识器和图片信息 + * @param markerDto + * @param companyId + * @param fileNames + * @param fileBuffers + * @return + */ + public boolean saveMarkerAndPhotos(MarkerDto markerDto, Long companyId, String[] fileNames, String[] fileBuffers) { + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + String strDirPath = request.getSession().getServletContext().getRealPath(""); + FileOutputStream fos = null; + String month = TimeFormat.format(Calendar.getInstance().getTime(), "yyyyMM"); + String webPath = "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String toDir = strDirPath + "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String filePaths = ""; + try { + for (int i = 0; i < fileBuffers.length; i++) { + if (fileBuffers[i] != null && fileNames[i] != null) { +// filePaths += toDir+fileNames[i]+","; + filePaths += webPath + fileNames[i] + ","; + byte[] buffer = new BASE64Decoder().decodeBuffer(fileBuffers[i]); //对android传过来的图片字符串进行解码 + File destDir = new File(toDir); + if (!destDir.exists()) + destDir.mkdirs(); + File imageFile = new File(destDir, fileNames[i]); + fos = new FileOutputStream(imageFile); //保存图片 + fos.write(buffer); + fos.flush(); + fos.close(); + } + } + if (filePaths.endsWith(",")) { + filePaths = filePaths.substring(0, filePaths.length() - 1); + } + } catch (Exception e) { + return false; + } + Marker marker = MarkerDto.convert2Marker(markerDto); + marker.setIsValid(1); + marker.setCompanyId(companyId); + marker.setPhotos(filePaths); + save(marker); + return true; + + } + + /** * 新增标识器 8-9 * * @param markers @@ -582,7 +630,7 @@ "所属区域","所属线路","所属道路","建设年代","权属单位","标示对象ID", "标识器ID","标识器类型","标识器埋深","安装部门","经度", "纬度", "最后修改时间","备注","下层管种类", "下层管埋深", - "下层管直径", "下层管材料", "标识对象类别"}; + "下层管直径", "下层管材料", "标识对象类别", "标识点颜色", "图片地址"}; Label[][] labels = new Label[markerDtos.size() + 1][titleTxt.length]; for(int k=0;k saveMarkerAndPhotos(@RequestParam(value = "fileBuffer1", required = false) MultipartFile fileBuffer1, + @RequestParam(value = "fileBuffer2", required = false) MultipartFile fileBuffer2, + @RequestParam(value = "fileBuffer3", required = false) MultipartFile fileBuffer3, + @RequestParam(value = "jsonMarker", required = true) String jsonMarker) { + Map map = new HashMap(); + map.put("message", "安装无标识器信息"); + Gson gson = new Gson(); + try { + MarkerDto marker = gson.fromJson(jsonMarker, MarkerDto.class); + + if (null == marker.getMarkerId()) { + map.put("message", "无标识器ID"); + map.put("success", "false"); + return map; + } else if (markerManager.getMarkerByMarkerId(marker.getMarkerId()).size() > 0) { + map.put("message", "已安装过该标识器[" + marker.getMarkerId() + "]"); + map.put("success", "false"); + return map; + } else { + String[] fileNames = new String[3]; + String[] fileBuffers = new String[3]; + if (fileBuffer1 != null) { + fileNames[0] = marker.getMarkerId() + "_" + fileBuffer1.getOriginalFilename(); + byte[] fis = fileBuffer1.getBytes(); + fileBuffers[0] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, com.sun.org.apache.xml.internal.security.utils.Base64.BASE64DEFAULTLENGTH)); + } + if (fileBuffer2 != null) { + fileNames[1] = marker.getMarkerId() + "_" + fileBuffer2.getOriginalFilename(); + byte[] fis = fileBuffer2.getBytes(); + fileBuffers[1] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, com.sun.org.apache.xml.internal.security.utils.Base64.BASE64DEFAULTLENGTH)); + } + if (fileBuffer3 != null) { + fileNames[2] = marker.getMarkerId() + "_" + fileBuffer3.getOriginalFilename(); + byte[] fis = fileBuffer3.getBytes(); + fileBuffers[2] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, Base64.BASE64DEFAULTLENGTH)); + } + Long companyId = marker.getCompanyId(); + if (companyId == null) { + return map; + } + boolean result = markerManager.saveMarkerAndPhotos(marker, companyId, fileNames, fileBuffers); + if (!result) { + return map; + } + } + } catch (Exception e) { + return map; + } + map.put("success", "true"); + map.put("message", "保存成功"); + return map; + } + + @RequestMapping("marker-info-delete") @ResponseBody public Map delete(@RequestParam(value = "id", required = true) Long id) { @@ -144,6 +208,9 @@ map.put("message", "删除需要ID信息"); return map; } + + System.out.println(ids); + markerManager.delMarkerByIds(ids); map.put("success", true); map.put("message", "删除成功"); @@ -240,6 +307,54 @@ return map; } + /** + * 批量上传标识点,用于无信号地区标识器信息统一上传,不修改已有标识点信息 + * @param strMarkers + * @return + */ + @RequestMapping("batch-save-no-update") + @ResponseBody + public Map batchSaveOrUpdate(@RequestParam(value = "markers", required = true) String strMarkers) { + strMarkers = strMarkers.replace('\n',' '); + Map map = new HashMap(); + map.put("message", "批量导入失败,或无导入标识器信息"); + Gson gson = new Gson(); + try { + List markers = gson.fromJson(strMarkers, new TypeToken>() { + }.getType()); + if (CollectionUtils.isEmpty(markers)) {//批量导入数据不存在,直接返回 + map.put("message", "批量导入数据不存在"); + return map; + } + + Long companyId = markers.get(0).getCompanyId(); + if (companyId == null) { + map.put("message", "未找到所属公司属性"); + return map; + } + + List markerDtoForSave = new ArrayList(); + for (MarkerDto markerDto : markers) { + // 上传marker的Id不为空且数据库中不存在记录,经纬度不为空,允许保存 + if (StringUtils.isNotBlank(markerDto.getMarkerId()) && markerManager.getMarkerByMarkerId(markerDto.getMarkerId()).size() <= 0) { + if (null != markerDto.getLongitude() && null != markerDto.getLatitude()) { + markerDtoForSave.add(markerDto); + } + } + } + boolean result = markerManager.batchSave(markerDtoForSave, companyId); + if (!result) { + return map; + } + } catch (Exception e) { + e.printStackTrace(); + return map; + } + map.put("success", true); + map.put("message", "保存成功"); + return map; + } + @RequestMapping("getMarkerListByCondition") @ResponseBody @POST diff --git a/src/main/java/com/casic/accessControl/user/web/UserController.java b/src/main/java/com/casic/accessControl/user/web/UserController.java index feab678..3534a97 100644 --- a/src/main/java/com/casic/accessControl/user/web/UserController.java +++ b/src/main/java/com/casic/accessControl/user/web/UserController.java @@ -46,6 +46,7 @@ @ResponseBody public Map login(@ModelAttribute User userInfo, HttpSession session) { Map result = new HashMap(); + User user = null; try{ user = userManager.login(userInfo); diff --git a/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java b/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java new file mode 100644 index 0000000..582120f --- /dev/null +++ b/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java @@ -0,0 +1,129 @@ +package com.casic.accessControl.util; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.net.URL; +import java.net.URLConnection; +import java.util.List; +import java.util.Map; + +/** + * Created by lenovo on 2016/8/31. + */ +public class HttpRequestUtils { + + /** + * 向指定URL发送GET方法的请求 + * + * @param url + * 发送请求的URL + * @param param + * 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 + * @return URL 所代表远程资源的响应结果 + */ + public static String sendGet(String url, String param) { + String result = ""; + BufferedReader in = null; + try { + String urlNameString = url + "?" + param; + URL realUrl = new URL(urlNameString); + // 打开和URL之间的连接 + URLConnection connection = realUrl.openConnection(); + // 设置通用的请求属性 + connection.setRequestProperty("accept", "*/*"); + connection.setRequestProperty("connection", "Keep-Alive"); + connection.setRequestProperty("user-agent", + "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + // 建立实际的连接 + connection.connect(); + // 获取所有响应头字段 + Map> map = connection.getHeaderFields(); + // 遍历所有的响应头字段 + for (String key : map.keySet()) { + System.out.println(key + "--->" + map.get(key)); + } + // 定义 BufferedReader输入流来读取URL的响应 + in = new BufferedReader(new InputStreamReader( + connection.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + result += line; + } + } catch (Exception e) { + System.out.println("发送GET请求出现异常!" + e); + e.printStackTrace(); + } + // 使用finally块来关闭输入流 + finally { + try { + if (in != null) { + in.close(); + } + } catch (Exception e2) { + e2.printStackTrace(); + } + } + return result; + } + + /** + * 向指定 URL 发送POST方法的请求 + * + * @param url + * 发送请求的 URL + * @param param + * 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 + * @return 所代表远程资源的响应结果 + */ + public static String sendPost(String url, String param) { + PrintWriter out = null; + BufferedReader in = null; + String result = ""; + try { + URL realUrl = new URL(url); + // 打开和URL之间的连接 + URLConnection conn = realUrl.openConnection(); + // 设置通用的请求属性 + conn.setRequestProperty("accept", "*/*"); + conn.setRequestProperty("connection", "Keep-Alive"); + conn.setRequestProperty("user-agent", + "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + // 发送POST请求必须设置如下两行 + conn.setDoOutput(true); + conn.setDoInput(true); + // 获取URLConnection对象对应的输出流 + out = new PrintWriter(conn.getOutputStream()); + // 发送请求参数 + out.print(param); + // flush输出流的缓冲 + out.flush(); + // 定义BufferedReader输入流来读取URL的响应 + in = new BufferedReader( + new InputStreamReader(conn.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + result += line; + } + } catch (Exception e) { + System.out.println("发送 POST 请求出现异常!"+e); + e.printStackTrace(); + } + //使用finally块来关闭输出流、输入流 + finally{ + try{ + if(out!=null){ + out.close(); + } + if(in!=null){ + in.close(); + } + } + catch(IOException ex){ + ex.printStackTrace(); + } + } + return result; + } + } \ No newline at end of file diff --git a/src/main/java/com/casic/accessControl/util/TimeFormat.java b/src/main/java/com/casic/accessControl/util/TimeFormat.java new file mode 100644 index 0000000..e9168d5 --- /dev/null +++ b/src/main/java/com/casic/accessControl/util/TimeFormat.java @@ -0,0 +1,148 @@ +package com.casic.accessControl.util; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +/** + * 格式化日期工具类 + * 默认模式yyyy-MM-dd HH:mm:ss + * @author Administrator + * + */ +public class TimeFormat { + + private static final String DATE_FORMAT_STRING = "yyyy-MM-dd"; + private static final String TIME_FORMAT_STRING = "HH:mm:ss"; + private static final String TIMESTAMP_FORMAT_STRING = "yyyy-MM-dd HH:mm:ss"; + + // 默认格式化格式 + private static SimpleDateFormat defaultFormat = new SimpleDateFormat(TIMESTAMP_FORMAT_STRING); + + public static void setFormatString(String pattern) { + defaultFormat.applyPattern(pattern); + } + + /** + * 默认格式化日期 + * + * @param Date date + * @return String + */ + public static String format(Date date) { + return defaultFormat.format(date); + } + + /** + * 日期格式化 + * + * @param date + * @return + */ + public static String formatDate(Date date) { + return TimeFormat.format(date, DATE_FORMAT_STRING); + } + + /** + * 时间格式化 + * + * @param date + * @return + */ + public static String formatTime(Date date) { + return TimeFormat.format(date, TIME_FORMAT_STRING); + } + + /** + * 时间戳格式化 + * + * @param date + * @return + */ + public static String formatTimestamp(Date date) { + return TimeFormat.format(date, TIMESTAMP_FORMAT_STRING); + } + + /** + * 以指定模式格式化日期 + * + * @param Date date + * @param String pattern + * @return String + */ + public static String format(Date date, String pattern) { + SimpleDateFormat formatter = new SimpleDateFormat(pattern); + return formatter.format(date); + } + + /** + * 根据起止日期生成日期序列 + * 包括start和end的日期 + * + * @param start + * @param end + * @return + */ + public static List generateDates(String start, String end) throws ParseException { + List dates = new ArrayList(); + Calendar s = Calendar.getInstance(); + Calendar e = Calendar.getInstance(); + s.setTime(TimeFormat.parse(start, DATE_FORMAT_STRING)); + s.set(Calendar.HOUR_OF_DAY, 0); + s.set(Calendar.MINUTE, 0); + s.set(Calendar.SECOND, 0); + e.setTime(TimeFormat.parse(end, DATE_FORMAT_STRING)); + e.set(Calendar.HOUR_OF_DAY, 0); + e.set(Calendar.MINUTE, 0); + e.set(Calendar.SECOND, 0); + while (s.before(e) == true) { + dates.add(TimeFormat.formatDate(s.getTime())); + s.add(Calendar.DATE, 1); + } + + dates.add(end); + return dates; + } + + + /** + * 解析日期字符串 + * + * @param String source + * @return Date + * + * @throws ParseException + */ + public static Date parse(String source) throws ParseException { + return defaultFormat.parse(source); + } + + /** + * 以指定模式解析日期 + * + * @param String source + * @param String pattern + * @return Date + * + * @throws ParseException + */ + public static Date parse(String source, String pattern) throws ParseException { + SimpleDateFormat formatter = new SimpleDateFormat(pattern); + return formatter.parse(source); + } + + + public static Date parseDateWithoutTime(String source) throws ParseException { + SimpleDateFormat formatter = new SimpleDateFormat(DATE_FORMAT_STRING); + Calendar date = Calendar.getInstance(); + date.setTime(formatter.parse(source)); + date.set(Calendar.HOUR, 0); + date.set(Calendar.HOUR, 0); + date.set(Calendar.MINUTE, 0); + return date.getTime(); + } + +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 53c91ea..cea976f 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -15,19 +15,17 @@ # ============================================================================ # db # ============================================================================ -#db.default.driverClassName=oracle.jdbc.driver.OracleDriver -#db.default.url=jdbc:oracle:thin:@192.168.0.203:1521:SZHTDB2 -#db.default.username=scott -#db.default.password=SZHTDB2 db.default.driverClassName=com.mysql.jdbc.Driver -db.default.url=jdbc:mysql://127.0.0.1:3306/ems?useUnicode=true&characterEncoding=UTF-8 -db.default.username=emsweb -db.default.password=emsweb +db.default.url=jdbc:mysql://127.0.0.1:3306/ems_tong?useUnicode=true&characterEncoding=UTF-8 +db.default.username=root +db.default.password=root +#db.default.username=emsweb +#db.default.password=emsweb #db.default.url=jdbc:mysql://119.254.110.71:3307/ems?useUnicode=true&characterEncoding=UTF-8 #db.default.username=root #db.default.password=rootems - -# ============================================================================ +# +## ============================================================================ # log4jdbc # ============================================================================ log4jdbc.enable=true diff --git a/src/main/resources/spring/applicationContext-filter.xml b/src/main/resources/spring/applicationContext-filter.xml index a08c5fc..98ac7d6 100644 --- a/src/main/resources/spring/applicationContext-filter.xml +++ b/src/main/resources/spring/applicationContext-filter.xml @@ -35,9 +35,13 @@ /user/ill-login.do /marker/exportMarker.do /marker/batchSave-na.do + /marker/batch-save-no-update.do + /marker/save-marker-photo.do /event/save-event.do /task/get-task.do + /app/get-latest-version.do /xls/* + /apk/* diff --git a/src/main/resources/spring/applicationContext-hibernate.xml b/src/main/resources/spring/applicationContext-hibernate.xml index 5bb1a7e..dc54192 100644 --- a/src/main/resources/spring/applicationContext-hibernate.xml +++ b/src/main/resources/spring/applicationContext-hibernate.xml @@ -65,6 +65,7 @@ com.casic.accessControl.task.domain.Position com.casic.accessControl.event.domain.Event com.casic.accessControl.marker.domain.OptionItem + com.casic.accessControl.app.domain.ApkVersion diff --git a/src/main/webapp/common/layout/menu_new.jsp b/src/main/webapp/common/layout/menu_new.jsp index 3cf4b4e..cbd822e 100644 --- a/src/main/webapp/common/layout/menu_new.jsp +++ b/src/main/webapp/common/layout/menu_new.jsp @@ -20,7 +20,7 @@
                      • - + @@ -54,7 +54,7 @@
                      • - + diff --git a/src/main/webapp/content/ems/ems-gd.jsp b/src/main/webapp/content/ems/ems-gd.jsp new file mode 100644 index 0000000..5137b49 --- /dev/null +++ b/src/main/webapp/content/ems/ems-gd.jsp @@ -0,0 +1,604 @@ +<%@page contentType="text/html;charset=UTF-8" %> + +<%@include file="/taglibs.jsp" %> + +<%pageContext.setAttribute("currentMenu", "ems");%> + + + + + + + + + + + + + 地下管线电子标识系统 + + + + + + + + + + + + + + + + + + +<%-- + +--%> + + + + + + + + + + + + + + +<%@include file="/common/layout/header.jsp" %> + +
                        + + + + <%@include file="/common/layout/menu_new.jsp" %> + + + +
                        + + + +
                        + +
                        + + +
                        +
                        +
                        +
                        + +
                        +
                        + +
                        +
                        + +
                        +
                        + +
                        +
                        + +
                        + +
                        + +
                        + +
                        + +
                        + +
                        +
                        +
                        + + + + +
                        +
                        +
                        +
                        + + + + +
                        +
                        +
                        + +
                        + +
                        + +<%--todo list:错误使用方法 + +--%> +
                        + +
                        +
                        + +
                        + +
                        + +
                        + + +
                        + +
                        + + 移动 + 绘制区域 + 新增标识器 + 删除标识器 + 保存标识器 + 批量导入 + 导出Excel + 清空 + +
                        + +
                        +
                        + +
                        + + + +
                        + +
                        + +
                        + + + + +
                        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/webapp/content/task/task-gd.jsp b/src/main/webapp/content/task/task-gd.jsp new file mode 100644 index 0000000..d2d5549 --- /dev/null +++ b/src/main/webapp/content/task/task-gd.jsp @@ -0,0 +1,374 @@ +<%@page contentType="text/html;charset=UTF-8" %> + +<%@include file="/taglibs.jsp" %> + +<%pageContext.setAttribute("currentMenu", "task");%> + + + + + + + + + + + + + 地下管线电子标识系统 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +<%@include file="/common/layout/header.jsp" %> + +
                        + + + + <%@include file="/common/layout/menu_new.jsp" %> + + + +
                        + + + +
                        + +
                        + +
                        + + 移动 + 绘制区域 + 选择多点创建工单 + 清空选择 + +
                        + +
                        + +
                        + + +
                        + +
                        + +
                        + +
                        历史工单
                        + +
                        + +
                        + +
                        + <%--巡检员:--%> +
                        +
                        + + +
                        +
                        + + +
                          +
                        +
                          +
                          + +
                          + +
                          + +
                          + +
                          +
                          + +
                          + + + +
                          + +
                          + +
                          + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/webapp/images/drop/0.png b/src/main/webapp/images/drop/0.png new file mode 100644 index 0000000..f4b966b --- /dev/null +++ b/src/main/webapp/images/drop/0.png Binary files differ diff --git a/src/main/webapp/images/drop/1.png b/src/main/webapp/images/drop/1.png new file mode 100644 index 0000000..9284b64 --- /dev/null +++ b/src/main/webapp/images/drop/1.png Binary files differ diff --git a/src/main/webapp/images/drop/2.png b/src/main/webapp/images/drop/2.png new file mode 100644 index 0000000..b5425db --- /dev/null +++ b/src/main/webapp/images/drop/2.png Binary files differ diff --git a/src/main/webapp/images/drop/3.png b/src/main/webapp/images/drop/3.png new file mode 100644 index 0000000..dd09655 --- /dev/null +++ b/src/main/webapp/images/drop/3.png Binary files differ diff --git a/src/main/webapp/images/drop/4.png b/src/main/webapp/images/drop/4.png new file mode 100644 index 0000000..50cf1f7 --- /dev/null +++ b/src/main/webapp/images/drop/4.png Binary files differ diff --git a/src/main/webapp/images/drop/5.png b/src/main/webapp/images/drop/5.png new file mode 100644 index 0000000..a2029bd --- /dev/null +++ b/src/main/webapp/images/drop/5.png Binary files differ diff --git a/src/main/webapp/images/drop/6.png b/src/main/webapp/images/drop/6.png new file mode 100644 index 0000000..b53248a --- /dev/null +++ b/src/main/webapp/images/drop/6.png Binary files differ diff --git a/src/main/webapp/images/ems/point.png b/src/main/webapp/images/ems/point.png new file mode 100644 index 0000000..a814351 --- /dev/null +++ b/src/main/webapp/images/ems/point.png Binary files differ diff --git a/src/main/webapp/images/ems/rect.png b/src/main/webapp/images/ems/rect.png new file mode 100644 index 0000000..99d0c9e --- /dev/null +++ b/src/main/webapp/images/ems/rect.png Binary files differ diff --git a/src/main/webapp/images/events/red_icon.png b/src/main/webapp/images/events/red_icon.png new file mode 100644 index 0000000..78c26e4 --- /dev/null +++ b/src/main/webapp/images/events/red_icon.png Binary files differ diff --git a/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java new file mode 100644 index 0000000..634ceae --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java @@ -0,0 +1,46 @@ +package com.casic.accessControl.app.domain; + +import javax.persistence.*; +import java.util.Date; + +/** + * app的版本信息 + */ +//工单 +@Entity +@Table(name = "apkVersion") +public class ApkVersion { + private String version; + private String path; + private Date ts;//时间戳 + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "version") + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + @Column(name = "path") + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + @Column(name = "ts") + public Date getTs() { + return ts; + } + + public void setTs(Date ts) { + this.ts = ts; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java new file mode 100644 index 0000000..1d0242a --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java @@ -0,0 +1,50 @@ +package com.casic.accessControl.app.dto; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.util.TimeFormat; + +/** + * Created by lenovo on 2016/4/13. + */ +public class ApkVersionDto { + private String version; + private String path; + private String ts; + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public String getTs() { + return ts; + } + + public void setTs(String ts) { + this.ts = ts; + } + + public static ApkVersionDto Convert(ApkVersion version) { + if (version == null) { + return null; + } + ApkVersionDto versionDto = new ApkVersionDto(); + versionDto.setVersion(version.getVersion()); + versionDto.setPath(version.getVersion()); + versionDto.setTs(TimeFormat.formatTimestamp(version.getTs())); + + return versionDto; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java b/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java new file mode 100644 index 0000000..28b12a7 --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java @@ -0,0 +1,27 @@ +package com.casic.accessControl.app.manager; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.core.hibernate.HibernateEntityDao; +import org.hibernate.Query; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * + */ +@Service("apkVersionManager") +public class ApkVersionManager extends HibernateEntityDao { + + public ApkVersion getLatestVersion() { + String sql = "from ApkVersion order by ts desc"; + Query query = getSession().createQuery(sql); + List list = query.list(); + if (null != list && list.isEmpty() == false) { + return list.get(0); + } + + return null; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java b/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java new file mode 100644 index 0000000..065d3cc --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java @@ -0,0 +1,66 @@ +package com.casic.accessControl.app.web; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.app.manager.ApkVersionManager; +import com.casic.accessControl.marker.domain.Marker; +import com.casic.accessControl.marker.manager.MarkerManager; +import com.casic.accessControl.task.domain.Task; +import com.casic.accessControl.task.domain.TaskDetail; +import com.casic.accessControl.task.dto.TaskDetailDto; +import com.casic.accessControl.task.dto.TaskDto; +import com.casic.accessControl.task.dto.TaskStatus; +import com.casic.accessControl.task.manager.TaskDetailManager; +import com.casic.accessControl.task.manager.TaskManager; +import com.casic.accessControl.user.domain.Company; +import com.casic.accessControl.user.domain.Role; +import com.casic.accessControl.user.domain.User; +import com.casic.accessControl.user.dto.UserDto; +import com.casic.accessControl.user.manager.RoleManager; +import com.casic.accessControl.user.manager.UserManager; +import com.casic.accessControl.util.DataTable; +import com.casic.accessControl.util.StringUtils; +import com.google.gson.Gson; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +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.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * Created by lenovo on 2016/4/13. + */ +@Controller +@RequestMapping("app") +public class ApkVersionController { + + @Resource + private ApkVersionManager apkVersionManager; + + @RequestMapping("get-latest-version") + @ResponseBody + public Map getLatestVersion(HttpServletResponse response, HttpSession session) { + Map result = new HashMap(); + try { + ApkVersion latest = apkVersionManager.getLatestVersion(); + if (null != latest) { + result.put("version", latest.getVersion()); + result.put("path", latest.getPath()); + } else { + result.put("version", "1.0.0"); + } + } catch (Exception e) { + e.printStackTrace(); + result.put("version", "1.0.0"); + } + + return result; + } + +} diff --git a/src/main/java/com/casic/accessControl/marker/domain/Marker.java b/src/main/java/com/casic/accessControl/marker/domain/Marker.java index 0575cfe..7d5b854 100644 --- a/src/main/java/com/casic/accessControl/marker/domain/Marker.java +++ b/src/main/java/com/casic/accessControl/marker/domain/Marker.java @@ -67,6 +67,10 @@ private String area; @Column(name = "line") private String line; + @Column(name = "colorType") + private String colorType; + @Column(name = "photos") + private String photos; @@ -315,4 +319,20 @@ public void setArea(String area) { this.area = area; } + + public String getColorType() { + return colorType; + } + + public void setColorType(String colorType) { + this.colorType = colorType; + } + + public String getPhotos() { + return photos; + } + + public void setPhotos(String photos) { + this.photos = photos; + } } diff --git a/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java b/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java index 506f31d..c5f8cf5 100644 --- a/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java +++ b/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java @@ -2,12 +2,12 @@ //import com.casic.accessControl.feature.domain.Feature; import com.casic.accessControl.marker.domain.Marker; +import com.casic.accessControl.util.StringUtils; +import com.casic.accessControl.util.TimeFormat; import org.apache.commons.collections.CollectionUtils; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.List; +import java.text.ParseException; +import java.util.*; /** * Created by lenovo on 2016/5/16. @@ -43,6 +43,8 @@ private Long userId; private String area; private String line; + private String colorType; + private String photos; private String btnEdit = "编辑"; private String btnDelete = "删除"; @@ -296,6 +298,23 @@ this.area = area; } + public String getColorType() { + if (StringUtils.isEmpty(colorType)) return "0"; + return colorType; + } + + public void setColorType(String colorType) { + this.colorType = colorType; + } + + public String getPhotos() { + return photos; + } + + public void setPhotos(String photos) { + this.photos = photos; + } + public String getLine() { return line; } @@ -335,6 +354,52 @@ result.setRoad(doNullChange(marker.getRoad())); result.setArea(doNullChange(marker.getArea())); result.setLine(doNullChange(marker.getLine())); + result.setColorType(marker.getColorType()); + result.setPhotos(marker.getPhotos()); + return result; + } + + public static Marker convert2Marker(MarkerDto markerDto) { + if (markerDto == null) return null; + Marker result = new Marker(); + if(markerDto.getLongitude()==null||markerDto.getLatitude()==null) return null; + if (null != markerDto.getCreateTime() && markerDto.getCreateTime().length() == 19) { + try { + result.setCreateTime(TimeFormat.parse(markerDto.getCreateTime(), "yyyy-MM-dd HH:mm:ss")); + } catch (ParseException pex) { + result.setCreateTime(Calendar.getInstance().getTime()); + } + } else { + result.setCreateTime(Calendar.getInstance().getTime()); + } + result.setDepth(doNullChange(markerDto.getDepth())); + result.setId(markerDto.getId()); + result.setLatitude(markerDto.getLatitude()); + result.setLongitude(markerDto.getLongitude()); + result.setMarkerId(markerDto.getMarkerId()); + result.setMarkerDepth(doNullChange(markerDto.getMarkerDepth())); + result.setMarkerObjectId(doNullChange(markerDto.getMarkerObjectId())); + result.setMarkerObjectType(doNullChange(markerDto.getMarkerObjectType())); + result.setOwnerComp(doNullChange(markerDto.getOwnerComp())); + result.setIsValid(markerDto.getIsValid()); + result.setMemo(doNullChange(markerDto.getMemo())); + result.setPipeDiameter(doNullChange(markerDto.getPipeDiameter())); + result.setPipeMaterial(doNullChange(markerDto.getPipeMaterial())); + result.setMarkerType(doNullChange(markerDto.getMarkerType())); + result.setCreator(doNullChange(markerDto.getCreator())); + + result.setLayStyle(doNullChange(markerDto.getLayStyle())); + result.setBelowDepth(doNullChange(markerDto.getBelowDepth())); + result.setBelowDiameter(doNullChange(markerDto.getBelowDiameter())); + result.setBelowMaterial(doNullChange(markerDto.getBelowMaterial())); + result.setBelowType(doNullChange(markerDto.getBelowType())); + result.setConstructTime(doNullChange(markerDto.getConstructTime())); + result.setRecordType(markerDto.getRecordType()); + result.setRoad(doNullChange(markerDto.getRoad())); + result.setArea(doNullChange(markerDto.getArea())); + result.setLine(doNullChange(markerDto.getLine())); + result.setColorType(markerDto.getColorType()); + result.setPhotos(markerDto.getPhotos()); return result; } diff --git a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java index dd0fa4b..ba5a1fb 100644 --- a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java +++ b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java @@ -9,10 +9,7 @@ import com.casic.accessControl.marker.domain.Marker; import com.casic.accessControl.user.domain.Company; import com.casic.accessControl.user.domain.User; -import com.casic.accessControl.util.DataTable; -import com.casic.accessControl.util.DataTableParameter; -import com.casic.accessControl.util.DataTableUtils; -import com.casic.accessControl.util.DateUtils; +import com.casic.accessControl.util.*; import com.google.gson.Gson; import jxl.*; import jxl.read.biff.BiffException; @@ -31,11 +28,15 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; +import sun.misc.BASE64Decoder; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.File; +import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.text.ParseException; @@ -183,6 +184,53 @@ } /** + * 保存标识器和图片信息 + * @param markerDto + * @param companyId + * @param fileNames + * @param fileBuffers + * @return + */ + public boolean saveMarkerAndPhotos(MarkerDto markerDto, Long companyId, String[] fileNames, String[] fileBuffers) { + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + String strDirPath = request.getSession().getServletContext().getRealPath(""); + FileOutputStream fos = null; + String month = TimeFormat.format(Calendar.getInstance().getTime(), "yyyyMM"); + String webPath = "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String toDir = strDirPath + "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String filePaths = ""; + try { + for (int i = 0; i < fileBuffers.length; i++) { + if (fileBuffers[i] != null && fileNames[i] != null) { +// filePaths += toDir+fileNames[i]+","; + filePaths += webPath + fileNames[i] + ","; + byte[] buffer = new BASE64Decoder().decodeBuffer(fileBuffers[i]); //对android传过来的图片字符串进行解码 + File destDir = new File(toDir); + if (!destDir.exists()) + destDir.mkdirs(); + File imageFile = new File(destDir, fileNames[i]); + fos = new FileOutputStream(imageFile); //保存图片 + fos.write(buffer); + fos.flush(); + fos.close(); + } + } + if (filePaths.endsWith(",")) { + filePaths = filePaths.substring(0, filePaths.length() - 1); + } + } catch (Exception e) { + return false; + } + Marker marker = MarkerDto.convert2Marker(markerDto); + marker.setIsValid(1); + marker.setCompanyId(companyId); + marker.setPhotos(filePaths); + save(marker); + return true; + + } + + /** * 新增标识器 8-9 * * @param markers @@ -582,7 +630,7 @@ "所属区域","所属线路","所属道路","建设年代","权属单位","标示对象ID", "标识器ID","标识器类型","标识器埋深","安装部门","经度", "纬度", "最后修改时间","备注","下层管种类", "下层管埋深", - "下层管直径", "下层管材料", "标识对象类别"}; + "下层管直径", "下层管材料", "标识对象类别", "标识点颜色", "图片地址"}; Label[][] labels = new Label[markerDtos.size() + 1][titleTxt.length]; for(int k=0;k saveMarkerAndPhotos(@RequestParam(value = "fileBuffer1", required = false) MultipartFile fileBuffer1, + @RequestParam(value = "fileBuffer2", required = false) MultipartFile fileBuffer2, + @RequestParam(value = "fileBuffer3", required = false) MultipartFile fileBuffer3, + @RequestParam(value = "jsonMarker", required = true) String jsonMarker) { + Map map = new HashMap(); + map.put("message", "安装无标识器信息"); + Gson gson = new Gson(); + try { + MarkerDto marker = gson.fromJson(jsonMarker, MarkerDto.class); + + if (null == marker.getMarkerId()) { + map.put("message", "无标识器ID"); + map.put("success", "false"); + return map; + } else if (markerManager.getMarkerByMarkerId(marker.getMarkerId()).size() > 0) { + map.put("message", "已安装过该标识器[" + marker.getMarkerId() + "]"); + map.put("success", "false"); + return map; + } else { + String[] fileNames = new String[3]; + String[] fileBuffers = new String[3]; + if (fileBuffer1 != null) { + fileNames[0] = marker.getMarkerId() + "_" + fileBuffer1.getOriginalFilename(); + byte[] fis = fileBuffer1.getBytes(); + fileBuffers[0] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, com.sun.org.apache.xml.internal.security.utils.Base64.BASE64DEFAULTLENGTH)); + } + if (fileBuffer2 != null) { + fileNames[1] = marker.getMarkerId() + "_" + fileBuffer2.getOriginalFilename(); + byte[] fis = fileBuffer2.getBytes(); + fileBuffers[1] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, com.sun.org.apache.xml.internal.security.utils.Base64.BASE64DEFAULTLENGTH)); + } + if (fileBuffer3 != null) { + fileNames[2] = marker.getMarkerId() + "_" + fileBuffer3.getOriginalFilename(); + byte[] fis = fileBuffer3.getBytes(); + fileBuffers[2] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, Base64.BASE64DEFAULTLENGTH)); + } + Long companyId = marker.getCompanyId(); + if (companyId == null) { + return map; + } + boolean result = markerManager.saveMarkerAndPhotos(marker, companyId, fileNames, fileBuffers); + if (!result) { + return map; + } + } + } catch (Exception e) { + return map; + } + map.put("success", "true"); + map.put("message", "保存成功"); + return map; + } + + @RequestMapping("marker-info-delete") @ResponseBody public Map delete(@RequestParam(value = "id", required = true) Long id) { @@ -144,6 +208,9 @@ map.put("message", "删除需要ID信息"); return map; } + + System.out.println(ids); + markerManager.delMarkerByIds(ids); map.put("success", true); map.put("message", "删除成功"); @@ -240,6 +307,54 @@ return map; } + /** + * 批量上传标识点,用于无信号地区标识器信息统一上传,不修改已有标识点信息 + * @param strMarkers + * @return + */ + @RequestMapping("batch-save-no-update") + @ResponseBody + public Map batchSaveOrUpdate(@RequestParam(value = "markers", required = true) String strMarkers) { + strMarkers = strMarkers.replace('\n',' '); + Map map = new HashMap(); + map.put("message", "批量导入失败,或无导入标识器信息"); + Gson gson = new Gson(); + try { + List markers = gson.fromJson(strMarkers, new TypeToken>() { + }.getType()); + if (CollectionUtils.isEmpty(markers)) {//批量导入数据不存在,直接返回 + map.put("message", "批量导入数据不存在"); + return map; + } + + Long companyId = markers.get(0).getCompanyId(); + if (companyId == null) { + map.put("message", "未找到所属公司属性"); + return map; + } + + List markerDtoForSave = new ArrayList(); + for (MarkerDto markerDto : markers) { + // 上传marker的Id不为空且数据库中不存在记录,经纬度不为空,允许保存 + if (StringUtils.isNotBlank(markerDto.getMarkerId()) && markerManager.getMarkerByMarkerId(markerDto.getMarkerId()).size() <= 0) { + if (null != markerDto.getLongitude() && null != markerDto.getLatitude()) { + markerDtoForSave.add(markerDto); + } + } + } + boolean result = markerManager.batchSave(markerDtoForSave, companyId); + if (!result) { + return map; + } + } catch (Exception e) { + e.printStackTrace(); + return map; + } + map.put("success", true); + map.put("message", "保存成功"); + return map; + } + @RequestMapping("getMarkerListByCondition") @ResponseBody @POST diff --git a/src/main/java/com/casic/accessControl/user/web/UserController.java b/src/main/java/com/casic/accessControl/user/web/UserController.java index feab678..3534a97 100644 --- a/src/main/java/com/casic/accessControl/user/web/UserController.java +++ b/src/main/java/com/casic/accessControl/user/web/UserController.java @@ -46,6 +46,7 @@ @ResponseBody public Map login(@ModelAttribute User userInfo, HttpSession session) { Map result = new HashMap(); + User user = null; try{ user = userManager.login(userInfo); diff --git a/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java b/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java new file mode 100644 index 0000000..582120f --- /dev/null +++ b/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java @@ -0,0 +1,129 @@ +package com.casic.accessControl.util; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.net.URL; +import java.net.URLConnection; +import java.util.List; +import java.util.Map; + +/** + * Created by lenovo on 2016/8/31. + */ +public class HttpRequestUtils { + + /** + * 向指定URL发送GET方法的请求 + * + * @param url + * 发送请求的URL + * @param param + * 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 + * @return URL 所代表远程资源的响应结果 + */ + public static String sendGet(String url, String param) { + String result = ""; + BufferedReader in = null; + try { + String urlNameString = url + "?" + param; + URL realUrl = new URL(urlNameString); + // 打开和URL之间的连接 + URLConnection connection = realUrl.openConnection(); + // 设置通用的请求属性 + connection.setRequestProperty("accept", "*/*"); + connection.setRequestProperty("connection", "Keep-Alive"); + connection.setRequestProperty("user-agent", + "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + // 建立实际的连接 + connection.connect(); + // 获取所有响应头字段 + Map> map = connection.getHeaderFields(); + // 遍历所有的响应头字段 + for (String key : map.keySet()) { + System.out.println(key + "--->" + map.get(key)); + } + // 定义 BufferedReader输入流来读取URL的响应 + in = new BufferedReader(new InputStreamReader( + connection.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + result += line; + } + } catch (Exception e) { + System.out.println("发送GET请求出现异常!" + e); + e.printStackTrace(); + } + // 使用finally块来关闭输入流 + finally { + try { + if (in != null) { + in.close(); + } + } catch (Exception e2) { + e2.printStackTrace(); + } + } + return result; + } + + /** + * 向指定 URL 发送POST方法的请求 + * + * @param url + * 发送请求的 URL + * @param param + * 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 + * @return 所代表远程资源的响应结果 + */ + public static String sendPost(String url, String param) { + PrintWriter out = null; + BufferedReader in = null; + String result = ""; + try { + URL realUrl = new URL(url); + // 打开和URL之间的连接 + URLConnection conn = realUrl.openConnection(); + // 设置通用的请求属性 + conn.setRequestProperty("accept", "*/*"); + conn.setRequestProperty("connection", "Keep-Alive"); + conn.setRequestProperty("user-agent", + "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + // 发送POST请求必须设置如下两行 + conn.setDoOutput(true); + conn.setDoInput(true); + // 获取URLConnection对象对应的输出流 + out = new PrintWriter(conn.getOutputStream()); + // 发送请求参数 + out.print(param); + // flush输出流的缓冲 + out.flush(); + // 定义BufferedReader输入流来读取URL的响应 + in = new BufferedReader( + new InputStreamReader(conn.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + result += line; + } + } catch (Exception e) { + System.out.println("发送 POST 请求出现异常!"+e); + e.printStackTrace(); + } + //使用finally块来关闭输出流、输入流 + finally{ + try{ + if(out!=null){ + out.close(); + } + if(in!=null){ + in.close(); + } + } + catch(IOException ex){ + ex.printStackTrace(); + } + } + return result; + } + } \ No newline at end of file diff --git a/src/main/java/com/casic/accessControl/util/TimeFormat.java b/src/main/java/com/casic/accessControl/util/TimeFormat.java new file mode 100644 index 0000000..e9168d5 --- /dev/null +++ b/src/main/java/com/casic/accessControl/util/TimeFormat.java @@ -0,0 +1,148 @@ +package com.casic.accessControl.util; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +/** + * 格式化日期工具类 + * 默认模式yyyy-MM-dd HH:mm:ss + * @author Administrator + * + */ +public class TimeFormat { + + private static final String DATE_FORMAT_STRING = "yyyy-MM-dd"; + private static final String TIME_FORMAT_STRING = "HH:mm:ss"; + private static final String TIMESTAMP_FORMAT_STRING = "yyyy-MM-dd HH:mm:ss"; + + // 默认格式化格式 + private static SimpleDateFormat defaultFormat = new SimpleDateFormat(TIMESTAMP_FORMAT_STRING); + + public static void setFormatString(String pattern) { + defaultFormat.applyPattern(pattern); + } + + /** + * 默认格式化日期 + * + * @param Date date + * @return String + */ + public static String format(Date date) { + return defaultFormat.format(date); + } + + /** + * 日期格式化 + * + * @param date + * @return + */ + public static String formatDate(Date date) { + return TimeFormat.format(date, DATE_FORMAT_STRING); + } + + /** + * 时间格式化 + * + * @param date + * @return + */ + public static String formatTime(Date date) { + return TimeFormat.format(date, TIME_FORMAT_STRING); + } + + /** + * 时间戳格式化 + * + * @param date + * @return + */ + public static String formatTimestamp(Date date) { + return TimeFormat.format(date, TIMESTAMP_FORMAT_STRING); + } + + /** + * 以指定模式格式化日期 + * + * @param Date date + * @param String pattern + * @return String + */ + public static String format(Date date, String pattern) { + SimpleDateFormat formatter = new SimpleDateFormat(pattern); + return formatter.format(date); + } + + /** + * 根据起止日期生成日期序列 + * 包括start和end的日期 + * + * @param start + * @param end + * @return + */ + public static List generateDates(String start, String end) throws ParseException { + List dates = new ArrayList(); + Calendar s = Calendar.getInstance(); + Calendar e = Calendar.getInstance(); + s.setTime(TimeFormat.parse(start, DATE_FORMAT_STRING)); + s.set(Calendar.HOUR_OF_DAY, 0); + s.set(Calendar.MINUTE, 0); + s.set(Calendar.SECOND, 0); + e.setTime(TimeFormat.parse(end, DATE_FORMAT_STRING)); + e.set(Calendar.HOUR_OF_DAY, 0); + e.set(Calendar.MINUTE, 0); + e.set(Calendar.SECOND, 0); + while (s.before(e) == true) { + dates.add(TimeFormat.formatDate(s.getTime())); + s.add(Calendar.DATE, 1); + } + + dates.add(end); + return dates; + } + + + /** + * 解析日期字符串 + * + * @param String source + * @return Date + * + * @throws ParseException + */ + public static Date parse(String source) throws ParseException { + return defaultFormat.parse(source); + } + + /** + * 以指定模式解析日期 + * + * @param String source + * @param String pattern + * @return Date + * + * @throws ParseException + */ + public static Date parse(String source, String pattern) throws ParseException { + SimpleDateFormat formatter = new SimpleDateFormat(pattern); + return formatter.parse(source); + } + + + public static Date parseDateWithoutTime(String source) throws ParseException { + SimpleDateFormat formatter = new SimpleDateFormat(DATE_FORMAT_STRING); + Calendar date = Calendar.getInstance(); + date.setTime(formatter.parse(source)); + date.set(Calendar.HOUR, 0); + date.set(Calendar.HOUR, 0); + date.set(Calendar.MINUTE, 0); + return date.getTime(); + } + +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 53c91ea..cea976f 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -15,19 +15,17 @@ # ============================================================================ # db # ============================================================================ -#db.default.driverClassName=oracle.jdbc.driver.OracleDriver -#db.default.url=jdbc:oracle:thin:@192.168.0.203:1521:SZHTDB2 -#db.default.username=scott -#db.default.password=SZHTDB2 db.default.driverClassName=com.mysql.jdbc.Driver -db.default.url=jdbc:mysql://127.0.0.1:3306/ems?useUnicode=true&characterEncoding=UTF-8 -db.default.username=emsweb -db.default.password=emsweb +db.default.url=jdbc:mysql://127.0.0.1:3306/ems_tong?useUnicode=true&characterEncoding=UTF-8 +db.default.username=root +db.default.password=root +#db.default.username=emsweb +#db.default.password=emsweb #db.default.url=jdbc:mysql://119.254.110.71:3307/ems?useUnicode=true&characterEncoding=UTF-8 #db.default.username=root #db.default.password=rootems - -# ============================================================================ +# +## ============================================================================ # log4jdbc # ============================================================================ log4jdbc.enable=true diff --git a/src/main/resources/spring/applicationContext-filter.xml b/src/main/resources/spring/applicationContext-filter.xml index a08c5fc..98ac7d6 100644 --- a/src/main/resources/spring/applicationContext-filter.xml +++ b/src/main/resources/spring/applicationContext-filter.xml @@ -35,9 +35,13 @@ /user/ill-login.do /marker/exportMarker.do /marker/batchSave-na.do + /marker/batch-save-no-update.do + /marker/save-marker-photo.do /event/save-event.do /task/get-task.do + /app/get-latest-version.do /xls/* + /apk/* diff --git a/src/main/resources/spring/applicationContext-hibernate.xml b/src/main/resources/spring/applicationContext-hibernate.xml index 5bb1a7e..dc54192 100644 --- a/src/main/resources/spring/applicationContext-hibernate.xml +++ b/src/main/resources/spring/applicationContext-hibernate.xml @@ -65,6 +65,7 @@ com.casic.accessControl.task.domain.Position com.casic.accessControl.event.domain.Event com.casic.accessControl.marker.domain.OptionItem + com.casic.accessControl.app.domain.ApkVersion diff --git a/src/main/webapp/common/layout/menu_new.jsp b/src/main/webapp/common/layout/menu_new.jsp index 3cf4b4e..cbd822e 100644 --- a/src/main/webapp/common/layout/menu_new.jsp +++ b/src/main/webapp/common/layout/menu_new.jsp @@ -20,7 +20,7 @@
                        • - + @@ -54,7 +54,7 @@
                        • - + diff --git a/src/main/webapp/content/ems/ems-gd.jsp b/src/main/webapp/content/ems/ems-gd.jsp new file mode 100644 index 0000000..5137b49 --- /dev/null +++ b/src/main/webapp/content/ems/ems-gd.jsp @@ -0,0 +1,604 @@ +<%@page contentType="text/html;charset=UTF-8" %> + +<%@include file="/taglibs.jsp" %> + +<%pageContext.setAttribute("currentMenu", "ems");%> + + + + + + + + + + + + + 地下管线电子标识系统 + + + + + + + + + + + + + + + + + + +<%-- + +--%> + + + + + + + + + + + + + + +<%@include file="/common/layout/header.jsp" %> + +
                          + + + + <%@include file="/common/layout/menu_new.jsp" %> + + + +
                          + + + +
                          + +
                          + + +
                          +
                          +
                          +
                          + +
                          +
                          + +
                          +
                          + +
                          +
                          + +
                          +
                          + +
                          + +
                          + +
                          + +
                          + +
                          + +
                          +
                          +
                          + + + + +
                          +
                          +
                          +
                          + + + + +
                          +
                          +
                          + +
                          + +
                          + +<%--todo list:错误使用方法 + +--%> +
                          + +
                          +
                          + +
                          + +
                          + +
                          + + +
                          + +
                          + + 移动 + 绘制区域 + 新增标识器 + 删除标识器 + 保存标识器 + 批量导入 + 导出Excel + 清空 + +
                          + +
                          +
                          + +
                          + + + +
                          + +
                          + +
                          + + + + +
                          + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/webapp/content/task/task-gd.jsp b/src/main/webapp/content/task/task-gd.jsp new file mode 100644 index 0000000..d2d5549 --- /dev/null +++ b/src/main/webapp/content/task/task-gd.jsp @@ -0,0 +1,374 @@ +<%@page contentType="text/html;charset=UTF-8" %> + +<%@include file="/taglibs.jsp" %> + +<%pageContext.setAttribute("currentMenu", "task");%> + + + + + + + + + + + + + 地下管线电子标识系统 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +<%@include file="/common/layout/header.jsp" %> + +
                          + + + + <%@include file="/common/layout/menu_new.jsp" %> + + + +
                          + + + +
                          + +
                          + +
                          + + 移动 + 绘制区域 + 选择多点创建工单 + 清空选择 + +
                          + +
                          + +
                          + + +
                          + +
                          + +
                          + +
                          历史工单
                          + +
                          + +
                          + +
                          + <%--巡检员:--%> +
                          +
                          + + +
                          +
                          + + +
                            +
                          +
                            +
                            + +
                            + +
                            + +
                            + +
                            +
                            + +
                            + + + +
                            + +
                            + +
                            + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/webapp/images/drop/0.png b/src/main/webapp/images/drop/0.png new file mode 100644 index 0000000..f4b966b --- /dev/null +++ b/src/main/webapp/images/drop/0.png Binary files differ diff --git a/src/main/webapp/images/drop/1.png b/src/main/webapp/images/drop/1.png new file mode 100644 index 0000000..9284b64 --- /dev/null +++ b/src/main/webapp/images/drop/1.png Binary files differ diff --git a/src/main/webapp/images/drop/2.png b/src/main/webapp/images/drop/2.png new file mode 100644 index 0000000..b5425db --- /dev/null +++ b/src/main/webapp/images/drop/2.png Binary files differ diff --git a/src/main/webapp/images/drop/3.png b/src/main/webapp/images/drop/3.png new file mode 100644 index 0000000..dd09655 --- /dev/null +++ b/src/main/webapp/images/drop/3.png Binary files differ diff --git a/src/main/webapp/images/drop/4.png b/src/main/webapp/images/drop/4.png new file mode 100644 index 0000000..50cf1f7 --- /dev/null +++ b/src/main/webapp/images/drop/4.png Binary files differ diff --git a/src/main/webapp/images/drop/5.png b/src/main/webapp/images/drop/5.png new file mode 100644 index 0000000..a2029bd --- /dev/null +++ b/src/main/webapp/images/drop/5.png Binary files differ diff --git a/src/main/webapp/images/drop/6.png b/src/main/webapp/images/drop/6.png new file mode 100644 index 0000000..b53248a --- /dev/null +++ b/src/main/webapp/images/drop/6.png Binary files differ diff --git a/src/main/webapp/images/ems/point.png b/src/main/webapp/images/ems/point.png new file mode 100644 index 0000000..a814351 --- /dev/null +++ b/src/main/webapp/images/ems/point.png Binary files differ diff --git a/src/main/webapp/images/ems/rect.png b/src/main/webapp/images/ems/rect.png new file mode 100644 index 0000000..99d0c9e --- /dev/null +++ b/src/main/webapp/images/ems/rect.png Binary files differ diff --git a/src/main/webapp/images/events/red_icon.png b/src/main/webapp/images/events/red_icon.png new file mode 100644 index 0000000..78c26e4 --- /dev/null +++ b/src/main/webapp/images/events/red_icon.png Binary files differ diff --git a/src/main/webapp/images/point-task.png b/src/main/webapp/images/point-task.png new file mode 100644 index 0000000..b2e22c6 --- /dev/null +++ b/src/main/webapp/images/point-task.png Binary files differ diff --git a/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java new file mode 100644 index 0000000..634ceae --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java @@ -0,0 +1,46 @@ +package com.casic.accessControl.app.domain; + +import javax.persistence.*; +import java.util.Date; + +/** + * app的版本信息 + */ +//工单 +@Entity +@Table(name = "apkVersion") +public class ApkVersion { + private String version; + private String path; + private Date ts;//时间戳 + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "version") + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + @Column(name = "path") + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + @Column(name = "ts") + public Date getTs() { + return ts; + } + + public void setTs(Date ts) { + this.ts = ts; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java new file mode 100644 index 0000000..1d0242a --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java @@ -0,0 +1,50 @@ +package com.casic.accessControl.app.dto; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.util.TimeFormat; + +/** + * Created by lenovo on 2016/4/13. + */ +public class ApkVersionDto { + private String version; + private String path; + private String ts; + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public String getTs() { + return ts; + } + + public void setTs(String ts) { + this.ts = ts; + } + + public static ApkVersionDto Convert(ApkVersion version) { + if (version == null) { + return null; + } + ApkVersionDto versionDto = new ApkVersionDto(); + versionDto.setVersion(version.getVersion()); + versionDto.setPath(version.getVersion()); + versionDto.setTs(TimeFormat.formatTimestamp(version.getTs())); + + return versionDto; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java b/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java new file mode 100644 index 0000000..28b12a7 --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java @@ -0,0 +1,27 @@ +package com.casic.accessControl.app.manager; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.core.hibernate.HibernateEntityDao; +import org.hibernate.Query; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * + */ +@Service("apkVersionManager") +public class ApkVersionManager extends HibernateEntityDao { + + public ApkVersion getLatestVersion() { + String sql = "from ApkVersion order by ts desc"; + Query query = getSession().createQuery(sql); + List list = query.list(); + if (null != list && list.isEmpty() == false) { + return list.get(0); + } + + return null; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java b/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java new file mode 100644 index 0000000..065d3cc --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java @@ -0,0 +1,66 @@ +package com.casic.accessControl.app.web; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.app.manager.ApkVersionManager; +import com.casic.accessControl.marker.domain.Marker; +import com.casic.accessControl.marker.manager.MarkerManager; +import com.casic.accessControl.task.domain.Task; +import com.casic.accessControl.task.domain.TaskDetail; +import com.casic.accessControl.task.dto.TaskDetailDto; +import com.casic.accessControl.task.dto.TaskDto; +import com.casic.accessControl.task.dto.TaskStatus; +import com.casic.accessControl.task.manager.TaskDetailManager; +import com.casic.accessControl.task.manager.TaskManager; +import com.casic.accessControl.user.domain.Company; +import com.casic.accessControl.user.domain.Role; +import com.casic.accessControl.user.domain.User; +import com.casic.accessControl.user.dto.UserDto; +import com.casic.accessControl.user.manager.RoleManager; +import com.casic.accessControl.user.manager.UserManager; +import com.casic.accessControl.util.DataTable; +import com.casic.accessControl.util.StringUtils; +import com.google.gson.Gson; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +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.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * Created by lenovo on 2016/4/13. + */ +@Controller +@RequestMapping("app") +public class ApkVersionController { + + @Resource + private ApkVersionManager apkVersionManager; + + @RequestMapping("get-latest-version") + @ResponseBody + public Map getLatestVersion(HttpServletResponse response, HttpSession session) { + Map result = new HashMap(); + try { + ApkVersion latest = apkVersionManager.getLatestVersion(); + if (null != latest) { + result.put("version", latest.getVersion()); + result.put("path", latest.getPath()); + } else { + result.put("version", "1.0.0"); + } + } catch (Exception e) { + e.printStackTrace(); + result.put("version", "1.0.0"); + } + + return result; + } + +} diff --git a/src/main/java/com/casic/accessControl/marker/domain/Marker.java b/src/main/java/com/casic/accessControl/marker/domain/Marker.java index 0575cfe..7d5b854 100644 --- a/src/main/java/com/casic/accessControl/marker/domain/Marker.java +++ b/src/main/java/com/casic/accessControl/marker/domain/Marker.java @@ -67,6 +67,10 @@ private String area; @Column(name = "line") private String line; + @Column(name = "colorType") + private String colorType; + @Column(name = "photos") + private String photos; @@ -315,4 +319,20 @@ public void setArea(String area) { this.area = area; } + + public String getColorType() { + return colorType; + } + + public void setColorType(String colorType) { + this.colorType = colorType; + } + + public String getPhotos() { + return photos; + } + + public void setPhotos(String photos) { + this.photos = photos; + } } diff --git a/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java b/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java index 506f31d..c5f8cf5 100644 --- a/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java +++ b/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java @@ -2,12 +2,12 @@ //import com.casic.accessControl.feature.domain.Feature; import com.casic.accessControl.marker.domain.Marker; +import com.casic.accessControl.util.StringUtils; +import com.casic.accessControl.util.TimeFormat; import org.apache.commons.collections.CollectionUtils; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.List; +import java.text.ParseException; +import java.util.*; /** * Created by lenovo on 2016/5/16. @@ -43,6 +43,8 @@ private Long userId; private String area; private String line; + private String colorType; + private String photos; private String btnEdit = "编辑"; private String btnDelete = "删除"; @@ -296,6 +298,23 @@ this.area = area; } + public String getColorType() { + if (StringUtils.isEmpty(colorType)) return "0"; + return colorType; + } + + public void setColorType(String colorType) { + this.colorType = colorType; + } + + public String getPhotos() { + return photos; + } + + public void setPhotos(String photos) { + this.photos = photos; + } + public String getLine() { return line; } @@ -335,6 +354,52 @@ result.setRoad(doNullChange(marker.getRoad())); result.setArea(doNullChange(marker.getArea())); result.setLine(doNullChange(marker.getLine())); + result.setColorType(marker.getColorType()); + result.setPhotos(marker.getPhotos()); + return result; + } + + public static Marker convert2Marker(MarkerDto markerDto) { + if (markerDto == null) return null; + Marker result = new Marker(); + if(markerDto.getLongitude()==null||markerDto.getLatitude()==null) return null; + if (null != markerDto.getCreateTime() && markerDto.getCreateTime().length() == 19) { + try { + result.setCreateTime(TimeFormat.parse(markerDto.getCreateTime(), "yyyy-MM-dd HH:mm:ss")); + } catch (ParseException pex) { + result.setCreateTime(Calendar.getInstance().getTime()); + } + } else { + result.setCreateTime(Calendar.getInstance().getTime()); + } + result.setDepth(doNullChange(markerDto.getDepth())); + result.setId(markerDto.getId()); + result.setLatitude(markerDto.getLatitude()); + result.setLongitude(markerDto.getLongitude()); + result.setMarkerId(markerDto.getMarkerId()); + result.setMarkerDepth(doNullChange(markerDto.getMarkerDepth())); + result.setMarkerObjectId(doNullChange(markerDto.getMarkerObjectId())); + result.setMarkerObjectType(doNullChange(markerDto.getMarkerObjectType())); + result.setOwnerComp(doNullChange(markerDto.getOwnerComp())); + result.setIsValid(markerDto.getIsValid()); + result.setMemo(doNullChange(markerDto.getMemo())); + result.setPipeDiameter(doNullChange(markerDto.getPipeDiameter())); + result.setPipeMaterial(doNullChange(markerDto.getPipeMaterial())); + result.setMarkerType(doNullChange(markerDto.getMarkerType())); + result.setCreator(doNullChange(markerDto.getCreator())); + + result.setLayStyle(doNullChange(markerDto.getLayStyle())); + result.setBelowDepth(doNullChange(markerDto.getBelowDepth())); + result.setBelowDiameter(doNullChange(markerDto.getBelowDiameter())); + result.setBelowMaterial(doNullChange(markerDto.getBelowMaterial())); + result.setBelowType(doNullChange(markerDto.getBelowType())); + result.setConstructTime(doNullChange(markerDto.getConstructTime())); + result.setRecordType(markerDto.getRecordType()); + result.setRoad(doNullChange(markerDto.getRoad())); + result.setArea(doNullChange(markerDto.getArea())); + result.setLine(doNullChange(markerDto.getLine())); + result.setColorType(markerDto.getColorType()); + result.setPhotos(markerDto.getPhotos()); return result; } diff --git a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java index dd0fa4b..ba5a1fb 100644 --- a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java +++ b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java @@ -9,10 +9,7 @@ import com.casic.accessControl.marker.domain.Marker; import com.casic.accessControl.user.domain.Company; import com.casic.accessControl.user.domain.User; -import com.casic.accessControl.util.DataTable; -import com.casic.accessControl.util.DataTableParameter; -import com.casic.accessControl.util.DataTableUtils; -import com.casic.accessControl.util.DateUtils; +import com.casic.accessControl.util.*; import com.google.gson.Gson; import jxl.*; import jxl.read.biff.BiffException; @@ -31,11 +28,15 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; +import sun.misc.BASE64Decoder; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.File; +import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.text.ParseException; @@ -183,6 +184,53 @@ } /** + * 保存标识器和图片信息 + * @param markerDto + * @param companyId + * @param fileNames + * @param fileBuffers + * @return + */ + public boolean saveMarkerAndPhotos(MarkerDto markerDto, Long companyId, String[] fileNames, String[] fileBuffers) { + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + String strDirPath = request.getSession().getServletContext().getRealPath(""); + FileOutputStream fos = null; + String month = TimeFormat.format(Calendar.getInstance().getTime(), "yyyyMM"); + String webPath = "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String toDir = strDirPath + "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String filePaths = ""; + try { + for (int i = 0; i < fileBuffers.length; i++) { + if (fileBuffers[i] != null && fileNames[i] != null) { +// filePaths += toDir+fileNames[i]+","; + filePaths += webPath + fileNames[i] + ","; + byte[] buffer = new BASE64Decoder().decodeBuffer(fileBuffers[i]); //对android传过来的图片字符串进行解码 + File destDir = new File(toDir); + if (!destDir.exists()) + destDir.mkdirs(); + File imageFile = new File(destDir, fileNames[i]); + fos = new FileOutputStream(imageFile); //保存图片 + fos.write(buffer); + fos.flush(); + fos.close(); + } + } + if (filePaths.endsWith(",")) { + filePaths = filePaths.substring(0, filePaths.length() - 1); + } + } catch (Exception e) { + return false; + } + Marker marker = MarkerDto.convert2Marker(markerDto); + marker.setIsValid(1); + marker.setCompanyId(companyId); + marker.setPhotos(filePaths); + save(marker); + return true; + + } + + /** * 新增标识器 8-9 * * @param markers @@ -582,7 +630,7 @@ "所属区域","所属线路","所属道路","建设年代","权属单位","标示对象ID", "标识器ID","标识器类型","标识器埋深","安装部门","经度", "纬度", "最后修改时间","备注","下层管种类", "下层管埋深", - "下层管直径", "下层管材料", "标识对象类别"}; + "下层管直径", "下层管材料", "标识对象类别", "标识点颜色", "图片地址"}; Label[][] labels = new Label[markerDtos.size() + 1][titleTxt.length]; for(int k=0;k saveMarkerAndPhotos(@RequestParam(value = "fileBuffer1", required = false) MultipartFile fileBuffer1, + @RequestParam(value = "fileBuffer2", required = false) MultipartFile fileBuffer2, + @RequestParam(value = "fileBuffer3", required = false) MultipartFile fileBuffer3, + @RequestParam(value = "jsonMarker", required = true) String jsonMarker) { + Map map = new HashMap(); + map.put("message", "安装无标识器信息"); + Gson gson = new Gson(); + try { + MarkerDto marker = gson.fromJson(jsonMarker, MarkerDto.class); + + if (null == marker.getMarkerId()) { + map.put("message", "无标识器ID"); + map.put("success", "false"); + return map; + } else if (markerManager.getMarkerByMarkerId(marker.getMarkerId()).size() > 0) { + map.put("message", "已安装过该标识器[" + marker.getMarkerId() + "]"); + map.put("success", "false"); + return map; + } else { + String[] fileNames = new String[3]; + String[] fileBuffers = new String[3]; + if (fileBuffer1 != null) { + fileNames[0] = marker.getMarkerId() + "_" + fileBuffer1.getOriginalFilename(); + byte[] fis = fileBuffer1.getBytes(); + fileBuffers[0] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, com.sun.org.apache.xml.internal.security.utils.Base64.BASE64DEFAULTLENGTH)); + } + if (fileBuffer2 != null) { + fileNames[1] = marker.getMarkerId() + "_" + fileBuffer2.getOriginalFilename(); + byte[] fis = fileBuffer2.getBytes(); + fileBuffers[1] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, com.sun.org.apache.xml.internal.security.utils.Base64.BASE64DEFAULTLENGTH)); + } + if (fileBuffer3 != null) { + fileNames[2] = marker.getMarkerId() + "_" + fileBuffer3.getOriginalFilename(); + byte[] fis = fileBuffer3.getBytes(); + fileBuffers[2] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, Base64.BASE64DEFAULTLENGTH)); + } + Long companyId = marker.getCompanyId(); + if (companyId == null) { + return map; + } + boolean result = markerManager.saveMarkerAndPhotos(marker, companyId, fileNames, fileBuffers); + if (!result) { + return map; + } + } + } catch (Exception e) { + return map; + } + map.put("success", "true"); + map.put("message", "保存成功"); + return map; + } + + @RequestMapping("marker-info-delete") @ResponseBody public Map delete(@RequestParam(value = "id", required = true) Long id) { @@ -144,6 +208,9 @@ map.put("message", "删除需要ID信息"); return map; } + + System.out.println(ids); + markerManager.delMarkerByIds(ids); map.put("success", true); map.put("message", "删除成功"); @@ -240,6 +307,54 @@ return map; } + /** + * 批量上传标识点,用于无信号地区标识器信息统一上传,不修改已有标识点信息 + * @param strMarkers + * @return + */ + @RequestMapping("batch-save-no-update") + @ResponseBody + public Map batchSaveOrUpdate(@RequestParam(value = "markers", required = true) String strMarkers) { + strMarkers = strMarkers.replace('\n',' '); + Map map = new HashMap(); + map.put("message", "批量导入失败,或无导入标识器信息"); + Gson gson = new Gson(); + try { + List markers = gson.fromJson(strMarkers, new TypeToken>() { + }.getType()); + if (CollectionUtils.isEmpty(markers)) {//批量导入数据不存在,直接返回 + map.put("message", "批量导入数据不存在"); + return map; + } + + Long companyId = markers.get(0).getCompanyId(); + if (companyId == null) { + map.put("message", "未找到所属公司属性"); + return map; + } + + List markerDtoForSave = new ArrayList(); + for (MarkerDto markerDto : markers) { + // 上传marker的Id不为空且数据库中不存在记录,经纬度不为空,允许保存 + if (StringUtils.isNotBlank(markerDto.getMarkerId()) && markerManager.getMarkerByMarkerId(markerDto.getMarkerId()).size() <= 0) { + if (null != markerDto.getLongitude() && null != markerDto.getLatitude()) { + markerDtoForSave.add(markerDto); + } + } + } + boolean result = markerManager.batchSave(markerDtoForSave, companyId); + if (!result) { + return map; + } + } catch (Exception e) { + e.printStackTrace(); + return map; + } + map.put("success", true); + map.put("message", "保存成功"); + return map; + } + @RequestMapping("getMarkerListByCondition") @ResponseBody @POST diff --git a/src/main/java/com/casic/accessControl/user/web/UserController.java b/src/main/java/com/casic/accessControl/user/web/UserController.java index feab678..3534a97 100644 --- a/src/main/java/com/casic/accessControl/user/web/UserController.java +++ b/src/main/java/com/casic/accessControl/user/web/UserController.java @@ -46,6 +46,7 @@ @ResponseBody public Map login(@ModelAttribute User userInfo, HttpSession session) { Map result = new HashMap(); + User user = null; try{ user = userManager.login(userInfo); diff --git a/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java b/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java new file mode 100644 index 0000000..582120f --- /dev/null +++ b/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java @@ -0,0 +1,129 @@ +package com.casic.accessControl.util; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.net.URL; +import java.net.URLConnection; +import java.util.List; +import java.util.Map; + +/** + * Created by lenovo on 2016/8/31. + */ +public class HttpRequestUtils { + + /** + * 向指定URL发送GET方法的请求 + * + * @param url + * 发送请求的URL + * @param param + * 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 + * @return URL 所代表远程资源的响应结果 + */ + public static String sendGet(String url, String param) { + String result = ""; + BufferedReader in = null; + try { + String urlNameString = url + "?" + param; + URL realUrl = new URL(urlNameString); + // 打开和URL之间的连接 + URLConnection connection = realUrl.openConnection(); + // 设置通用的请求属性 + connection.setRequestProperty("accept", "*/*"); + connection.setRequestProperty("connection", "Keep-Alive"); + connection.setRequestProperty("user-agent", + "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + // 建立实际的连接 + connection.connect(); + // 获取所有响应头字段 + Map> map = connection.getHeaderFields(); + // 遍历所有的响应头字段 + for (String key : map.keySet()) { + System.out.println(key + "--->" + map.get(key)); + } + // 定义 BufferedReader输入流来读取URL的响应 + in = new BufferedReader(new InputStreamReader( + connection.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + result += line; + } + } catch (Exception e) { + System.out.println("发送GET请求出现异常!" + e); + e.printStackTrace(); + } + // 使用finally块来关闭输入流 + finally { + try { + if (in != null) { + in.close(); + } + } catch (Exception e2) { + e2.printStackTrace(); + } + } + return result; + } + + /** + * 向指定 URL 发送POST方法的请求 + * + * @param url + * 发送请求的 URL + * @param param + * 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 + * @return 所代表远程资源的响应结果 + */ + public static String sendPost(String url, String param) { + PrintWriter out = null; + BufferedReader in = null; + String result = ""; + try { + URL realUrl = new URL(url); + // 打开和URL之间的连接 + URLConnection conn = realUrl.openConnection(); + // 设置通用的请求属性 + conn.setRequestProperty("accept", "*/*"); + conn.setRequestProperty("connection", "Keep-Alive"); + conn.setRequestProperty("user-agent", + "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + // 发送POST请求必须设置如下两行 + conn.setDoOutput(true); + conn.setDoInput(true); + // 获取URLConnection对象对应的输出流 + out = new PrintWriter(conn.getOutputStream()); + // 发送请求参数 + out.print(param); + // flush输出流的缓冲 + out.flush(); + // 定义BufferedReader输入流来读取URL的响应 + in = new BufferedReader( + new InputStreamReader(conn.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + result += line; + } + } catch (Exception e) { + System.out.println("发送 POST 请求出现异常!"+e); + e.printStackTrace(); + } + //使用finally块来关闭输出流、输入流 + finally{ + try{ + if(out!=null){ + out.close(); + } + if(in!=null){ + in.close(); + } + } + catch(IOException ex){ + ex.printStackTrace(); + } + } + return result; + } + } \ No newline at end of file diff --git a/src/main/java/com/casic/accessControl/util/TimeFormat.java b/src/main/java/com/casic/accessControl/util/TimeFormat.java new file mode 100644 index 0000000..e9168d5 --- /dev/null +++ b/src/main/java/com/casic/accessControl/util/TimeFormat.java @@ -0,0 +1,148 @@ +package com.casic.accessControl.util; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +/** + * 格式化日期工具类 + * 默认模式yyyy-MM-dd HH:mm:ss + * @author Administrator + * + */ +public class TimeFormat { + + private static final String DATE_FORMAT_STRING = "yyyy-MM-dd"; + private static final String TIME_FORMAT_STRING = "HH:mm:ss"; + private static final String TIMESTAMP_FORMAT_STRING = "yyyy-MM-dd HH:mm:ss"; + + // 默认格式化格式 + private static SimpleDateFormat defaultFormat = new SimpleDateFormat(TIMESTAMP_FORMAT_STRING); + + public static void setFormatString(String pattern) { + defaultFormat.applyPattern(pattern); + } + + /** + * 默认格式化日期 + * + * @param Date date + * @return String + */ + public static String format(Date date) { + return defaultFormat.format(date); + } + + /** + * 日期格式化 + * + * @param date + * @return + */ + public static String formatDate(Date date) { + return TimeFormat.format(date, DATE_FORMAT_STRING); + } + + /** + * 时间格式化 + * + * @param date + * @return + */ + public static String formatTime(Date date) { + return TimeFormat.format(date, TIME_FORMAT_STRING); + } + + /** + * 时间戳格式化 + * + * @param date + * @return + */ + public static String formatTimestamp(Date date) { + return TimeFormat.format(date, TIMESTAMP_FORMAT_STRING); + } + + /** + * 以指定模式格式化日期 + * + * @param Date date + * @param String pattern + * @return String + */ + public static String format(Date date, String pattern) { + SimpleDateFormat formatter = new SimpleDateFormat(pattern); + return formatter.format(date); + } + + /** + * 根据起止日期生成日期序列 + * 包括start和end的日期 + * + * @param start + * @param end + * @return + */ + public static List generateDates(String start, String end) throws ParseException { + List dates = new ArrayList(); + Calendar s = Calendar.getInstance(); + Calendar e = Calendar.getInstance(); + s.setTime(TimeFormat.parse(start, DATE_FORMAT_STRING)); + s.set(Calendar.HOUR_OF_DAY, 0); + s.set(Calendar.MINUTE, 0); + s.set(Calendar.SECOND, 0); + e.setTime(TimeFormat.parse(end, DATE_FORMAT_STRING)); + e.set(Calendar.HOUR_OF_DAY, 0); + e.set(Calendar.MINUTE, 0); + e.set(Calendar.SECOND, 0); + while (s.before(e) == true) { + dates.add(TimeFormat.formatDate(s.getTime())); + s.add(Calendar.DATE, 1); + } + + dates.add(end); + return dates; + } + + + /** + * 解析日期字符串 + * + * @param String source + * @return Date + * + * @throws ParseException + */ + public static Date parse(String source) throws ParseException { + return defaultFormat.parse(source); + } + + /** + * 以指定模式解析日期 + * + * @param String source + * @param String pattern + * @return Date + * + * @throws ParseException + */ + public static Date parse(String source, String pattern) throws ParseException { + SimpleDateFormat formatter = new SimpleDateFormat(pattern); + return formatter.parse(source); + } + + + public static Date parseDateWithoutTime(String source) throws ParseException { + SimpleDateFormat formatter = new SimpleDateFormat(DATE_FORMAT_STRING); + Calendar date = Calendar.getInstance(); + date.setTime(formatter.parse(source)); + date.set(Calendar.HOUR, 0); + date.set(Calendar.HOUR, 0); + date.set(Calendar.MINUTE, 0); + return date.getTime(); + } + +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 53c91ea..cea976f 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -15,19 +15,17 @@ # ============================================================================ # db # ============================================================================ -#db.default.driverClassName=oracle.jdbc.driver.OracleDriver -#db.default.url=jdbc:oracle:thin:@192.168.0.203:1521:SZHTDB2 -#db.default.username=scott -#db.default.password=SZHTDB2 db.default.driverClassName=com.mysql.jdbc.Driver -db.default.url=jdbc:mysql://127.0.0.1:3306/ems?useUnicode=true&characterEncoding=UTF-8 -db.default.username=emsweb -db.default.password=emsweb +db.default.url=jdbc:mysql://127.0.0.1:3306/ems_tong?useUnicode=true&characterEncoding=UTF-8 +db.default.username=root +db.default.password=root +#db.default.username=emsweb +#db.default.password=emsweb #db.default.url=jdbc:mysql://119.254.110.71:3307/ems?useUnicode=true&characterEncoding=UTF-8 #db.default.username=root #db.default.password=rootems - -# ============================================================================ +# +## ============================================================================ # log4jdbc # ============================================================================ log4jdbc.enable=true diff --git a/src/main/resources/spring/applicationContext-filter.xml b/src/main/resources/spring/applicationContext-filter.xml index a08c5fc..98ac7d6 100644 --- a/src/main/resources/spring/applicationContext-filter.xml +++ b/src/main/resources/spring/applicationContext-filter.xml @@ -35,9 +35,13 @@ /user/ill-login.do /marker/exportMarker.do /marker/batchSave-na.do + /marker/batch-save-no-update.do + /marker/save-marker-photo.do /event/save-event.do /task/get-task.do + /app/get-latest-version.do /xls/* + /apk/* diff --git a/src/main/resources/spring/applicationContext-hibernate.xml b/src/main/resources/spring/applicationContext-hibernate.xml index 5bb1a7e..dc54192 100644 --- a/src/main/resources/spring/applicationContext-hibernate.xml +++ b/src/main/resources/spring/applicationContext-hibernate.xml @@ -65,6 +65,7 @@ com.casic.accessControl.task.domain.Position com.casic.accessControl.event.domain.Event com.casic.accessControl.marker.domain.OptionItem + com.casic.accessControl.app.domain.ApkVersion diff --git a/src/main/webapp/common/layout/menu_new.jsp b/src/main/webapp/common/layout/menu_new.jsp index 3cf4b4e..cbd822e 100644 --- a/src/main/webapp/common/layout/menu_new.jsp +++ b/src/main/webapp/common/layout/menu_new.jsp @@ -20,7 +20,7 @@
                          • - + @@ -54,7 +54,7 @@
                          • - + diff --git a/src/main/webapp/content/ems/ems-gd.jsp b/src/main/webapp/content/ems/ems-gd.jsp new file mode 100644 index 0000000..5137b49 --- /dev/null +++ b/src/main/webapp/content/ems/ems-gd.jsp @@ -0,0 +1,604 @@ +<%@page contentType="text/html;charset=UTF-8" %> + +<%@include file="/taglibs.jsp" %> + +<%pageContext.setAttribute("currentMenu", "ems");%> + + + + + + + + + + + + + 地下管线电子标识系统 + + + + + + + + + + + + + + + + + + +<%-- + +--%> + + + + + + + + + + + + + + +<%@include file="/common/layout/header.jsp" %> + +
                            + + + + <%@include file="/common/layout/menu_new.jsp" %> + + + +
                            + + + +
                            + +
                            + + +
                            +
                            +
                            +
                            + +
                            +
                            + +
                            +
                            + +
                            +
                            + +
                            +
                            + +
                            + +
                            + +
                            + +
                            + +
                            + +
                            +
                            +
                            + + + + +
                            +
                            +
                            +
                            + + + + +
                            +
                            +
                            + +
                            + +
                            + +<%--todo list:错误使用方法 + +--%> +
                            + +
                            +
                            + +
                            + +
                            + +
                            + + +
                            + +
                            + + 移动 + 绘制区域 + 新增标识器 + 删除标识器 + 保存标识器 + 批量导入 + 导出Excel + 清空 + +
                            + +
                            +
                            + +
                            + + + +
                            + +
                            + +
                            + + + + +
                            + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/webapp/content/task/task-gd.jsp b/src/main/webapp/content/task/task-gd.jsp new file mode 100644 index 0000000..d2d5549 --- /dev/null +++ b/src/main/webapp/content/task/task-gd.jsp @@ -0,0 +1,374 @@ +<%@page contentType="text/html;charset=UTF-8" %> + +<%@include file="/taglibs.jsp" %> + +<%pageContext.setAttribute("currentMenu", "task");%> + + + + + + + + + + + + + 地下管线电子标识系统 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +<%@include file="/common/layout/header.jsp" %> + +
                            + + + + <%@include file="/common/layout/menu_new.jsp" %> + + + +
                            + + + +
                            + +
                            + +
                            + + 移动 + 绘制区域 + 选择多点创建工单 + 清空选择 + +
                            + +
                            + +
                            + + +
                            + +
                            + +
                            + +
                            历史工单
                            + +
                            + +
                            + +
                            + <%--巡检员:--%> +
                            +
                            + + +
                            +
                            + + +
                              +
                            +
                              +
                              + +
                              + +
                              + +
                              + +
                              +
                              + +
                              + + + +
                              + +
                              + +
                              + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/webapp/images/drop/0.png b/src/main/webapp/images/drop/0.png new file mode 100644 index 0000000..f4b966b --- /dev/null +++ b/src/main/webapp/images/drop/0.png Binary files differ diff --git a/src/main/webapp/images/drop/1.png b/src/main/webapp/images/drop/1.png new file mode 100644 index 0000000..9284b64 --- /dev/null +++ b/src/main/webapp/images/drop/1.png Binary files differ diff --git a/src/main/webapp/images/drop/2.png b/src/main/webapp/images/drop/2.png new file mode 100644 index 0000000..b5425db --- /dev/null +++ b/src/main/webapp/images/drop/2.png Binary files differ diff --git a/src/main/webapp/images/drop/3.png b/src/main/webapp/images/drop/3.png new file mode 100644 index 0000000..dd09655 --- /dev/null +++ b/src/main/webapp/images/drop/3.png Binary files differ diff --git a/src/main/webapp/images/drop/4.png b/src/main/webapp/images/drop/4.png new file mode 100644 index 0000000..50cf1f7 --- /dev/null +++ b/src/main/webapp/images/drop/4.png Binary files differ diff --git a/src/main/webapp/images/drop/5.png b/src/main/webapp/images/drop/5.png new file mode 100644 index 0000000..a2029bd --- /dev/null +++ b/src/main/webapp/images/drop/5.png Binary files differ diff --git a/src/main/webapp/images/drop/6.png b/src/main/webapp/images/drop/6.png new file mode 100644 index 0000000..b53248a --- /dev/null +++ b/src/main/webapp/images/drop/6.png Binary files differ diff --git a/src/main/webapp/images/ems/point.png b/src/main/webapp/images/ems/point.png new file mode 100644 index 0000000..a814351 --- /dev/null +++ b/src/main/webapp/images/ems/point.png Binary files differ diff --git a/src/main/webapp/images/ems/rect.png b/src/main/webapp/images/ems/rect.png new file mode 100644 index 0000000..99d0c9e --- /dev/null +++ b/src/main/webapp/images/ems/rect.png Binary files differ diff --git a/src/main/webapp/images/events/red_icon.png b/src/main/webapp/images/events/red_icon.png new file mode 100644 index 0000000..78c26e4 --- /dev/null +++ b/src/main/webapp/images/events/red_icon.png Binary files differ diff --git a/src/main/webapp/images/point-task.png b/src/main/webapp/images/point-task.png new file mode 100644 index 0000000..b2e22c6 --- /dev/null +++ b/src/main/webapp/images/point-task.png Binary files differ diff --git a/src/main/webapp/images/point.png b/src/main/webapp/images/point.png new file mode 100644 index 0000000..4b887dc --- /dev/null +++ b/src/main/webapp/images/point.png Binary files differ diff --git a/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java new file mode 100644 index 0000000..634ceae --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java @@ -0,0 +1,46 @@ +package com.casic.accessControl.app.domain; + +import javax.persistence.*; +import java.util.Date; + +/** + * app的版本信息 + */ +//工单 +@Entity +@Table(name = "apkVersion") +public class ApkVersion { + private String version; + private String path; + private Date ts;//时间戳 + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "version") + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + @Column(name = "path") + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + @Column(name = "ts") + public Date getTs() { + return ts; + } + + public void setTs(Date ts) { + this.ts = ts; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java new file mode 100644 index 0000000..1d0242a --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java @@ -0,0 +1,50 @@ +package com.casic.accessControl.app.dto; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.util.TimeFormat; + +/** + * Created by lenovo on 2016/4/13. + */ +public class ApkVersionDto { + private String version; + private String path; + private String ts; + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public String getTs() { + return ts; + } + + public void setTs(String ts) { + this.ts = ts; + } + + public static ApkVersionDto Convert(ApkVersion version) { + if (version == null) { + return null; + } + ApkVersionDto versionDto = new ApkVersionDto(); + versionDto.setVersion(version.getVersion()); + versionDto.setPath(version.getVersion()); + versionDto.setTs(TimeFormat.formatTimestamp(version.getTs())); + + return versionDto; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java b/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java new file mode 100644 index 0000000..28b12a7 --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java @@ -0,0 +1,27 @@ +package com.casic.accessControl.app.manager; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.core.hibernate.HibernateEntityDao; +import org.hibernate.Query; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * + */ +@Service("apkVersionManager") +public class ApkVersionManager extends HibernateEntityDao { + + public ApkVersion getLatestVersion() { + String sql = "from ApkVersion order by ts desc"; + Query query = getSession().createQuery(sql); + List list = query.list(); + if (null != list && list.isEmpty() == false) { + return list.get(0); + } + + return null; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java b/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java new file mode 100644 index 0000000..065d3cc --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java @@ -0,0 +1,66 @@ +package com.casic.accessControl.app.web; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.app.manager.ApkVersionManager; +import com.casic.accessControl.marker.domain.Marker; +import com.casic.accessControl.marker.manager.MarkerManager; +import com.casic.accessControl.task.domain.Task; +import com.casic.accessControl.task.domain.TaskDetail; +import com.casic.accessControl.task.dto.TaskDetailDto; +import com.casic.accessControl.task.dto.TaskDto; +import com.casic.accessControl.task.dto.TaskStatus; +import com.casic.accessControl.task.manager.TaskDetailManager; +import com.casic.accessControl.task.manager.TaskManager; +import com.casic.accessControl.user.domain.Company; +import com.casic.accessControl.user.domain.Role; +import com.casic.accessControl.user.domain.User; +import com.casic.accessControl.user.dto.UserDto; +import com.casic.accessControl.user.manager.RoleManager; +import com.casic.accessControl.user.manager.UserManager; +import com.casic.accessControl.util.DataTable; +import com.casic.accessControl.util.StringUtils; +import com.google.gson.Gson; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +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.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * Created by lenovo on 2016/4/13. + */ +@Controller +@RequestMapping("app") +public class ApkVersionController { + + @Resource + private ApkVersionManager apkVersionManager; + + @RequestMapping("get-latest-version") + @ResponseBody + public Map getLatestVersion(HttpServletResponse response, HttpSession session) { + Map result = new HashMap(); + try { + ApkVersion latest = apkVersionManager.getLatestVersion(); + if (null != latest) { + result.put("version", latest.getVersion()); + result.put("path", latest.getPath()); + } else { + result.put("version", "1.0.0"); + } + } catch (Exception e) { + e.printStackTrace(); + result.put("version", "1.0.0"); + } + + return result; + } + +} diff --git a/src/main/java/com/casic/accessControl/marker/domain/Marker.java b/src/main/java/com/casic/accessControl/marker/domain/Marker.java index 0575cfe..7d5b854 100644 --- a/src/main/java/com/casic/accessControl/marker/domain/Marker.java +++ b/src/main/java/com/casic/accessControl/marker/domain/Marker.java @@ -67,6 +67,10 @@ private String area; @Column(name = "line") private String line; + @Column(name = "colorType") + private String colorType; + @Column(name = "photos") + private String photos; @@ -315,4 +319,20 @@ public void setArea(String area) { this.area = area; } + + public String getColorType() { + return colorType; + } + + public void setColorType(String colorType) { + this.colorType = colorType; + } + + public String getPhotos() { + return photos; + } + + public void setPhotos(String photos) { + this.photos = photos; + } } diff --git a/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java b/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java index 506f31d..c5f8cf5 100644 --- a/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java +++ b/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java @@ -2,12 +2,12 @@ //import com.casic.accessControl.feature.domain.Feature; import com.casic.accessControl.marker.domain.Marker; +import com.casic.accessControl.util.StringUtils; +import com.casic.accessControl.util.TimeFormat; import org.apache.commons.collections.CollectionUtils; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.List; +import java.text.ParseException; +import java.util.*; /** * Created by lenovo on 2016/5/16. @@ -43,6 +43,8 @@ private Long userId; private String area; private String line; + private String colorType; + private String photos; private String btnEdit = "编辑"; private String btnDelete = "删除"; @@ -296,6 +298,23 @@ this.area = area; } + public String getColorType() { + if (StringUtils.isEmpty(colorType)) return "0"; + return colorType; + } + + public void setColorType(String colorType) { + this.colorType = colorType; + } + + public String getPhotos() { + return photos; + } + + public void setPhotos(String photos) { + this.photos = photos; + } + public String getLine() { return line; } @@ -335,6 +354,52 @@ result.setRoad(doNullChange(marker.getRoad())); result.setArea(doNullChange(marker.getArea())); result.setLine(doNullChange(marker.getLine())); + result.setColorType(marker.getColorType()); + result.setPhotos(marker.getPhotos()); + return result; + } + + public static Marker convert2Marker(MarkerDto markerDto) { + if (markerDto == null) return null; + Marker result = new Marker(); + if(markerDto.getLongitude()==null||markerDto.getLatitude()==null) return null; + if (null != markerDto.getCreateTime() && markerDto.getCreateTime().length() == 19) { + try { + result.setCreateTime(TimeFormat.parse(markerDto.getCreateTime(), "yyyy-MM-dd HH:mm:ss")); + } catch (ParseException pex) { + result.setCreateTime(Calendar.getInstance().getTime()); + } + } else { + result.setCreateTime(Calendar.getInstance().getTime()); + } + result.setDepth(doNullChange(markerDto.getDepth())); + result.setId(markerDto.getId()); + result.setLatitude(markerDto.getLatitude()); + result.setLongitude(markerDto.getLongitude()); + result.setMarkerId(markerDto.getMarkerId()); + result.setMarkerDepth(doNullChange(markerDto.getMarkerDepth())); + result.setMarkerObjectId(doNullChange(markerDto.getMarkerObjectId())); + result.setMarkerObjectType(doNullChange(markerDto.getMarkerObjectType())); + result.setOwnerComp(doNullChange(markerDto.getOwnerComp())); + result.setIsValid(markerDto.getIsValid()); + result.setMemo(doNullChange(markerDto.getMemo())); + result.setPipeDiameter(doNullChange(markerDto.getPipeDiameter())); + result.setPipeMaterial(doNullChange(markerDto.getPipeMaterial())); + result.setMarkerType(doNullChange(markerDto.getMarkerType())); + result.setCreator(doNullChange(markerDto.getCreator())); + + result.setLayStyle(doNullChange(markerDto.getLayStyle())); + result.setBelowDepth(doNullChange(markerDto.getBelowDepth())); + result.setBelowDiameter(doNullChange(markerDto.getBelowDiameter())); + result.setBelowMaterial(doNullChange(markerDto.getBelowMaterial())); + result.setBelowType(doNullChange(markerDto.getBelowType())); + result.setConstructTime(doNullChange(markerDto.getConstructTime())); + result.setRecordType(markerDto.getRecordType()); + result.setRoad(doNullChange(markerDto.getRoad())); + result.setArea(doNullChange(markerDto.getArea())); + result.setLine(doNullChange(markerDto.getLine())); + result.setColorType(markerDto.getColorType()); + result.setPhotos(markerDto.getPhotos()); return result; } diff --git a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java index dd0fa4b..ba5a1fb 100644 --- a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java +++ b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java @@ -9,10 +9,7 @@ import com.casic.accessControl.marker.domain.Marker; import com.casic.accessControl.user.domain.Company; import com.casic.accessControl.user.domain.User; -import com.casic.accessControl.util.DataTable; -import com.casic.accessControl.util.DataTableParameter; -import com.casic.accessControl.util.DataTableUtils; -import com.casic.accessControl.util.DateUtils; +import com.casic.accessControl.util.*; import com.google.gson.Gson; import jxl.*; import jxl.read.biff.BiffException; @@ -31,11 +28,15 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; +import sun.misc.BASE64Decoder; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.File; +import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.text.ParseException; @@ -183,6 +184,53 @@ } /** + * 保存标识器和图片信息 + * @param markerDto + * @param companyId + * @param fileNames + * @param fileBuffers + * @return + */ + public boolean saveMarkerAndPhotos(MarkerDto markerDto, Long companyId, String[] fileNames, String[] fileBuffers) { + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + String strDirPath = request.getSession().getServletContext().getRealPath(""); + FileOutputStream fos = null; + String month = TimeFormat.format(Calendar.getInstance().getTime(), "yyyyMM"); + String webPath = "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String toDir = strDirPath + "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String filePaths = ""; + try { + for (int i = 0; i < fileBuffers.length; i++) { + if (fileBuffers[i] != null && fileNames[i] != null) { +// filePaths += toDir+fileNames[i]+","; + filePaths += webPath + fileNames[i] + ","; + byte[] buffer = new BASE64Decoder().decodeBuffer(fileBuffers[i]); //对android传过来的图片字符串进行解码 + File destDir = new File(toDir); + if (!destDir.exists()) + destDir.mkdirs(); + File imageFile = new File(destDir, fileNames[i]); + fos = new FileOutputStream(imageFile); //保存图片 + fos.write(buffer); + fos.flush(); + fos.close(); + } + } + if (filePaths.endsWith(",")) { + filePaths = filePaths.substring(0, filePaths.length() - 1); + } + } catch (Exception e) { + return false; + } + Marker marker = MarkerDto.convert2Marker(markerDto); + marker.setIsValid(1); + marker.setCompanyId(companyId); + marker.setPhotos(filePaths); + save(marker); + return true; + + } + + /** * 新增标识器 8-9 * * @param markers @@ -582,7 +630,7 @@ "所属区域","所属线路","所属道路","建设年代","权属单位","标示对象ID", "标识器ID","标识器类型","标识器埋深","安装部门","经度", "纬度", "最后修改时间","备注","下层管种类", "下层管埋深", - "下层管直径", "下层管材料", "标识对象类别"}; + "下层管直径", "下层管材料", "标识对象类别", "标识点颜色", "图片地址"}; Label[][] labels = new Label[markerDtos.size() + 1][titleTxt.length]; for(int k=0;k saveMarkerAndPhotos(@RequestParam(value = "fileBuffer1", required = false) MultipartFile fileBuffer1, + @RequestParam(value = "fileBuffer2", required = false) MultipartFile fileBuffer2, + @RequestParam(value = "fileBuffer3", required = false) MultipartFile fileBuffer3, + @RequestParam(value = "jsonMarker", required = true) String jsonMarker) { + Map map = new HashMap(); + map.put("message", "安装无标识器信息"); + Gson gson = new Gson(); + try { + MarkerDto marker = gson.fromJson(jsonMarker, MarkerDto.class); + + if (null == marker.getMarkerId()) { + map.put("message", "无标识器ID"); + map.put("success", "false"); + return map; + } else if (markerManager.getMarkerByMarkerId(marker.getMarkerId()).size() > 0) { + map.put("message", "已安装过该标识器[" + marker.getMarkerId() + "]"); + map.put("success", "false"); + return map; + } else { + String[] fileNames = new String[3]; + String[] fileBuffers = new String[3]; + if (fileBuffer1 != null) { + fileNames[0] = marker.getMarkerId() + "_" + fileBuffer1.getOriginalFilename(); + byte[] fis = fileBuffer1.getBytes(); + fileBuffers[0] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, com.sun.org.apache.xml.internal.security.utils.Base64.BASE64DEFAULTLENGTH)); + } + if (fileBuffer2 != null) { + fileNames[1] = marker.getMarkerId() + "_" + fileBuffer2.getOriginalFilename(); + byte[] fis = fileBuffer2.getBytes(); + fileBuffers[1] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, com.sun.org.apache.xml.internal.security.utils.Base64.BASE64DEFAULTLENGTH)); + } + if (fileBuffer3 != null) { + fileNames[2] = marker.getMarkerId() + "_" + fileBuffer3.getOriginalFilename(); + byte[] fis = fileBuffer3.getBytes(); + fileBuffers[2] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, Base64.BASE64DEFAULTLENGTH)); + } + Long companyId = marker.getCompanyId(); + if (companyId == null) { + return map; + } + boolean result = markerManager.saveMarkerAndPhotos(marker, companyId, fileNames, fileBuffers); + if (!result) { + return map; + } + } + } catch (Exception e) { + return map; + } + map.put("success", "true"); + map.put("message", "保存成功"); + return map; + } + + @RequestMapping("marker-info-delete") @ResponseBody public Map delete(@RequestParam(value = "id", required = true) Long id) { @@ -144,6 +208,9 @@ map.put("message", "删除需要ID信息"); return map; } + + System.out.println(ids); + markerManager.delMarkerByIds(ids); map.put("success", true); map.put("message", "删除成功"); @@ -240,6 +307,54 @@ return map; } + /** + * 批量上传标识点,用于无信号地区标识器信息统一上传,不修改已有标识点信息 + * @param strMarkers + * @return + */ + @RequestMapping("batch-save-no-update") + @ResponseBody + public Map batchSaveOrUpdate(@RequestParam(value = "markers", required = true) String strMarkers) { + strMarkers = strMarkers.replace('\n',' '); + Map map = new HashMap(); + map.put("message", "批量导入失败,或无导入标识器信息"); + Gson gson = new Gson(); + try { + List markers = gson.fromJson(strMarkers, new TypeToken>() { + }.getType()); + if (CollectionUtils.isEmpty(markers)) {//批量导入数据不存在,直接返回 + map.put("message", "批量导入数据不存在"); + return map; + } + + Long companyId = markers.get(0).getCompanyId(); + if (companyId == null) { + map.put("message", "未找到所属公司属性"); + return map; + } + + List markerDtoForSave = new ArrayList(); + for (MarkerDto markerDto : markers) { + // 上传marker的Id不为空且数据库中不存在记录,经纬度不为空,允许保存 + if (StringUtils.isNotBlank(markerDto.getMarkerId()) && markerManager.getMarkerByMarkerId(markerDto.getMarkerId()).size() <= 0) { + if (null != markerDto.getLongitude() && null != markerDto.getLatitude()) { + markerDtoForSave.add(markerDto); + } + } + } + boolean result = markerManager.batchSave(markerDtoForSave, companyId); + if (!result) { + return map; + } + } catch (Exception e) { + e.printStackTrace(); + return map; + } + map.put("success", true); + map.put("message", "保存成功"); + return map; + } + @RequestMapping("getMarkerListByCondition") @ResponseBody @POST diff --git a/src/main/java/com/casic/accessControl/user/web/UserController.java b/src/main/java/com/casic/accessControl/user/web/UserController.java index feab678..3534a97 100644 --- a/src/main/java/com/casic/accessControl/user/web/UserController.java +++ b/src/main/java/com/casic/accessControl/user/web/UserController.java @@ -46,6 +46,7 @@ @ResponseBody public Map login(@ModelAttribute User userInfo, HttpSession session) { Map result = new HashMap(); + User user = null; try{ user = userManager.login(userInfo); diff --git a/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java b/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java new file mode 100644 index 0000000..582120f --- /dev/null +++ b/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java @@ -0,0 +1,129 @@ +package com.casic.accessControl.util; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.net.URL; +import java.net.URLConnection; +import java.util.List; +import java.util.Map; + +/** + * Created by lenovo on 2016/8/31. + */ +public class HttpRequestUtils { + + /** + * 向指定URL发送GET方法的请求 + * + * @param url + * 发送请求的URL + * @param param + * 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 + * @return URL 所代表远程资源的响应结果 + */ + public static String sendGet(String url, String param) { + String result = ""; + BufferedReader in = null; + try { + String urlNameString = url + "?" + param; + URL realUrl = new URL(urlNameString); + // 打开和URL之间的连接 + URLConnection connection = realUrl.openConnection(); + // 设置通用的请求属性 + connection.setRequestProperty("accept", "*/*"); + connection.setRequestProperty("connection", "Keep-Alive"); + connection.setRequestProperty("user-agent", + "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + // 建立实际的连接 + connection.connect(); + // 获取所有响应头字段 + Map> map = connection.getHeaderFields(); + // 遍历所有的响应头字段 + for (String key : map.keySet()) { + System.out.println(key + "--->" + map.get(key)); + } + // 定义 BufferedReader输入流来读取URL的响应 + in = new BufferedReader(new InputStreamReader( + connection.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + result += line; + } + } catch (Exception e) { + System.out.println("发送GET请求出现异常!" + e); + e.printStackTrace(); + } + // 使用finally块来关闭输入流 + finally { + try { + if (in != null) { + in.close(); + } + } catch (Exception e2) { + e2.printStackTrace(); + } + } + return result; + } + + /** + * 向指定 URL 发送POST方法的请求 + * + * @param url + * 发送请求的 URL + * @param param + * 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 + * @return 所代表远程资源的响应结果 + */ + public static String sendPost(String url, String param) { + PrintWriter out = null; + BufferedReader in = null; + String result = ""; + try { + URL realUrl = new URL(url); + // 打开和URL之间的连接 + URLConnection conn = realUrl.openConnection(); + // 设置通用的请求属性 + conn.setRequestProperty("accept", "*/*"); + conn.setRequestProperty("connection", "Keep-Alive"); + conn.setRequestProperty("user-agent", + "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + // 发送POST请求必须设置如下两行 + conn.setDoOutput(true); + conn.setDoInput(true); + // 获取URLConnection对象对应的输出流 + out = new PrintWriter(conn.getOutputStream()); + // 发送请求参数 + out.print(param); + // flush输出流的缓冲 + out.flush(); + // 定义BufferedReader输入流来读取URL的响应 + in = new BufferedReader( + new InputStreamReader(conn.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + result += line; + } + } catch (Exception e) { + System.out.println("发送 POST 请求出现异常!"+e); + e.printStackTrace(); + } + //使用finally块来关闭输出流、输入流 + finally{ + try{ + if(out!=null){ + out.close(); + } + if(in!=null){ + in.close(); + } + } + catch(IOException ex){ + ex.printStackTrace(); + } + } + return result; + } + } \ No newline at end of file diff --git a/src/main/java/com/casic/accessControl/util/TimeFormat.java b/src/main/java/com/casic/accessControl/util/TimeFormat.java new file mode 100644 index 0000000..e9168d5 --- /dev/null +++ b/src/main/java/com/casic/accessControl/util/TimeFormat.java @@ -0,0 +1,148 @@ +package com.casic.accessControl.util; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +/** + * 格式化日期工具类 + * 默认模式yyyy-MM-dd HH:mm:ss + * @author Administrator + * + */ +public class TimeFormat { + + private static final String DATE_FORMAT_STRING = "yyyy-MM-dd"; + private static final String TIME_FORMAT_STRING = "HH:mm:ss"; + private static final String TIMESTAMP_FORMAT_STRING = "yyyy-MM-dd HH:mm:ss"; + + // 默认格式化格式 + private static SimpleDateFormat defaultFormat = new SimpleDateFormat(TIMESTAMP_FORMAT_STRING); + + public static void setFormatString(String pattern) { + defaultFormat.applyPattern(pattern); + } + + /** + * 默认格式化日期 + * + * @param Date date + * @return String + */ + public static String format(Date date) { + return defaultFormat.format(date); + } + + /** + * 日期格式化 + * + * @param date + * @return + */ + public static String formatDate(Date date) { + return TimeFormat.format(date, DATE_FORMAT_STRING); + } + + /** + * 时间格式化 + * + * @param date + * @return + */ + public static String formatTime(Date date) { + return TimeFormat.format(date, TIME_FORMAT_STRING); + } + + /** + * 时间戳格式化 + * + * @param date + * @return + */ + public static String formatTimestamp(Date date) { + return TimeFormat.format(date, TIMESTAMP_FORMAT_STRING); + } + + /** + * 以指定模式格式化日期 + * + * @param Date date + * @param String pattern + * @return String + */ + public static String format(Date date, String pattern) { + SimpleDateFormat formatter = new SimpleDateFormat(pattern); + return formatter.format(date); + } + + /** + * 根据起止日期生成日期序列 + * 包括start和end的日期 + * + * @param start + * @param end + * @return + */ + public static List generateDates(String start, String end) throws ParseException { + List dates = new ArrayList(); + Calendar s = Calendar.getInstance(); + Calendar e = Calendar.getInstance(); + s.setTime(TimeFormat.parse(start, DATE_FORMAT_STRING)); + s.set(Calendar.HOUR_OF_DAY, 0); + s.set(Calendar.MINUTE, 0); + s.set(Calendar.SECOND, 0); + e.setTime(TimeFormat.parse(end, DATE_FORMAT_STRING)); + e.set(Calendar.HOUR_OF_DAY, 0); + e.set(Calendar.MINUTE, 0); + e.set(Calendar.SECOND, 0); + while (s.before(e) == true) { + dates.add(TimeFormat.formatDate(s.getTime())); + s.add(Calendar.DATE, 1); + } + + dates.add(end); + return dates; + } + + + /** + * 解析日期字符串 + * + * @param String source + * @return Date + * + * @throws ParseException + */ + public static Date parse(String source) throws ParseException { + return defaultFormat.parse(source); + } + + /** + * 以指定模式解析日期 + * + * @param String source + * @param String pattern + * @return Date + * + * @throws ParseException + */ + public static Date parse(String source, String pattern) throws ParseException { + SimpleDateFormat formatter = new SimpleDateFormat(pattern); + return formatter.parse(source); + } + + + public static Date parseDateWithoutTime(String source) throws ParseException { + SimpleDateFormat formatter = new SimpleDateFormat(DATE_FORMAT_STRING); + Calendar date = Calendar.getInstance(); + date.setTime(formatter.parse(source)); + date.set(Calendar.HOUR, 0); + date.set(Calendar.HOUR, 0); + date.set(Calendar.MINUTE, 0); + return date.getTime(); + } + +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 53c91ea..cea976f 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -15,19 +15,17 @@ # ============================================================================ # db # ============================================================================ -#db.default.driverClassName=oracle.jdbc.driver.OracleDriver -#db.default.url=jdbc:oracle:thin:@192.168.0.203:1521:SZHTDB2 -#db.default.username=scott -#db.default.password=SZHTDB2 db.default.driverClassName=com.mysql.jdbc.Driver -db.default.url=jdbc:mysql://127.0.0.1:3306/ems?useUnicode=true&characterEncoding=UTF-8 -db.default.username=emsweb -db.default.password=emsweb +db.default.url=jdbc:mysql://127.0.0.1:3306/ems_tong?useUnicode=true&characterEncoding=UTF-8 +db.default.username=root +db.default.password=root +#db.default.username=emsweb +#db.default.password=emsweb #db.default.url=jdbc:mysql://119.254.110.71:3307/ems?useUnicode=true&characterEncoding=UTF-8 #db.default.username=root #db.default.password=rootems - -# ============================================================================ +# +## ============================================================================ # log4jdbc # ============================================================================ log4jdbc.enable=true diff --git a/src/main/resources/spring/applicationContext-filter.xml b/src/main/resources/spring/applicationContext-filter.xml index a08c5fc..98ac7d6 100644 --- a/src/main/resources/spring/applicationContext-filter.xml +++ b/src/main/resources/spring/applicationContext-filter.xml @@ -35,9 +35,13 @@ /user/ill-login.do /marker/exportMarker.do /marker/batchSave-na.do + /marker/batch-save-no-update.do + /marker/save-marker-photo.do /event/save-event.do /task/get-task.do + /app/get-latest-version.do /xls/* + /apk/* diff --git a/src/main/resources/spring/applicationContext-hibernate.xml b/src/main/resources/spring/applicationContext-hibernate.xml index 5bb1a7e..dc54192 100644 --- a/src/main/resources/spring/applicationContext-hibernate.xml +++ b/src/main/resources/spring/applicationContext-hibernate.xml @@ -65,6 +65,7 @@ com.casic.accessControl.task.domain.Position com.casic.accessControl.event.domain.Event com.casic.accessControl.marker.domain.OptionItem + com.casic.accessControl.app.domain.ApkVersion diff --git a/src/main/webapp/common/layout/menu_new.jsp b/src/main/webapp/common/layout/menu_new.jsp index 3cf4b4e..cbd822e 100644 --- a/src/main/webapp/common/layout/menu_new.jsp +++ b/src/main/webapp/common/layout/menu_new.jsp @@ -20,7 +20,7 @@
                            • - + @@ -54,7 +54,7 @@
                            • - + diff --git a/src/main/webapp/content/ems/ems-gd.jsp b/src/main/webapp/content/ems/ems-gd.jsp new file mode 100644 index 0000000..5137b49 --- /dev/null +++ b/src/main/webapp/content/ems/ems-gd.jsp @@ -0,0 +1,604 @@ +<%@page contentType="text/html;charset=UTF-8" %> + +<%@include file="/taglibs.jsp" %> + +<%pageContext.setAttribute("currentMenu", "ems");%> + + + + + + + + + + + + + 地下管线电子标识系统 + + + + + + + + + + + + + + + + + + +<%-- + +--%> + + + + + + + + + + + + + + +<%@include file="/common/layout/header.jsp" %> + +
                              + + + + <%@include file="/common/layout/menu_new.jsp" %> + + + +
                              + + + +
                              + +
                              + + +
                              +
                              +
                              +
                              + +
                              +
                              + +
                              +
                              + +
                              +
                              + +
                              +
                              + +
                              + +
                              + +
                              + +
                              + +
                              + +
                              +
                              +
                              + + + + +
                              +
                              +
                              +
                              + + + + +
                              +
                              +
                              + +
                              + +
                              + +<%--todo list:错误使用方法 + +--%> +
                              + +
                              +
                              + +
                              + +
                              + +
                              + + +
                              + +
                              + + 移动 + 绘制区域 + 新增标识器 + 删除标识器 + 保存标识器 + 批量导入 + 导出Excel + 清空 + +
                              + +
                              +
                              + +
                              + + + +
                              + +
                              + +
                              + + + + +
                              + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/webapp/content/task/task-gd.jsp b/src/main/webapp/content/task/task-gd.jsp new file mode 100644 index 0000000..d2d5549 --- /dev/null +++ b/src/main/webapp/content/task/task-gd.jsp @@ -0,0 +1,374 @@ +<%@page contentType="text/html;charset=UTF-8" %> + +<%@include file="/taglibs.jsp" %> + +<%pageContext.setAttribute("currentMenu", "task");%> + + + + + + + + + + + + + 地下管线电子标识系统 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +<%@include file="/common/layout/header.jsp" %> + +
                              + + + + <%@include file="/common/layout/menu_new.jsp" %> + + + +
                              + + + +
                              + +
                              + +
                              + + 移动 + 绘制区域 + 选择多点创建工单 + 清空选择 + +
                              + +
                              + +
                              + + +
                              + +
                              + +
                              + +
                              历史工单
                              + +
                              + +
                              + +
                              + <%--巡检员:--%> +
                              +
                              + + +
                              +
                              + + +
                                +
                              +
                                +
                                + +
                                + +
                                + +
                                + +
                                +
                                + +
                                + + + +
                                + +
                                + +
                                + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/webapp/images/drop/0.png b/src/main/webapp/images/drop/0.png new file mode 100644 index 0000000..f4b966b --- /dev/null +++ b/src/main/webapp/images/drop/0.png Binary files differ diff --git a/src/main/webapp/images/drop/1.png b/src/main/webapp/images/drop/1.png new file mode 100644 index 0000000..9284b64 --- /dev/null +++ b/src/main/webapp/images/drop/1.png Binary files differ diff --git a/src/main/webapp/images/drop/2.png b/src/main/webapp/images/drop/2.png new file mode 100644 index 0000000..b5425db --- /dev/null +++ b/src/main/webapp/images/drop/2.png Binary files differ diff --git a/src/main/webapp/images/drop/3.png b/src/main/webapp/images/drop/3.png new file mode 100644 index 0000000..dd09655 --- /dev/null +++ b/src/main/webapp/images/drop/3.png Binary files differ diff --git a/src/main/webapp/images/drop/4.png b/src/main/webapp/images/drop/4.png new file mode 100644 index 0000000..50cf1f7 --- /dev/null +++ b/src/main/webapp/images/drop/4.png Binary files differ diff --git a/src/main/webapp/images/drop/5.png b/src/main/webapp/images/drop/5.png new file mode 100644 index 0000000..a2029bd --- /dev/null +++ b/src/main/webapp/images/drop/5.png Binary files differ diff --git a/src/main/webapp/images/drop/6.png b/src/main/webapp/images/drop/6.png new file mode 100644 index 0000000..b53248a --- /dev/null +++ b/src/main/webapp/images/drop/6.png Binary files differ diff --git a/src/main/webapp/images/ems/point.png b/src/main/webapp/images/ems/point.png new file mode 100644 index 0000000..a814351 --- /dev/null +++ b/src/main/webapp/images/ems/point.png Binary files differ diff --git a/src/main/webapp/images/ems/rect.png b/src/main/webapp/images/ems/rect.png new file mode 100644 index 0000000..99d0c9e --- /dev/null +++ b/src/main/webapp/images/ems/rect.png Binary files differ diff --git a/src/main/webapp/images/events/red_icon.png b/src/main/webapp/images/events/red_icon.png new file mode 100644 index 0000000..78c26e4 --- /dev/null +++ b/src/main/webapp/images/events/red_icon.png Binary files differ diff --git a/src/main/webapp/images/point-task.png b/src/main/webapp/images/point-task.png new file mode 100644 index 0000000..b2e22c6 --- /dev/null +++ b/src/main/webapp/images/point-task.png Binary files differ diff --git a/src/main/webapp/images/point.png b/src/main/webapp/images/point.png new file mode 100644 index 0000000..4b887dc --- /dev/null +++ b/src/main/webapp/images/point.png Binary files differ diff --git a/src/main/webapp/images/tasks/point.png b/src/main/webapp/images/tasks/point.png new file mode 100644 index 0000000..a814351 --- /dev/null +++ b/src/main/webapp/images/tasks/point.png Binary files differ diff --git a/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java new file mode 100644 index 0000000..634ceae --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java @@ -0,0 +1,46 @@ +package com.casic.accessControl.app.domain; + +import javax.persistence.*; +import java.util.Date; + +/** + * app的版本信息 + */ +//工单 +@Entity +@Table(name = "apkVersion") +public class ApkVersion { + private String version; + private String path; + private Date ts;//时间戳 + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "version") + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + @Column(name = "path") + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + @Column(name = "ts") + public Date getTs() { + return ts; + } + + public void setTs(Date ts) { + this.ts = ts; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java new file mode 100644 index 0000000..1d0242a --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java @@ -0,0 +1,50 @@ +package com.casic.accessControl.app.dto; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.util.TimeFormat; + +/** + * Created by lenovo on 2016/4/13. + */ +public class ApkVersionDto { + private String version; + private String path; + private String ts; + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public String getTs() { + return ts; + } + + public void setTs(String ts) { + this.ts = ts; + } + + public static ApkVersionDto Convert(ApkVersion version) { + if (version == null) { + return null; + } + ApkVersionDto versionDto = new ApkVersionDto(); + versionDto.setVersion(version.getVersion()); + versionDto.setPath(version.getVersion()); + versionDto.setTs(TimeFormat.formatTimestamp(version.getTs())); + + return versionDto; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java b/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java new file mode 100644 index 0000000..28b12a7 --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java @@ -0,0 +1,27 @@ +package com.casic.accessControl.app.manager; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.core.hibernate.HibernateEntityDao; +import org.hibernate.Query; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * + */ +@Service("apkVersionManager") +public class ApkVersionManager extends HibernateEntityDao { + + public ApkVersion getLatestVersion() { + String sql = "from ApkVersion order by ts desc"; + Query query = getSession().createQuery(sql); + List list = query.list(); + if (null != list && list.isEmpty() == false) { + return list.get(0); + } + + return null; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java b/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java new file mode 100644 index 0000000..065d3cc --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java @@ -0,0 +1,66 @@ +package com.casic.accessControl.app.web; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.app.manager.ApkVersionManager; +import com.casic.accessControl.marker.domain.Marker; +import com.casic.accessControl.marker.manager.MarkerManager; +import com.casic.accessControl.task.domain.Task; +import com.casic.accessControl.task.domain.TaskDetail; +import com.casic.accessControl.task.dto.TaskDetailDto; +import com.casic.accessControl.task.dto.TaskDto; +import com.casic.accessControl.task.dto.TaskStatus; +import com.casic.accessControl.task.manager.TaskDetailManager; +import com.casic.accessControl.task.manager.TaskManager; +import com.casic.accessControl.user.domain.Company; +import com.casic.accessControl.user.domain.Role; +import com.casic.accessControl.user.domain.User; +import com.casic.accessControl.user.dto.UserDto; +import com.casic.accessControl.user.manager.RoleManager; +import com.casic.accessControl.user.manager.UserManager; +import com.casic.accessControl.util.DataTable; +import com.casic.accessControl.util.StringUtils; +import com.google.gson.Gson; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +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.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * Created by lenovo on 2016/4/13. + */ +@Controller +@RequestMapping("app") +public class ApkVersionController { + + @Resource + private ApkVersionManager apkVersionManager; + + @RequestMapping("get-latest-version") + @ResponseBody + public Map getLatestVersion(HttpServletResponse response, HttpSession session) { + Map result = new HashMap(); + try { + ApkVersion latest = apkVersionManager.getLatestVersion(); + if (null != latest) { + result.put("version", latest.getVersion()); + result.put("path", latest.getPath()); + } else { + result.put("version", "1.0.0"); + } + } catch (Exception e) { + e.printStackTrace(); + result.put("version", "1.0.0"); + } + + return result; + } + +} diff --git a/src/main/java/com/casic/accessControl/marker/domain/Marker.java b/src/main/java/com/casic/accessControl/marker/domain/Marker.java index 0575cfe..7d5b854 100644 --- a/src/main/java/com/casic/accessControl/marker/domain/Marker.java +++ b/src/main/java/com/casic/accessControl/marker/domain/Marker.java @@ -67,6 +67,10 @@ private String area; @Column(name = "line") private String line; + @Column(name = "colorType") + private String colorType; + @Column(name = "photos") + private String photos; @@ -315,4 +319,20 @@ public void setArea(String area) { this.area = area; } + + public String getColorType() { + return colorType; + } + + public void setColorType(String colorType) { + this.colorType = colorType; + } + + public String getPhotos() { + return photos; + } + + public void setPhotos(String photos) { + this.photos = photos; + } } diff --git a/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java b/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java index 506f31d..c5f8cf5 100644 --- a/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java +++ b/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java @@ -2,12 +2,12 @@ //import com.casic.accessControl.feature.domain.Feature; import com.casic.accessControl.marker.domain.Marker; +import com.casic.accessControl.util.StringUtils; +import com.casic.accessControl.util.TimeFormat; import org.apache.commons.collections.CollectionUtils; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.List; +import java.text.ParseException; +import java.util.*; /** * Created by lenovo on 2016/5/16. @@ -43,6 +43,8 @@ private Long userId; private String area; private String line; + private String colorType; + private String photos; private String btnEdit = "编辑"; private String btnDelete = "删除"; @@ -296,6 +298,23 @@ this.area = area; } + public String getColorType() { + if (StringUtils.isEmpty(colorType)) return "0"; + return colorType; + } + + public void setColorType(String colorType) { + this.colorType = colorType; + } + + public String getPhotos() { + return photos; + } + + public void setPhotos(String photos) { + this.photos = photos; + } + public String getLine() { return line; } @@ -335,6 +354,52 @@ result.setRoad(doNullChange(marker.getRoad())); result.setArea(doNullChange(marker.getArea())); result.setLine(doNullChange(marker.getLine())); + result.setColorType(marker.getColorType()); + result.setPhotos(marker.getPhotos()); + return result; + } + + public static Marker convert2Marker(MarkerDto markerDto) { + if (markerDto == null) return null; + Marker result = new Marker(); + if(markerDto.getLongitude()==null||markerDto.getLatitude()==null) return null; + if (null != markerDto.getCreateTime() && markerDto.getCreateTime().length() == 19) { + try { + result.setCreateTime(TimeFormat.parse(markerDto.getCreateTime(), "yyyy-MM-dd HH:mm:ss")); + } catch (ParseException pex) { + result.setCreateTime(Calendar.getInstance().getTime()); + } + } else { + result.setCreateTime(Calendar.getInstance().getTime()); + } + result.setDepth(doNullChange(markerDto.getDepth())); + result.setId(markerDto.getId()); + result.setLatitude(markerDto.getLatitude()); + result.setLongitude(markerDto.getLongitude()); + result.setMarkerId(markerDto.getMarkerId()); + result.setMarkerDepth(doNullChange(markerDto.getMarkerDepth())); + result.setMarkerObjectId(doNullChange(markerDto.getMarkerObjectId())); + result.setMarkerObjectType(doNullChange(markerDto.getMarkerObjectType())); + result.setOwnerComp(doNullChange(markerDto.getOwnerComp())); + result.setIsValid(markerDto.getIsValid()); + result.setMemo(doNullChange(markerDto.getMemo())); + result.setPipeDiameter(doNullChange(markerDto.getPipeDiameter())); + result.setPipeMaterial(doNullChange(markerDto.getPipeMaterial())); + result.setMarkerType(doNullChange(markerDto.getMarkerType())); + result.setCreator(doNullChange(markerDto.getCreator())); + + result.setLayStyle(doNullChange(markerDto.getLayStyle())); + result.setBelowDepth(doNullChange(markerDto.getBelowDepth())); + result.setBelowDiameter(doNullChange(markerDto.getBelowDiameter())); + result.setBelowMaterial(doNullChange(markerDto.getBelowMaterial())); + result.setBelowType(doNullChange(markerDto.getBelowType())); + result.setConstructTime(doNullChange(markerDto.getConstructTime())); + result.setRecordType(markerDto.getRecordType()); + result.setRoad(doNullChange(markerDto.getRoad())); + result.setArea(doNullChange(markerDto.getArea())); + result.setLine(doNullChange(markerDto.getLine())); + result.setColorType(markerDto.getColorType()); + result.setPhotos(markerDto.getPhotos()); return result; } diff --git a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java index dd0fa4b..ba5a1fb 100644 --- a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java +++ b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java @@ -9,10 +9,7 @@ import com.casic.accessControl.marker.domain.Marker; import com.casic.accessControl.user.domain.Company; import com.casic.accessControl.user.domain.User; -import com.casic.accessControl.util.DataTable; -import com.casic.accessControl.util.DataTableParameter; -import com.casic.accessControl.util.DataTableUtils; -import com.casic.accessControl.util.DateUtils; +import com.casic.accessControl.util.*; import com.google.gson.Gson; import jxl.*; import jxl.read.biff.BiffException; @@ -31,11 +28,15 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; +import sun.misc.BASE64Decoder; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.File; +import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.text.ParseException; @@ -183,6 +184,53 @@ } /** + * 保存标识器和图片信息 + * @param markerDto + * @param companyId + * @param fileNames + * @param fileBuffers + * @return + */ + public boolean saveMarkerAndPhotos(MarkerDto markerDto, Long companyId, String[] fileNames, String[] fileBuffers) { + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + String strDirPath = request.getSession().getServletContext().getRealPath(""); + FileOutputStream fos = null; + String month = TimeFormat.format(Calendar.getInstance().getTime(), "yyyyMM"); + String webPath = "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String toDir = strDirPath + "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String filePaths = ""; + try { + for (int i = 0; i < fileBuffers.length; i++) { + if (fileBuffers[i] != null && fileNames[i] != null) { +// filePaths += toDir+fileNames[i]+","; + filePaths += webPath + fileNames[i] + ","; + byte[] buffer = new BASE64Decoder().decodeBuffer(fileBuffers[i]); //对android传过来的图片字符串进行解码 + File destDir = new File(toDir); + if (!destDir.exists()) + destDir.mkdirs(); + File imageFile = new File(destDir, fileNames[i]); + fos = new FileOutputStream(imageFile); //保存图片 + fos.write(buffer); + fos.flush(); + fos.close(); + } + } + if (filePaths.endsWith(",")) { + filePaths = filePaths.substring(0, filePaths.length() - 1); + } + } catch (Exception e) { + return false; + } + Marker marker = MarkerDto.convert2Marker(markerDto); + marker.setIsValid(1); + marker.setCompanyId(companyId); + marker.setPhotos(filePaths); + save(marker); + return true; + + } + + /** * 新增标识器 8-9 * * @param markers @@ -582,7 +630,7 @@ "所属区域","所属线路","所属道路","建设年代","权属单位","标示对象ID", "标识器ID","标识器类型","标识器埋深","安装部门","经度", "纬度", "最后修改时间","备注","下层管种类", "下层管埋深", - "下层管直径", "下层管材料", "标识对象类别"}; + "下层管直径", "下层管材料", "标识对象类别", "标识点颜色", "图片地址"}; Label[][] labels = new Label[markerDtos.size() + 1][titleTxt.length]; for(int k=0;k saveMarkerAndPhotos(@RequestParam(value = "fileBuffer1", required = false) MultipartFile fileBuffer1, + @RequestParam(value = "fileBuffer2", required = false) MultipartFile fileBuffer2, + @RequestParam(value = "fileBuffer3", required = false) MultipartFile fileBuffer3, + @RequestParam(value = "jsonMarker", required = true) String jsonMarker) { + Map map = new HashMap(); + map.put("message", "安装无标识器信息"); + Gson gson = new Gson(); + try { + MarkerDto marker = gson.fromJson(jsonMarker, MarkerDto.class); + + if (null == marker.getMarkerId()) { + map.put("message", "无标识器ID"); + map.put("success", "false"); + return map; + } else if (markerManager.getMarkerByMarkerId(marker.getMarkerId()).size() > 0) { + map.put("message", "已安装过该标识器[" + marker.getMarkerId() + "]"); + map.put("success", "false"); + return map; + } else { + String[] fileNames = new String[3]; + String[] fileBuffers = new String[3]; + if (fileBuffer1 != null) { + fileNames[0] = marker.getMarkerId() + "_" + fileBuffer1.getOriginalFilename(); + byte[] fis = fileBuffer1.getBytes(); + fileBuffers[0] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, com.sun.org.apache.xml.internal.security.utils.Base64.BASE64DEFAULTLENGTH)); + } + if (fileBuffer2 != null) { + fileNames[1] = marker.getMarkerId() + "_" + fileBuffer2.getOriginalFilename(); + byte[] fis = fileBuffer2.getBytes(); + fileBuffers[1] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, com.sun.org.apache.xml.internal.security.utils.Base64.BASE64DEFAULTLENGTH)); + } + if (fileBuffer3 != null) { + fileNames[2] = marker.getMarkerId() + "_" + fileBuffer3.getOriginalFilename(); + byte[] fis = fileBuffer3.getBytes(); + fileBuffers[2] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, Base64.BASE64DEFAULTLENGTH)); + } + Long companyId = marker.getCompanyId(); + if (companyId == null) { + return map; + } + boolean result = markerManager.saveMarkerAndPhotos(marker, companyId, fileNames, fileBuffers); + if (!result) { + return map; + } + } + } catch (Exception e) { + return map; + } + map.put("success", "true"); + map.put("message", "保存成功"); + return map; + } + + @RequestMapping("marker-info-delete") @ResponseBody public Map delete(@RequestParam(value = "id", required = true) Long id) { @@ -144,6 +208,9 @@ map.put("message", "删除需要ID信息"); return map; } + + System.out.println(ids); + markerManager.delMarkerByIds(ids); map.put("success", true); map.put("message", "删除成功"); @@ -240,6 +307,54 @@ return map; } + /** + * 批量上传标识点,用于无信号地区标识器信息统一上传,不修改已有标识点信息 + * @param strMarkers + * @return + */ + @RequestMapping("batch-save-no-update") + @ResponseBody + public Map batchSaveOrUpdate(@RequestParam(value = "markers", required = true) String strMarkers) { + strMarkers = strMarkers.replace('\n',' '); + Map map = new HashMap(); + map.put("message", "批量导入失败,或无导入标识器信息"); + Gson gson = new Gson(); + try { + List markers = gson.fromJson(strMarkers, new TypeToken>() { + }.getType()); + if (CollectionUtils.isEmpty(markers)) {//批量导入数据不存在,直接返回 + map.put("message", "批量导入数据不存在"); + return map; + } + + Long companyId = markers.get(0).getCompanyId(); + if (companyId == null) { + map.put("message", "未找到所属公司属性"); + return map; + } + + List markerDtoForSave = new ArrayList(); + for (MarkerDto markerDto : markers) { + // 上传marker的Id不为空且数据库中不存在记录,经纬度不为空,允许保存 + if (StringUtils.isNotBlank(markerDto.getMarkerId()) && markerManager.getMarkerByMarkerId(markerDto.getMarkerId()).size() <= 0) { + if (null != markerDto.getLongitude() && null != markerDto.getLatitude()) { + markerDtoForSave.add(markerDto); + } + } + } + boolean result = markerManager.batchSave(markerDtoForSave, companyId); + if (!result) { + return map; + } + } catch (Exception e) { + e.printStackTrace(); + return map; + } + map.put("success", true); + map.put("message", "保存成功"); + return map; + } + @RequestMapping("getMarkerListByCondition") @ResponseBody @POST diff --git a/src/main/java/com/casic/accessControl/user/web/UserController.java b/src/main/java/com/casic/accessControl/user/web/UserController.java index feab678..3534a97 100644 --- a/src/main/java/com/casic/accessControl/user/web/UserController.java +++ b/src/main/java/com/casic/accessControl/user/web/UserController.java @@ -46,6 +46,7 @@ @ResponseBody public Map login(@ModelAttribute User userInfo, HttpSession session) { Map result = new HashMap(); + User user = null; try{ user = userManager.login(userInfo); diff --git a/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java b/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java new file mode 100644 index 0000000..582120f --- /dev/null +++ b/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java @@ -0,0 +1,129 @@ +package com.casic.accessControl.util; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.net.URL; +import java.net.URLConnection; +import java.util.List; +import java.util.Map; + +/** + * Created by lenovo on 2016/8/31. + */ +public class HttpRequestUtils { + + /** + * 向指定URL发送GET方法的请求 + * + * @param url + * 发送请求的URL + * @param param + * 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 + * @return URL 所代表远程资源的响应结果 + */ + public static String sendGet(String url, String param) { + String result = ""; + BufferedReader in = null; + try { + String urlNameString = url + "?" + param; + URL realUrl = new URL(urlNameString); + // 打开和URL之间的连接 + URLConnection connection = realUrl.openConnection(); + // 设置通用的请求属性 + connection.setRequestProperty("accept", "*/*"); + connection.setRequestProperty("connection", "Keep-Alive"); + connection.setRequestProperty("user-agent", + "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + // 建立实际的连接 + connection.connect(); + // 获取所有响应头字段 + Map> map = connection.getHeaderFields(); + // 遍历所有的响应头字段 + for (String key : map.keySet()) { + System.out.println(key + "--->" + map.get(key)); + } + // 定义 BufferedReader输入流来读取URL的响应 + in = new BufferedReader(new InputStreamReader( + connection.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + result += line; + } + } catch (Exception e) { + System.out.println("发送GET请求出现异常!" + e); + e.printStackTrace(); + } + // 使用finally块来关闭输入流 + finally { + try { + if (in != null) { + in.close(); + } + } catch (Exception e2) { + e2.printStackTrace(); + } + } + return result; + } + + /** + * 向指定 URL 发送POST方法的请求 + * + * @param url + * 发送请求的 URL + * @param param + * 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 + * @return 所代表远程资源的响应结果 + */ + public static String sendPost(String url, String param) { + PrintWriter out = null; + BufferedReader in = null; + String result = ""; + try { + URL realUrl = new URL(url); + // 打开和URL之间的连接 + URLConnection conn = realUrl.openConnection(); + // 设置通用的请求属性 + conn.setRequestProperty("accept", "*/*"); + conn.setRequestProperty("connection", "Keep-Alive"); + conn.setRequestProperty("user-agent", + "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + // 发送POST请求必须设置如下两行 + conn.setDoOutput(true); + conn.setDoInput(true); + // 获取URLConnection对象对应的输出流 + out = new PrintWriter(conn.getOutputStream()); + // 发送请求参数 + out.print(param); + // flush输出流的缓冲 + out.flush(); + // 定义BufferedReader输入流来读取URL的响应 + in = new BufferedReader( + new InputStreamReader(conn.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + result += line; + } + } catch (Exception e) { + System.out.println("发送 POST 请求出现异常!"+e); + e.printStackTrace(); + } + //使用finally块来关闭输出流、输入流 + finally{ + try{ + if(out!=null){ + out.close(); + } + if(in!=null){ + in.close(); + } + } + catch(IOException ex){ + ex.printStackTrace(); + } + } + return result; + } + } \ No newline at end of file diff --git a/src/main/java/com/casic/accessControl/util/TimeFormat.java b/src/main/java/com/casic/accessControl/util/TimeFormat.java new file mode 100644 index 0000000..e9168d5 --- /dev/null +++ b/src/main/java/com/casic/accessControl/util/TimeFormat.java @@ -0,0 +1,148 @@ +package com.casic.accessControl.util; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +/** + * 格式化日期工具类 + * 默认模式yyyy-MM-dd HH:mm:ss + * @author Administrator + * + */ +public class TimeFormat { + + private static final String DATE_FORMAT_STRING = "yyyy-MM-dd"; + private static final String TIME_FORMAT_STRING = "HH:mm:ss"; + private static final String TIMESTAMP_FORMAT_STRING = "yyyy-MM-dd HH:mm:ss"; + + // 默认格式化格式 + private static SimpleDateFormat defaultFormat = new SimpleDateFormat(TIMESTAMP_FORMAT_STRING); + + public static void setFormatString(String pattern) { + defaultFormat.applyPattern(pattern); + } + + /** + * 默认格式化日期 + * + * @param Date date + * @return String + */ + public static String format(Date date) { + return defaultFormat.format(date); + } + + /** + * 日期格式化 + * + * @param date + * @return + */ + public static String formatDate(Date date) { + return TimeFormat.format(date, DATE_FORMAT_STRING); + } + + /** + * 时间格式化 + * + * @param date + * @return + */ + public static String formatTime(Date date) { + return TimeFormat.format(date, TIME_FORMAT_STRING); + } + + /** + * 时间戳格式化 + * + * @param date + * @return + */ + public static String formatTimestamp(Date date) { + return TimeFormat.format(date, TIMESTAMP_FORMAT_STRING); + } + + /** + * 以指定模式格式化日期 + * + * @param Date date + * @param String pattern + * @return String + */ + public static String format(Date date, String pattern) { + SimpleDateFormat formatter = new SimpleDateFormat(pattern); + return formatter.format(date); + } + + /** + * 根据起止日期生成日期序列 + * 包括start和end的日期 + * + * @param start + * @param end + * @return + */ + public static List generateDates(String start, String end) throws ParseException { + List dates = new ArrayList(); + Calendar s = Calendar.getInstance(); + Calendar e = Calendar.getInstance(); + s.setTime(TimeFormat.parse(start, DATE_FORMAT_STRING)); + s.set(Calendar.HOUR_OF_DAY, 0); + s.set(Calendar.MINUTE, 0); + s.set(Calendar.SECOND, 0); + e.setTime(TimeFormat.parse(end, DATE_FORMAT_STRING)); + e.set(Calendar.HOUR_OF_DAY, 0); + e.set(Calendar.MINUTE, 0); + e.set(Calendar.SECOND, 0); + while (s.before(e) == true) { + dates.add(TimeFormat.formatDate(s.getTime())); + s.add(Calendar.DATE, 1); + } + + dates.add(end); + return dates; + } + + + /** + * 解析日期字符串 + * + * @param String source + * @return Date + * + * @throws ParseException + */ + public static Date parse(String source) throws ParseException { + return defaultFormat.parse(source); + } + + /** + * 以指定模式解析日期 + * + * @param String source + * @param String pattern + * @return Date + * + * @throws ParseException + */ + public static Date parse(String source, String pattern) throws ParseException { + SimpleDateFormat formatter = new SimpleDateFormat(pattern); + return formatter.parse(source); + } + + + public static Date parseDateWithoutTime(String source) throws ParseException { + SimpleDateFormat formatter = new SimpleDateFormat(DATE_FORMAT_STRING); + Calendar date = Calendar.getInstance(); + date.setTime(formatter.parse(source)); + date.set(Calendar.HOUR, 0); + date.set(Calendar.HOUR, 0); + date.set(Calendar.MINUTE, 0); + return date.getTime(); + } + +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 53c91ea..cea976f 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -15,19 +15,17 @@ # ============================================================================ # db # ============================================================================ -#db.default.driverClassName=oracle.jdbc.driver.OracleDriver -#db.default.url=jdbc:oracle:thin:@192.168.0.203:1521:SZHTDB2 -#db.default.username=scott -#db.default.password=SZHTDB2 db.default.driverClassName=com.mysql.jdbc.Driver -db.default.url=jdbc:mysql://127.0.0.1:3306/ems?useUnicode=true&characterEncoding=UTF-8 -db.default.username=emsweb -db.default.password=emsweb +db.default.url=jdbc:mysql://127.0.0.1:3306/ems_tong?useUnicode=true&characterEncoding=UTF-8 +db.default.username=root +db.default.password=root +#db.default.username=emsweb +#db.default.password=emsweb #db.default.url=jdbc:mysql://119.254.110.71:3307/ems?useUnicode=true&characterEncoding=UTF-8 #db.default.username=root #db.default.password=rootems - -# ============================================================================ +# +## ============================================================================ # log4jdbc # ============================================================================ log4jdbc.enable=true diff --git a/src/main/resources/spring/applicationContext-filter.xml b/src/main/resources/spring/applicationContext-filter.xml index a08c5fc..98ac7d6 100644 --- a/src/main/resources/spring/applicationContext-filter.xml +++ b/src/main/resources/spring/applicationContext-filter.xml @@ -35,9 +35,13 @@ /user/ill-login.do /marker/exportMarker.do /marker/batchSave-na.do + /marker/batch-save-no-update.do + /marker/save-marker-photo.do /event/save-event.do /task/get-task.do + /app/get-latest-version.do /xls/* + /apk/* diff --git a/src/main/resources/spring/applicationContext-hibernate.xml b/src/main/resources/spring/applicationContext-hibernate.xml index 5bb1a7e..dc54192 100644 --- a/src/main/resources/spring/applicationContext-hibernate.xml +++ b/src/main/resources/spring/applicationContext-hibernate.xml @@ -65,6 +65,7 @@ com.casic.accessControl.task.domain.Position com.casic.accessControl.event.domain.Event com.casic.accessControl.marker.domain.OptionItem + com.casic.accessControl.app.domain.ApkVersion diff --git a/src/main/webapp/common/layout/menu_new.jsp b/src/main/webapp/common/layout/menu_new.jsp index 3cf4b4e..cbd822e 100644 --- a/src/main/webapp/common/layout/menu_new.jsp +++ b/src/main/webapp/common/layout/menu_new.jsp @@ -20,7 +20,7 @@
                              • - + @@ -54,7 +54,7 @@
                              • - + diff --git a/src/main/webapp/content/ems/ems-gd.jsp b/src/main/webapp/content/ems/ems-gd.jsp new file mode 100644 index 0000000..5137b49 --- /dev/null +++ b/src/main/webapp/content/ems/ems-gd.jsp @@ -0,0 +1,604 @@ +<%@page contentType="text/html;charset=UTF-8" %> + +<%@include file="/taglibs.jsp" %> + +<%pageContext.setAttribute("currentMenu", "ems");%> + + + + + + + + + + + + + 地下管线电子标识系统 + + + + + + + + + + + + + + + + + + +<%-- + +--%> + + + + + + + + + + + + + + +<%@include file="/common/layout/header.jsp" %> + +
                                + + + + <%@include file="/common/layout/menu_new.jsp" %> + + + +
                                + + + +
                                + +
                                + + +
                                +
                                +
                                +
                                + +
                                +
                                + +
                                +
                                + +
                                +
                                + +
                                +
                                + +
                                + +
                                + +
                                + +
                                + +
                                + +
                                +
                                +
                                + + + + +
                                +
                                +
                                +
                                + + + + +
                                +
                                +
                                + +
                                + +
                                + +<%--todo list:错误使用方法 + +--%> +
                                + +
                                +
                                + +
                                + +
                                + +
                                + + +
                                + +
                                + + 移动 + 绘制区域 + 新增标识器 + 删除标识器 + 保存标识器 + 批量导入 + 导出Excel + 清空 + +
                                + +
                                +
                                + +
                                + + + +
                                + +
                                + +
                                + + + + +
                                + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/webapp/content/task/task-gd.jsp b/src/main/webapp/content/task/task-gd.jsp new file mode 100644 index 0000000..d2d5549 --- /dev/null +++ b/src/main/webapp/content/task/task-gd.jsp @@ -0,0 +1,374 @@ +<%@page contentType="text/html;charset=UTF-8" %> + +<%@include file="/taglibs.jsp" %> + +<%pageContext.setAttribute("currentMenu", "task");%> + + + + + + + + + + + + + 地下管线电子标识系统 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +<%@include file="/common/layout/header.jsp" %> + +
                                + + + + <%@include file="/common/layout/menu_new.jsp" %> + + + +
                                + + + +
                                + +
                                + +
                                + + 移动 + 绘制区域 + 选择多点创建工单 + 清空选择 + +
                                + +
                                + +
                                + + +
                                + +
                                + +
                                + +
                                历史工单
                                + +
                                + +
                                + +
                                + <%--巡检员:--%> +
                                +
                                + + +
                                +
                                + + +
                                  +
                                +
                                  +
                                  + +
                                  + +
                                  + +
                                  + +
                                  +
                                  + +
                                  + + + +
                                  + +
                                  + +
                                  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/webapp/images/drop/0.png b/src/main/webapp/images/drop/0.png new file mode 100644 index 0000000..f4b966b --- /dev/null +++ b/src/main/webapp/images/drop/0.png Binary files differ diff --git a/src/main/webapp/images/drop/1.png b/src/main/webapp/images/drop/1.png new file mode 100644 index 0000000..9284b64 --- /dev/null +++ b/src/main/webapp/images/drop/1.png Binary files differ diff --git a/src/main/webapp/images/drop/2.png b/src/main/webapp/images/drop/2.png new file mode 100644 index 0000000..b5425db --- /dev/null +++ b/src/main/webapp/images/drop/2.png Binary files differ diff --git a/src/main/webapp/images/drop/3.png b/src/main/webapp/images/drop/3.png new file mode 100644 index 0000000..dd09655 --- /dev/null +++ b/src/main/webapp/images/drop/3.png Binary files differ diff --git a/src/main/webapp/images/drop/4.png b/src/main/webapp/images/drop/4.png new file mode 100644 index 0000000..50cf1f7 --- /dev/null +++ b/src/main/webapp/images/drop/4.png Binary files differ diff --git a/src/main/webapp/images/drop/5.png b/src/main/webapp/images/drop/5.png new file mode 100644 index 0000000..a2029bd --- /dev/null +++ b/src/main/webapp/images/drop/5.png Binary files differ diff --git a/src/main/webapp/images/drop/6.png b/src/main/webapp/images/drop/6.png new file mode 100644 index 0000000..b53248a --- /dev/null +++ b/src/main/webapp/images/drop/6.png Binary files differ diff --git a/src/main/webapp/images/ems/point.png b/src/main/webapp/images/ems/point.png new file mode 100644 index 0000000..a814351 --- /dev/null +++ b/src/main/webapp/images/ems/point.png Binary files differ diff --git a/src/main/webapp/images/ems/rect.png b/src/main/webapp/images/ems/rect.png new file mode 100644 index 0000000..99d0c9e --- /dev/null +++ b/src/main/webapp/images/ems/rect.png Binary files differ diff --git a/src/main/webapp/images/events/red_icon.png b/src/main/webapp/images/events/red_icon.png new file mode 100644 index 0000000..78c26e4 --- /dev/null +++ b/src/main/webapp/images/events/red_icon.png Binary files differ diff --git a/src/main/webapp/images/point-task.png b/src/main/webapp/images/point-task.png new file mode 100644 index 0000000..b2e22c6 --- /dev/null +++ b/src/main/webapp/images/point-task.png Binary files differ diff --git a/src/main/webapp/images/point.png b/src/main/webapp/images/point.png new file mode 100644 index 0000000..4b887dc --- /dev/null +++ b/src/main/webapp/images/point.png Binary files differ diff --git a/src/main/webapp/images/tasks/point.png b/src/main/webapp/images/tasks/point.png new file mode 100644 index 0000000..a814351 --- /dev/null +++ b/src/main/webapp/images/tasks/point.png Binary files differ diff --git a/src/main/webapp/images/tasks/rect.png b/src/main/webapp/images/tasks/rect.png new file mode 100644 index 0000000..99d0c9e --- /dev/null +++ b/src/main/webapp/images/tasks/rect.png Binary files differ diff --git a/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java new file mode 100644 index 0000000..634ceae --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java @@ -0,0 +1,46 @@ +package com.casic.accessControl.app.domain; + +import javax.persistence.*; +import java.util.Date; + +/** + * app的版本信息 + */ +//工单 +@Entity +@Table(name = "apkVersion") +public class ApkVersion { + private String version; + private String path; + private Date ts;//时间戳 + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "version") + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + @Column(name = "path") + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + @Column(name = "ts") + public Date getTs() { + return ts; + } + + public void setTs(Date ts) { + this.ts = ts; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java new file mode 100644 index 0000000..1d0242a --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java @@ -0,0 +1,50 @@ +package com.casic.accessControl.app.dto; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.util.TimeFormat; + +/** + * Created by lenovo on 2016/4/13. + */ +public class ApkVersionDto { + private String version; + private String path; + private String ts; + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public String getTs() { + return ts; + } + + public void setTs(String ts) { + this.ts = ts; + } + + public static ApkVersionDto Convert(ApkVersion version) { + if (version == null) { + return null; + } + ApkVersionDto versionDto = new ApkVersionDto(); + versionDto.setVersion(version.getVersion()); + versionDto.setPath(version.getVersion()); + versionDto.setTs(TimeFormat.formatTimestamp(version.getTs())); + + return versionDto; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java b/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java new file mode 100644 index 0000000..28b12a7 --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java @@ -0,0 +1,27 @@ +package com.casic.accessControl.app.manager; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.core.hibernate.HibernateEntityDao; +import org.hibernate.Query; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * + */ +@Service("apkVersionManager") +public class ApkVersionManager extends HibernateEntityDao { + + public ApkVersion getLatestVersion() { + String sql = "from ApkVersion order by ts desc"; + Query query = getSession().createQuery(sql); + List list = query.list(); + if (null != list && list.isEmpty() == false) { + return list.get(0); + } + + return null; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java b/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java new file mode 100644 index 0000000..065d3cc --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java @@ -0,0 +1,66 @@ +package com.casic.accessControl.app.web; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.app.manager.ApkVersionManager; +import com.casic.accessControl.marker.domain.Marker; +import com.casic.accessControl.marker.manager.MarkerManager; +import com.casic.accessControl.task.domain.Task; +import com.casic.accessControl.task.domain.TaskDetail; +import com.casic.accessControl.task.dto.TaskDetailDto; +import com.casic.accessControl.task.dto.TaskDto; +import com.casic.accessControl.task.dto.TaskStatus; +import com.casic.accessControl.task.manager.TaskDetailManager; +import com.casic.accessControl.task.manager.TaskManager; +import com.casic.accessControl.user.domain.Company; +import com.casic.accessControl.user.domain.Role; +import com.casic.accessControl.user.domain.User; +import com.casic.accessControl.user.dto.UserDto; +import com.casic.accessControl.user.manager.RoleManager; +import com.casic.accessControl.user.manager.UserManager; +import com.casic.accessControl.util.DataTable; +import com.casic.accessControl.util.StringUtils; +import com.google.gson.Gson; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +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.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * Created by lenovo on 2016/4/13. + */ +@Controller +@RequestMapping("app") +public class ApkVersionController { + + @Resource + private ApkVersionManager apkVersionManager; + + @RequestMapping("get-latest-version") + @ResponseBody + public Map getLatestVersion(HttpServletResponse response, HttpSession session) { + Map result = new HashMap(); + try { + ApkVersion latest = apkVersionManager.getLatestVersion(); + if (null != latest) { + result.put("version", latest.getVersion()); + result.put("path", latest.getPath()); + } else { + result.put("version", "1.0.0"); + } + } catch (Exception e) { + e.printStackTrace(); + result.put("version", "1.0.0"); + } + + return result; + } + +} diff --git a/src/main/java/com/casic/accessControl/marker/domain/Marker.java b/src/main/java/com/casic/accessControl/marker/domain/Marker.java index 0575cfe..7d5b854 100644 --- a/src/main/java/com/casic/accessControl/marker/domain/Marker.java +++ b/src/main/java/com/casic/accessControl/marker/domain/Marker.java @@ -67,6 +67,10 @@ private String area; @Column(name = "line") private String line; + @Column(name = "colorType") + private String colorType; + @Column(name = "photos") + private String photos; @@ -315,4 +319,20 @@ public void setArea(String area) { this.area = area; } + + public String getColorType() { + return colorType; + } + + public void setColorType(String colorType) { + this.colorType = colorType; + } + + public String getPhotos() { + return photos; + } + + public void setPhotos(String photos) { + this.photos = photos; + } } diff --git a/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java b/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java index 506f31d..c5f8cf5 100644 --- a/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java +++ b/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java @@ -2,12 +2,12 @@ //import com.casic.accessControl.feature.domain.Feature; import com.casic.accessControl.marker.domain.Marker; +import com.casic.accessControl.util.StringUtils; +import com.casic.accessControl.util.TimeFormat; import org.apache.commons.collections.CollectionUtils; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.List; +import java.text.ParseException; +import java.util.*; /** * Created by lenovo on 2016/5/16. @@ -43,6 +43,8 @@ private Long userId; private String area; private String line; + private String colorType; + private String photos; private String btnEdit = "编辑"; private String btnDelete = "删除"; @@ -296,6 +298,23 @@ this.area = area; } + public String getColorType() { + if (StringUtils.isEmpty(colorType)) return "0"; + return colorType; + } + + public void setColorType(String colorType) { + this.colorType = colorType; + } + + public String getPhotos() { + return photos; + } + + public void setPhotos(String photos) { + this.photos = photos; + } + public String getLine() { return line; } @@ -335,6 +354,52 @@ result.setRoad(doNullChange(marker.getRoad())); result.setArea(doNullChange(marker.getArea())); result.setLine(doNullChange(marker.getLine())); + result.setColorType(marker.getColorType()); + result.setPhotos(marker.getPhotos()); + return result; + } + + public static Marker convert2Marker(MarkerDto markerDto) { + if (markerDto == null) return null; + Marker result = new Marker(); + if(markerDto.getLongitude()==null||markerDto.getLatitude()==null) return null; + if (null != markerDto.getCreateTime() && markerDto.getCreateTime().length() == 19) { + try { + result.setCreateTime(TimeFormat.parse(markerDto.getCreateTime(), "yyyy-MM-dd HH:mm:ss")); + } catch (ParseException pex) { + result.setCreateTime(Calendar.getInstance().getTime()); + } + } else { + result.setCreateTime(Calendar.getInstance().getTime()); + } + result.setDepth(doNullChange(markerDto.getDepth())); + result.setId(markerDto.getId()); + result.setLatitude(markerDto.getLatitude()); + result.setLongitude(markerDto.getLongitude()); + result.setMarkerId(markerDto.getMarkerId()); + result.setMarkerDepth(doNullChange(markerDto.getMarkerDepth())); + result.setMarkerObjectId(doNullChange(markerDto.getMarkerObjectId())); + result.setMarkerObjectType(doNullChange(markerDto.getMarkerObjectType())); + result.setOwnerComp(doNullChange(markerDto.getOwnerComp())); + result.setIsValid(markerDto.getIsValid()); + result.setMemo(doNullChange(markerDto.getMemo())); + result.setPipeDiameter(doNullChange(markerDto.getPipeDiameter())); + result.setPipeMaterial(doNullChange(markerDto.getPipeMaterial())); + result.setMarkerType(doNullChange(markerDto.getMarkerType())); + result.setCreator(doNullChange(markerDto.getCreator())); + + result.setLayStyle(doNullChange(markerDto.getLayStyle())); + result.setBelowDepth(doNullChange(markerDto.getBelowDepth())); + result.setBelowDiameter(doNullChange(markerDto.getBelowDiameter())); + result.setBelowMaterial(doNullChange(markerDto.getBelowMaterial())); + result.setBelowType(doNullChange(markerDto.getBelowType())); + result.setConstructTime(doNullChange(markerDto.getConstructTime())); + result.setRecordType(markerDto.getRecordType()); + result.setRoad(doNullChange(markerDto.getRoad())); + result.setArea(doNullChange(markerDto.getArea())); + result.setLine(doNullChange(markerDto.getLine())); + result.setColorType(markerDto.getColorType()); + result.setPhotos(markerDto.getPhotos()); return result; } diff --git a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java index dd0fa4b..ba5a1fb 100644 --- a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java +++ b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java @@ -9,10 +9,7 @@ import com.casic.accessControl.marker.domain.Marker; import com.casic.accessControl.user.domain.Company; import com.casic.accessControl.user.domain.User; -import com.casic.accessControl.util.DataTable; -import com.casic.accessControl.util.DataTableParameter; -import com.casic.accessControl.util.DataTableUtils; -import com.casic.accessControl.util.DateUtils; +import com.casic.accessControl.util.*; import com.google.gson.Gson; import jxl.*; import jxl.read.biff.BiffException; @@ -31,11 +28,15 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; +import sun.misc.BASE64Decoder; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.File; +import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.text.ParseException; @@ -183,6 +184,53 @@ } /** + * 保存标识器和图片信息 + * @param markerDto + * @param companyId + * @param fileNames + * @param fileBuffers + * @return + */ + public boolean saveMarkerAndPhotos(MarkerDto markerDto, Long companyId, String[] fileNames, String[] fileBuffers) { + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + String strDirPath = request.getSession().getServletContext().getRealPath(""); + FileOutputStream fos = null; + String month = TimeFormat.format(Calendar.getInstance().getTime(), "yyyyMM"); + String webPath = "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String toDir = strDirPath + "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String filePaths = ""; + try { + for (int i = 0; i < fileBuffers.length; i++) { + if (fileBuffers[i] != null && fileNames[i] != null) { +// filePaths += toDir+fileNames[i]+","; + filePaths += webPath + fileNames[i] + ","; + byte[] buffer = new BASE64Decoder().decodeBuffer(fileBuffers[i]); //对android传过来的图片字符串进行解码 + File destDir = new File(toDir); + if (!destDir.exists()) + destDir.mkdirs(); + File imageFile = new File(destDir, fileNames[i]); + fos = new FileOutputStream(imageFile); //保存图片 + fos.write(buffer); + fos.flush(); + fos.close(); + } + } + if (filePaths.endsWith(",")) { + filePaths = filePaths.substring(0, filePaths.length() - 1); + } + } catch (Exception e) { + return false; + } + Marker marker = MarkerDto.convert2Marker(markerDto); + marker.setIsValid(1); + marker.setCompanyId(companyId); + marker.setPhotos(filePaths); + save(marker); + return true; + + } + + /** * 新增标识器 8-9 * * @param markers @@ -582,7 +630,7 @@ "所属区域","所属线路","所属道路","建设年代","权属单位","标示对象ID", "标识器ID","标识器类型","标识器埋深","安装部门","经度", "纬度", "最后修改时间","备注","下层管种类", "下层管埋深", - "下层管直径", "下层管材料", "标识对象类别"}; + "下层管直径", "下层管材料", "标识对象类别", "标识点颜色", "图片地址"}; Label[][] labels = new Label[markerDtos.size() + 1][titleTxt.length]; for(int k=0;k saveMarkerAndPhotos(@RequestParam(value = "fileBuffer1", required = false) MultipartFile fileBuffer1, + @RequestParam(value = "fileBuffer2", required = false) MultipartFile fileBuffer2, + @RequestParam(value = "fileBuffer3", required = false) MultipartFile fileBuffer3, + @RequestParam(value = "jsonMarker", required = true) String jsonMarker) { + Map map = new HashMap(); + map.put("message", "安装无标识器信息"); + Gson gson = new Gson(); + try { + MarkerDto marker = gson.fromJson(jsonMarker, MarkerDto.class); + + if (null == marker.getMarkerId()) { + map.put("message", "无标识器ID"); + map.put("success", "false"); + return map; + } else if (markerManager.getMarkerByMarkerId(marker.getMarkerId()).size() > 0) { + map.put("message", "已安装过该标识器[" + marker.getMarkerId() + "]"); + map.put("success", "false"); + return map; + } else { + String[] fileNames = new String[3]; + String[] fileBuffers = new String[3]; + if (fileBuffer1 != null) { + fileNames[0] = marker.getMarkerId() + "_" + fileBuffer1.getOriginalFilename(); + byte[] fis = fileBuffer1.getBytes(); + fileBuffers[0] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, com.sun.org.apache.xml.internal.security.utils.Base64.BASE64DEFAULTLENGTH)); + } + if (fileBuffer2 != null) { + fileNames[1] = marker.getMarkerId() + "_" + fileBuffer2.getOriginalFilename(); + byte[] fis = fileBuffer2.getBytes(); + fileBuffers[1] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, com.sun.org.apache.xml.internal.security.utils.Base64.BASE64DEFAULTLENGTH)); + } + if (fileBuffer3 != null) { + fileNames[2] = marker.getMarkerId() + "_" + fileBuffer3.getOriginalFilename(); + byte[] fis = fileBuffer3.getBytes(); + fileBuffers[2] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, Base64.BASE64DEFAULTLENGTH)); + } + Long companyId = marker.getCompanyId(); + if (companyId == null) { + return map; + } + boolean result = markerManager.saveMarkerAndPhotos(marker, companyId, fileNames, fileBuffers); + if (!result) { + return map; + } + } + } catch (Exception e) { + return map; + } + map.put("success", "true"); + map.put("message", "保存成功"); + return map; + } + + @RequestMapping("marker-info-delete") @ResponseBody public Map delete(@RequestParam(value = "id", required = true) Long id) { @@ -144,6 +208,9 @@ map.put("message", "删除需要ID信息"); return map; } + + System.out.println(ids); + markerManager.delMarkerByIds(ids); map.put("success", true); map.put("message", "删除成功"); @@ -240,6 +307,54 @@ return map; } + /** + * 批量上传标识点,用于无信号地区标识器信息统一上传,不修改已有标识点信息 + * @param strMarkers + * @return + */ + @RequestMapping("batch-save-no-update") + @ResponseBody + public Map batchSaveOrUpdate(@RequestParam(value = "markers", required = true) String strMarkers) { + strMarkers = strMarkers.replace('\n',' '); + Map map = new HashMap(); + map.put("message", "批量导入失败,或无导入标识器信息"); + Gson gson = new Gson(); + try { + List markers = gson.fromJson(strMarkers, new TypeToken>() { + }.getType()); + if (CollectionUtils.isEmpty(markers)) {//批量导入数据不存在,直接返回 + map.put("message", "批量导入数据不存在"); + return map; + } + + Long companyId = markers.get(0).getCompanyId(); + if (companyId == null) { + map.put("message", "未找到所属公司属性"); + return map; + } + + List markerDtoForSave = new ArrayList(); + for (MarkerDto markerDto : markers) { + // 上传marker的Id不为空且数据库中不存在记录,经纬度不为空,允许保存 + if (StringUtils.isNotBlank(markerDto.getMarkerId()) && markerManager.getMarkerByMarkerId(markerDto.getMarkerId()).size() <= 0) { + if (null != markerDto.getLongitude() && null != markerDto.getLatitude()) { + markerDtoForSave.add(markerDto); + } + } + } + boolean result = markerManager.batchSave(markerDtoForSave, companyId); + if (!result) { + return map; + } + } catch (Exception e) { + e.printStackTrace(); + return map; + } + map.put("success", true); + map.put("message", "保存成功"); + return map; + } + @RequestMapping("getMarkerListByCondition") @ResponseBody @POST diff --git a/src/main/java/com/casic/accessControl/user/web/UserController.java b/src/main/java/com/casic/accessControl/user/web/UserController.java index feab678..3534a97 100644 --- a/src/main/java/com/casic/accessControl/user/web/UserController.java +++ b/src/main/java/com/casic/accessControl/user/web/UserController.java @@ -46,6 +46,7 @@ @ResponseBody public Map login(@ModelAttribute User userInfo, HttpSession session) { Map result = new HashMap(); + User user = null; try{ user = userManager.login(userInfo); diff --git a/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java b/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java new file mode 100644 index 0000000..582120f --- /dev/null +++ b/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java @@ -0,0 +1,129 @@ +package com.casic.accessControl.util; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.net.URL; +import java.net.URLConnection; +import java.util.List; +import java.util.Map; + +/** + * Created by lenovo on 2016/8/31. + */ +public class HttpRequestUtils { + + /** + * 向指定URL发送GET方法的请求 + * + * @param url + * 发送请求的URL + * @param param + * 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 + * @return URL 所代表远程资源的响应结果 + */ + public static String sendGet(String url, String param) { + String result = ""; + BufferedReader in = null; + try { + String urlNameString = url + "?" + param; + URL realUrl = new URL(urlNameString); + // 打开和URL之间的连接 + URLConnection connection = realUrl.openConnection(); + // 设置通用的请求属性 + connection.setRequestProperty("accept", "*/*"); + connection.setRequestProperty("connection", "Keep-Alive"); + connection.setRequestProperty("user-agent", + "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + // 建立实际的连接 + connection.connect(); + // 获取所有响应头字段 + Map> map = connection.getHeaderFields(); + // 遍历所有的响应头字段 + for (String key : map.keySet()) { + System.out.println(key + "--->" + map.get(key)); + } + // 定义 BufferedReader输入流来读取URL的响应 + in = new BufferedReader(new InputStreamReader( + connection.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + result += line; + } + } catch (Exception e) { + System.out.println("发送GET请求出现异常!" + e); + e.printStackTrace(); + } + // 使用finally块来关闭输入流 + finally { + try { + if (in != null) { + in.close(); + } + } catch (Exception e2) { + e2.printStackTrace(); + } + } + return result; + } + + /** + * 向指定 URL 发送POST方法的请求 + * + * @param url + * 发送请求的 URL + * @param param + * 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 + * @return 所代表远程资源的响应结果 + */ + public static String sendPost(String url, String param) { + PrintWriter out = null; + BufferedReader in = null; + String result = ""; + try { + URL realUrl = new URL(url); + // 打开和URL之间的连接 + URLConnection conn = realUrl.openConnection(); + // 设置通用的请求属性 + conn.setRequestProperty("accept", "*/*"); + conn.setRequestProperty("connection", "Keep-Alive"); + conn.setRequestProperty("user-agent", + "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + // 发送POST请求必须设置如下两行 + conn.setDoOutput(true); + conn.setDoInput(true); + // 获取URLConnection对象对应的输出流 + out = new PrintWriter(conn.getOutputStream()); + // 发送请求参数 + out.print(param); + // flush输出流的缓冲 + out.flush(); + // 定义BufferedReader输入流来读取URL的响应 + in = new BufferedReader( + new InputStreamReader(conn.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + result += line; + } + } catch (Exception e) { + System.out.println("发送 POST 请求出现异常!"+e); + e.printStackTrace(); + } + //使用finally块来关闭输出流、输入流 + finally{ + try{ + if(out!=null){ + out.close(); + } + if(in!=null){ + in.close(); + } + } + catch(IOException ex){ + ex.printStackTrace(); + } + } + return result; + } + } \ No newline at end of file diff --git a/src/main/java/com/casic/accessControl/util/TimeFormat.java b/src/main/java/com/casic/accessControl/util/TimeFormat.java new file mode 100644 index 0000000..e9168d5 --- /dev/null +++ b/src/main/java/com/casic/accessControl/util/TimeFormat.java @@ -0,0 +1,148 @@ +package com.casic.accessControl.util; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +/** + * 格式化日期工具类 + * 默认模式yyyy-MM-dd HH:mm:ss + * @author Administrator + * + */ +public class TimeFormat { + + private static final String DATE_FORMAT_STRING = "yyyy-MM-dd"; + private static final String TIME_FORMAT_STRING = "HH:mm:ss"; + private static final String TIMESTAMP_FORMAT_STRING = "yyyy-MM-dd HH:mm:ss"; + + // 默认格式化格式 + private static SimpleDateFormat defaultFormat = new SimpleDateFormat(TIMESTAMP_FORMAT_STRING); + + public static void setFormatString(String pattern) { + defaultFormat.applyPattern(pattern); + } + + /** + * 默认格式化日期 + * + * @param Date date + * @return String + */ + public static String format(Date date) { + return defaultFormat.format(date); + } + + /** + * 日期格式化 + * + * @param date + * @return + */ + public static String formatDate(Date date) { + return TimeFormat.format(date, DATE_FORMAT_STRING); + } + + /** + * 时间格式化 + * + * @param date + * @return + */ + public static String formatTime(Date date) { + return TimeFormat.format(date, TIME_FORMAT_STRING); + } + + /** + * 时间戳格式化 + * + * @param date + * @return + */ + public static String formatTimestamp(Date date) { + return TimeFormat.format(date, TIMESTAMP_FORMAT_STRING); + } + + /** + * 以指定模式格式化日期 + * + * @param Date date + * @param String pattern + * @return String + */ + public static String format(Date date, String pattern) { + SimpleDateFormat formatter = new SimpleDateFormat(pattern); + return formatter.format(date); + } + + /** + * 根据起止日期生成日期序列 + * 包括start和end的日期 + * + * @param start + * @param end + * @return + */ + public static List generateDates(String start, String end) throws ParseException { + List dates = new ArrayList(); + Calendar s = Calendar.getInstance(); + Calendar e = Calendar.getInstance(); + s.setTime(TimeFormat.parse(start, DATE_FORMAT_STRING)); + s.set(Calendar.HOUR_OF_DAY, 0); + s.set(Calendar.MINUTE, 0); + s.set(Calendar.SECOND, 0); + e.setTime(TimeFormat.parse(end, DATE_FORMAT_STRING)); + e.set(Calendar.HOUR_OF_DAY, 0); + e.set(Calendar.MINUTE, 0); + e.set(Calendar.SECOND, 0); + while (s.before(e) == true) { + dates.add(TimeFormat.formatDate(s.getTime())); + s.add(Calendar.DATE, 1); + } + + dates.add(end); + return dates; + } + + + /** + * 解析日期字符串 + * + * @param String source + * @return Date + * + * @throws ParseException + */ + public static Date parse(String source) throws ParseException { + return defaultFormat.parse(source); + } + + /** + * 以指定模式解析日期 + * + * @param String source + * @param String pattern + * @return Date + * + * @throws ParseException + */ + public static Date parse(String source, String pattern) throws ParseException { + SimpleDateFormat formatter = new SimpleDateFormat(pattern); + return formatter.parse(source); + } + + + public static Date parseDateWithoutTime(String source) throws ParseException { + SimpleDateFormat formatter = new SimpleDateFormat(DATE_FORMAT_STRING); + Calendar date = Calendar.getInstance(); + date.setTime(formatter.parse(source)); + date.set(Calendar.HOUR, 0); + date.set(Calendar.HOUR, 0); + date.set(Calendar.MINUTE, 0); + return date.getTime(); + } + +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 53c91ea..cea976f 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -15,19 +15,17 @@ # ============================================================================ # db # ============================================================================ -#db.default.driverClassName=oracle.jdbc.driver.OracleDriver -#db.default.url=jdbc:oracle:thin:@192.168.0.203:1521:SZHTDB2 -#db.default.username=scott -#db.default.password=SZHTDB2 db.default.driverClassName=com.mysql.jdbc.Driver -db.default.url=jdbc:mysql://127.0.0.1:3306/ems?useUnicode=true&characterEncoding=UTF-8 -db.default.username=emsweb -db.default.password=emsweb +db.default.url=jdbc:mysql://127.0.0.1:3306/ems_tong?useUnicode=true&characterEncoding=UTF-8 +db.default.username=root +db.default.password=root +#db.default.username=emsweb +#db.default.password=emsweb #db.default.url=jdbc:mysql://119.254.110.71:3307/ems?useUnicode=true&characterEncoding=UTF-8 #db.default.username=root #db.default.password=rootems - -# ============================================================================ +# +## ============================================================================ # log4jdbc # ============================================================================ log4jdbc.enable=true diff --git a/src/main/resources/spring/applicationContext-filter.xml b/src/main/resources/spring/applicationContext-filter.xml index a08c5fc..98ac7d6 100644 --- a/src/main/resources/spring/applicationContext-filter.xml +++ b/src/main/resources/spring/applicationContext-filter.xml @@ -35,9 +35,13 @@ /user/ill-login.do /marker/exportMarker.do /marker/batchSave-na.do + /marker/batch-save-no-update.do + /marker/save-marker-photo.do /event/save-event.do /task/get-task.do + /app/get-latest-version.do /xls/* + /apk/* diff --git a/src/main/resources/spring/applicationContext-hibernate.xml b/src/main/resources/spring/applicationContext-hibernate.xml index 5bb1a7e..dc54192 100644 --- a/src/main/resources/spring/applicationContext-hibernate.xml +++ b/src/main/resources/spring/applicationContext-hibernate.xml @@ -65,6 +65,7 @@ com.casic.accessControl.task.domain.Position com.casic.accessControl.event.domain.Event com.casic.accessControl.marker.domain.OptionItem + com.casic.accessControl.app.domain.ApkVersion diff --git a/src/main/webapp/common/layout/menu_new.jsp b/src/main/webapp/common/layout/menu_new.jsp index 3cf4b4e..cbd822e 100644 --- a/src/main/webapp/common/layout/menu_new.jsp +++ b/src/main/webapp/common/layout/menu_new.jsp @@ -20,7 +20,7 @@
                                • - + @@ -54,7 +54,7 @@
                                • - + diff --git a/src/main/webapp/content/ems/ems-gd.jsp b/src/main/webapp/content/ems/ems-gd.jsp new file mode 100644 index 0000000..5137b49 --- /dev/null +++ b/src/main/webapp/content/ems/ems-gd.jsp @@ -0,0 +1,604 @@ +<%@page contentType="text/html;charset=UTF-8" %> + +<%@include file="/taglibs.jsp" %> + +<%pageContext.setAttribute("currentMenu", "ems");%> + + + + + + + + + + + + + 地下管线电子标识系统 + + + + + + + + + + + + + + + + + + +<%-- + +--%> + + + + + + + + + + + + + + +<%@include file="/common/layout/header.jsp" %> + +
                                  + + + + <%@include file="/common/layout/menu_new.jsp" %> + + + +
                                  + + + +
                                  + +
                                  + + +
                                  +
                                  +
                                  +
                                  + +
                                  +
                                  + +
                                  +
                                  + +
                                  +
                                  + +
                                  +
                                  + +
                                  + +
                                  + +
                                  + +
                                  + +
                                  + +
                                  +
                                  +
                                  + + + + +
                                  +
                                  +
                                  +
                                  + + + + +
                                  +
                                  +
                                  + +
                                  + +
                                  + +<%--todo list:错误使用方法 + +--%> +
                                  + +
                                  +
                                  + +
                                  + +
                                  + +
                                  + + +
                                  + +
                                  + + 移动 + 绘制区域 + 新增标识器 + 删除标识器 + 保存标识器 + 批量导入 + 导出Excel + 清空 + +
                                  + +
                                  +
                                  + +
                                  + + + +
                                  + +
                                  + +
                                  + + + + +
                                  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/webapp/content/task/task-gd.jsp b/src/main/webapp/content/task/task-gd.jsp new file mode 100644 index 0000000..d2d5549 --- /dev/null +++ b/src/main/webapp/content/task/task-gd.jsp @@ -0,0 +1,374 @@ +<%@page contentType="text/html;charset=UTF-8" %> + +<%@include file="/taglibs.jsp" %> + +<%pageContext.setAttribute("currentMenu", "task");%> + + + + + + + + + + + + + 地下管线电子标识系统 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +<%@include file="/common/layout/header.jsp" %> + +
                                  + + + + <%@include file="/common/layout/menu_new.jsp" %> + + + +
                                  + + + +
                                  + +
                                  + +
                                  + + 移动 + 绘制区域 + 选择多点创建工单 + 清空选择 + +
                                  + +
                                  + +
                                  + + +
                                  + +
                                  + +
                                  + +
                                  历史工单
                                  + +
                                  + +
                                  + +
                                  + <%--巡检员:--%> +
                                  +
                                  + + +
                                  +
                                  + + +
                                    +
                                  +
                                    +
                                    + +
                                    + +
                                    + +
                                    + +
                                    +
                                    + +
                                    + + + +
                                    + +
                                    + +
                                    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/webapp/images/drop/0.png b/src/main/webapp/images/drop/0.png new file mode 100644 index 0000000..f4b966b --- /dev/null +++ b/src/main/webapp/images/drop/0.png Binary files differ diff --git a/src/main/webapp/images/drop/1.png b/src/main/webapp/images/drop/1.png new file mode 100644 index 0000000..9284b64 --- /dev/null +++ b/src/main/webapp/images/drop/1.png Binary files differ diff --git a/src/main/webapp/images/drop/2.png b/src/main/webapp/images/drop/2.png new file mode 100644 index 0000000..b5425db --- /dev/null +++ b/src/main/webapp/images/drop/2.png Binary files differ diff --git a/src/main/webapp/images/drop/3.png b/src/main/webapp/images/drop/3.png new file mode 100644 index 0000000..dd09655 --- /dev/null +++ b/src/main/webapp/images/drop/3.png Binary files differ diff --git a/src/main/webapp/images/drop/4.png b/src/main/webapp/images/drop/4.png new file mode 100644 index 0000000..50cf1f7 --- /dev/null +++ b/src/main/webapp/images/drop/4.png Binary files differ diff --git a/src/main/webapp/images/drop/5.png b/src/main/webapp/images/drop/5.png new file mode 100644 index 0000000..a2029bd --- /dev/null +++ b/src/main/webapp/images/drop/5.png Binary files differ diff --git a/src/main/webapp/images/drop/6.png b/src/main/webapp/images/drop/6.png new file mode 100644 index 0000000..b53248a --- /dev/null +++ b/src/main/webapp/images/drop/6.png Binary files differ diff --git a/src/main/webapp/images/ems/point.png b/src/main/webapp/images/ems/point.png new file mode 100644 index 0000000..a814351 --- /dev/null +++ b/src/main/webapp/images/ems/point.png Binary files differ diff --git a/src/main/webapp/images/ems/rect.png b/src/main/webapp/images/ems/rect.png new file mode 100644 index 0000000..99d0c9e --- /dev/null +++ b/src/main/webapp/images/ems/rect.png Binary files differ diff --git a/src/main/webapp/images/events/red_icon.png b/src/main/webapp/images/events/red_icon.png new file mode 100644 index 0000000..78c26e4 --- /dev/null +++ b/src/main/webapp/images/events/red_icon.png Binary files differ diff --git a/src/main/webapp/images/point-task.png b/src/main/webapp/images/point-task.png new file mode 100644 index 0000000..b2e22c6 --- /dev/null +++ b/src/main/webapp/images/point-task.png Binary files differ diff --git a/src/main/webapp/images/point.png b/src/main/webapp/images/point.png new file mode 100644 index 0000000..4b887dc --- /dev/null +++ b/src/main/webapp/images/point.png Binary files differ diff --git a/src/main/webapp/images/tasks/point.png b/src/main/webapp/images/tasks/point.png new file mode 100644 index 0000000..a814351 --- /dev/null +++ b/src/main/webapp/images/tasks/point.png Binary files differ diff --git a/src/main/webapp/images/tasks/rect.png b/src/main/webapp/images/tasks/rect.png new file mode 100644 index 0000000..99d0c9e --- /dev/null +++ b/src/main/webapp/images/tasks/rect.png Binary files differ diff --git a/src/main/webapp/s/app/ems/EMSBean.js b/src/main/webapp/s/app/ems/EMSBean.js index ca6914b..a3b1dca 100644 --- a/src/main/webapp/s/app/ems/EMSBean.js +++ b/src/main/webapp/s/app/ems/EMSBean.js @@ -1,5 +1,6 @@ EMSBean = function (markerObjectType,pipeMaterial,pipeDiameter, layStyle, depth, belowType, belowDepth, belowDiameter, belowMaterial, road, - constructTime, ownerComp, markerObjectId, markerId, markerType, markerDepth, creator, createTime, memo, lat, long, recordType,id,line,area) { + constructTime, ownerComp, markerObjectId, markerId, markerType, markerDepth, creator, createTime, memo, lat, long, + recordType,id,line,area, colorType) { this.markerObjectType = markerObjectType; this.pipeMaterial = pipeMaterial; @@ -26,5 +27,5 @@ this.id = id; this.line=line; this.area =area; - + this.colorType = colorType; }; diff --git a/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java new file mode 100644 index 0000000..634ceae --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java @@ -0,0 +1,46 @@ +package com.casic.accessControl.app.domain; + +import javax.persistence.*; +import java.util.Date; + +/** + * app的版本信息 + */ +//工单 +@Entity +@Table(name = "apkVersion") +public class ApkVersion { + private String version; + private String path; + private Date ts;//时间戳 + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "version") + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + @Column(name = "path") + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + @Column(name = "ts") + public Date getTs() { + return ts; + } + + public void setTs(Date ts) { + this.ts = ts; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java new file mode 100644 index 0000000..1d0242a --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java @@ -0,0 +1,50 @@ +package com.casic.accessControl.app.dto; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.util.TimeFormat; + +/** + * Created by lenovo on 2016/4/13. + */ +public class ApkVersionDto { + private String version; + private String path; + private String ts; + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public String getTs() { + return ts; + } + + public void setTs(String ts) { + this.ts = ts; + } + + public static ApkVersionDto Convert(ApkVersion version) { + if (version == null) { + return null; + } + ApkVersionDto versionDto = new ApkVersionDto(); + versionDto.setVersion(version.getVersion()); + versionDto.setPath(version.getVersion()); + versionDto.setTs(TimeFormat.formatTimestamp(version.getTs())); + + return versionDto; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java b/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java new file mode 100644 index 0000000..28b12a7 --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java @@ -0,0 +1,27 @@ +package com.casic.accessControl.app.manager; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.core.hibernate.HibernateEntityDao; +import org.hibernate.Query; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * + */ +@Service("apkVersionManager") +public class ApkVersionManager extends HibernateEntityDao { + + public ApkVersion getLatestVersion() { + String sql = "from ApkVersion order by ts desc"; + Query query = getSession().createQuery(sql); + List list = query.list(); + if (null != list && list.isEmpty() == false) { + return list.get(0); + } + + return null; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java b/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java new file mode 100644 index 0000000..065d3cc --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java @@ -0,0 +1,66 @@ +package com.casic.accessControl.app.web; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.app.manager.ApkVersionManager; +import com.casic.accessControl.marker.domain.Marker; +import com.casic.accessControl.marker.manager.MarkerManager; +import com.casic.accessControl.task.domain.Task; +import com.casic.accessControl.task.domain.TaskDetail; +import com.casic.accessControl.task.dto.TaskDetailDto; +import com.casic.accessControl.task.dto.TaskDto; +import com.casic.accessControl.task.dto.TaskStatus; +import com.casic.accessControl.task.manager.TaskDetailManager; +import com.casic.accessControl.task.manager.TaskManager; +import com.casic.accessControl.user.domain.Company; +import com.casic.accessControl.user.domain.Role; +import com.casic.accessControl.user.domain.User; +import com.casic.accessControl.user.dto.UserDto; +import com.casic.accessControl.user.manager.RoleManager; +import com.casic.accessControl.user.manager.UserManager; +import com.casic.accessControl.util.DataTable; +import com.casic.accessControl.util.StringUtils; +import com.google.gson.Gson; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +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.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * Created by lenovo on 2016/4/13. + */ +@Controller +@RequestMapping("app") +public class ApkVersionController { + + @Resource + private ApkVersionManager apkVersionManager; + + @RequestMapping("get-latest-version") + @ResponseBody + public Map getLatestVersion(HttpServletResponse response, HttpSession session) { + Map result = new HashMap(); + try { + ApkVersion latest = apkVersionManager.getLatestVersion(); + if (null != latest) { + result.put("version", latest.getVersion()); + result.put("path", latest.getPath()); + } else { + result.put("version", "1.0.0"); + } + } catch (Exception e) { + e.printStackTrace(); + result.put("version", "1.0.0"); + } + + return result; + } + +} diff --git a/src/main/java/com/casic/accessControl/marker/domain/Marker.java b/src/main/java/com/casic/accessControl/marker/domain/Marker.java index 0575cfe..7d5b854 100644 --- a/src/main/java/com/casic/accessControl/marker/domain/Marker.java +++ b/src/main/java/com/casic/accessControl/marker/domain/Marker.java @@ -67,6 +67,10 @@ private String area; @Column(name = "line") private String line; + @Column(name = "colorType") + private String colorType; + @Column(name = "photos") + private String photos; @@ -315,4 +319,20 @@ public void setArea(String area) { this.area = area; } + + public String getColorType() { + return colorType; + } + + public void setColorType(String colorType) { + this.colorType = colorType; + } + + public String getPhotos() { + return photos; + } + + public void setPhotos(String photos) { + this.photos = photos; + } } diff --git a/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java b/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java index 506f31d..c5f8cf5 100644 --- a/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java +++ b/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java @@ -2,12 +2,12 @@ //import com.casic.accessControl.feature.domain.Feature; import com.casic.accessControl.marker.domain.Marker; +import com.casic.accessControl.util.StringUtils; +import com.casic.accessControl.util.TimeFormat; import org.apache.commons.collections.CollectionUtils; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.List; +import java.text.ParseException; +import java.util.*; /** * Created by lenovo on 2016/5/16. @@ -43,6 +43,8 @@ private Long userId; private String area; private String line; + private String colorType; + private String photos; private String btnEdit = "编辑"; private String btnDelete = "删除"; @@ -296,6 +298,23 @@ this.area = area; } + public String getColorType() { + if (StringUtils.isEmpty(colorType)) return "0"; + return colorType; + } + + public void setColorType(String colorType) { + this.colorType = colorType; + } + + public String getPhotos() { + return photos; + } + + public void setPhotos(String photos) { + this.photos = photos; + } + public String getLine() { return line; } @@ -335,6 +354,52 @@ result.setRoad(doNullChange(marker.getRoad())); result.setArea(doNullChange(marker.getArea())); result.setLine(doNullChange(marker.getLine())); + result.setColorType(marker.getColorType()); + result.setPhotos(marker.getPhotos()); + return result; + } + + public static Marker convert2Marker(MarkerDto markerDto) { + if (markerDto == null) return null; + Marker result = new Marker(); + if(markerDto.getLongitude()==null||markerDto.getLatitude()==null) return null; + if (null != markerDto.getCreateTime() && markerDto.getCreateTime().length() == 19) { + try { + result.setCreateTime(TimeFormat.parse(markerDto.getCreateTime(), "yyyy-MM-dd HH:mm:ss")); + } catch (ParseException pex) { + result.setCreateTime(Calendar.getInstance().getTime()); + } + } else { + result.setCreateTime(Calendar.getInstance().getTime()); + } + result.setDepth(doNullChange(markerDto.getDepth())); + result.setId(markerDto.getId()); + result.setLatitude(markerDto.getLatitude()); + result.setLongitude(markerDto.getLongitude()); + result.setMarkerId(markerDto.getMarkerId()); + result.setMarkerDepth(doNullChange(markerDto.getMarkerDepth())); + result.setMarkerObjectId(doNullChange(markerDto.getMarkerObjectId())); + result.setMarkerObjectType(doNullChange(markerDto.getMarkerObjectType())); + result.setOwnerComp(doNullChange(markerDto.getOwnerComp())); + result.setIsValid(markerDto.getIsValid()); + result.setMemo(doNullChange(markerDto.getMemo())); + result.setPipeDiameter(doNullChange(markerDto.getPipeDiameter())); + result.setPipeMaterial(doNullChange(markerDto.getPipeMaterial())); + result.setMarkerType(doNullChange(markerDto.getMarkerType())); + result.setCreator(doNullChange(markerDto.getCreator())); + + result.setLayStyle(doNullChange(markerDto.getLayStyle())); + result.setBelowDepth(doNullChange(markerDto.getBelowDepth())); + result.setBelowDiameter(doNullChange(markerDto.getBelowDiameter())); + result.setBelowMaterial(doNullChange(markerDto.getBelowMaterial())); + result.setBelowType(doNullChange(markerDto.getBelowType())); + result.setConstructTime(doNullChange(markerDto.getConstructTime())); + result.setRecordType(markerDto.getRecordType()); + result.setRoad(doNullChange(markerDto.getRoad())); + result.setArea(doNullChange(markerDto.getArea())); + result.setLine(doNullChange(markerDto.getLine())); + result.setColorType(markerDto.getColorType()); + result.setPhotos(markerDto.getPhotos()); return result; } diff --git a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java index dd0fa4b..ba5a1fb 100644 --- a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java +++ b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java @@ -9,10 +9,7 @@ import com.casic.accessControl.marker.domain.Marker; import com.casic.accessControl.user.domain.Company; import com.casic.accessControl.user.domain.User; -import com.casic.accessControl.util.DataTable; -import com.casic.accessControl.util.DataTableParameter; -import com.casic.accessControl.util.DataTableUtils; -import com.casic.accessControl.util.DateUtils; +import com.casic.accessControl.util.*; import com.google.gson.Gson; import jxl.*; import jxl.read.biff.BiffException; @@ -31,11 +28,15 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; +import sun.misc.BASE64Decoder; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.File; +import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.text.ParseException; @@ -183,6 +184,53 @@ } /** + * 保存标识器和图片信息 + * @param markerDto + * @param companyId + * @param fileNames + * @param fileBuffers + * @return + */ + public boolean saveMarkerAndPhotos(MarkerDto markerDto, Long companyId, String[] fileNames, String[] fileBuffers) { + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + String strDirPath = request.getSession().getServletContext().getRealPath(""); + FileOutputStream fos = null; + String month = TimeFormat.format(Calendar.getInstance().getTime(), "yyyyMM"); + String webPath = "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String toDir = strDirPath + "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String filePaths = ""; + try { + for (int i = 0; i < fileBuffers.length; i++) { + if (fileBuffers[i] != null && fileNames[i] != null) { +// filePaths += toDir+fileNames[i]+","; + filePaths += webPath + fileNames[i] + ","; + byte[] buffer = new BASE64Decoder().decodeBuffer(fileBuffers[i]); //对android传过来的图片字符串进行解码 + File destDir = new File(toDir); + if (!destDir.exists()) + destDir.mkdirs(); + File imageFile = new File(destDir, fileNames[i]); + fos = new FileOutputStream(imageFile); //保存图片 + fos.write(buffer); + fos.flush(); + fos.close(); + } + } + if (filePaths.endsWith(",")) { + filePaths = filePaths.substring(0, filePaths.length() - 1); + } + } catch (Exception e) { + return false; + } + Marker marker = MarkerDto.convert2Marker(markerDto); + marker.setIsValid(1); + marker.setCompanyId(companyId); + marker.setPhotos(filePaths); + save(marker); + return true; + + } + + /** * 新增标识器 8-9 * * @param markers @@ -582,7 +630,7 @@ "所属区域","所属线路","所属道路","建设年代","权属单位","标示对象ID", "标识器ID","标识器类型","标识器埋深","安装部门","经度", "纬度", "最后修改时间","备注","下层管种类", "下层管埋深", - "下层管直径", "下层管材料", "标识对象类别"}; + "下层管直径", "下层管材料", "标识对象类别", "标识点颜色", "图片地址"}; Label[][] labels = new Label[markerDtos.size() + 1][titleTxt.length]; for(int k=0;k saveMarkerAndPhotos(@RequestParam(value = "fileBuffer1", required = false) MultipartFile fileBuffer1, + @RequestParam(value = "fileBuffer2", required = false) MultipartFile fileBuffer2, + @RequestParam(value = "fileBuffer3", required = false) MultipartFile fileBuffer3, + @RequestParam(value = "jsonMarker", required = true) String jsonMarker) { + Map map = new HashMap(); + map.put("message", "安装无标识器信息"); + Gson gson = new Gson(); + try { + MarkerDto marker = gson.fromJson(jsonMarker, MarkerDto.class); + + if (null == marker.getMarkerId()) { + map.put("message", "无标识器ID"); + map.put("success", "false"); + return map; + } else if (markerManager.getMarkerByMarkerId(marker.getMarkerId()).size() > 0) { + map.put("message", "已安装过该标识器[" + marker.getMarkerId() + "]"); + map.put("success", "false"); + return map; + } else { + String[] fileNames = new String[3]; + String[] fileBuffers = new String[3]; + if (fileBuffer1 != null) { + fileNames[0] = marker.getMarkerId() + "_" + fileBuffer1.getOriginalFilename(); + byte[] fis = fileBuffer1.getBytes(); + fileBuffers[0] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, com.sun.org.apache.xml.internal.security.utils.Base64.BASE64DEFAULTLENGTH)); + } + if (fileBuffer2 != null) { + fileNames[1] = marker.getMarkerId() + "_" + fileBuffer2.getOriginalFilename(); + byte[] fis = fileBuffer2.getBytes(); + fileBuffers[1] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, com.sun.org.apache.xml.internal.security.utils.Base64.BASE64DEFAULTLENGTH)); + } + if (fileBuffer3 != null) { + fileNames[2] = marker.getMarkerId() + "_" + fileBuffer3.getOriginalFilename(); + byte[] fis = fileBuffer3.getBytes(); + fileBuffers[2] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, Base64.BASE64DEFAULTLENGTH)); + } + Long companyId = marker.getCompanyId(); + if (companyId == null) { + return map; + } + boolean result = markerManager.saveMarkerAndPhotos(marker, companyId, fileNames, fileBuffers); + if (!result) { + return map; + } + } + } catch (Exception e) { + return map; + } + map.put("success", "true"); + map.put("message", "保存成功"); + return map; + } + + @RequestMapping("marker-info-delete") @ResponseBody public Map delete(@RequestParam(value = "id", required = true) Long id) { @@ -144,6 +208,9 @@ map.put("message", "删除需要ID信息"); return map; } + + System.out.println(ids); + markerManager.delMarkerByIds(ids); map.put("success", true); map.put("message", "删除成功"); @@ -240,6 +307,54 @@ return map; } + /** + * 批量上传标识点,用于无信号地区标识器信息统一上传,不修改已有标识点信息 + * @param strMarkers + * @return + */ + @RequestMapping("batch-save-no-update") + @ResponseBody + public Map batchSaveOrUpdate(@RequestParam(value = "markers", required = true) String strMarkers) { + strMarkers = strMarkers.replace('\n',' '); + Map map = new HashMap(); + map.put("message", "批量导入失败,或无导入标识器信息"); + Gson gson = new Gson(); + try { + List markers = gson.fromJson(strMarkers, new TypeToken>() { + }.getType()); + if (CollectionUtils.isEmpty(markers)) {//批量导入数据不存在,直接返回 + map.put("message", "批量导入数据不存在"); + return map; + } + + Long companyId = markers.get(0).getCompanyId(); + if (companyId == null) { + map.put("message", "未找到所属公司属性"); + return map; + } + + List markerDtoForSave = new ArrayList(); + for (MarkerDto markerDto : markers) { + // 上传marker的Id不为空且数据库中不存在记录,经纬度不为空,允许保存 + if (StringUtils.isNotBlank(markerDto.getMarkerId()) && markerManager.getMarkerByMarkerId(markerDto.getMarkerId()).size() <= 0) { + if (null != markerDto.getLongitude() && null != markerDto.getLatitude()) { + markerDtoForSave.add(markerDto); + } + } + } + boolean result = markerManager.batchSave(markerDtoForSave, companyId); + if (!result) { + return map; + } + } catch (Exception e) { + e.printStackTrace(); + return map; + } + map.put("success", true); + map.put("message", "保存成功"); + return map; + } + @RequestMapping("getMarkerListByCondition") @ResponseBody @POST diff --git a/src/main/java/com/casic/accessControl/user/web/UserController.java b/src/main/java/com/casic/accessControl/user/web/UserController.java index feab678..3534a97 100644 --- a/src/main/java/com/casic/accessControl/user/web/UserController.java +++ b/src/main/java/com/casic/accessControl/user/web/UserController.java @@ -46,6 +46,7 @@ @ResponseBody public Map login(@ModelAttribute User userInfo, HttpSession session) { Map result = new HashMap(); + User user = null; try{ user = userManager.login(userInfo); diff --git a/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java b/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java new file mode 100644 index 0000000..582120f --- /dev/null +++ b/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java @@ -0,0 +1,129 @@ +package com.casic.accessControl.util; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.net.URL; +import java.net.URLConnection; +import java.util.List; +import java.util.Map; + +/** + * Created by lenovo on 2016/8/31. + */ +public class HttpRequestUtils { + + /** + * 向指定URL发送GET方法的请求 + * + * @param url + * 发送请求的URL + * @param param + * 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 + * @return URL 所代表远程资源的响应结果 + */ + public static String sendGet(String url, String param) { + String result = ""; + BufferedReader in = null; + try { + String urlNameString = url + "?" + param; + URL realUrl = new URL(urlNameString); + // 打开和URL之间的连接 + URLConnection connection = realUrl.openConnection(); + // 设置通用的请求属性 + connection.setRequestProperty("accept", "*/*"); + connection.setRequestProperty("connection", "Keep-Alive"); + connection.setRequestProperty("user-agent", + "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + // 建立实际的连接 + connection.connect(); + // 获取所有响应头字段 + Map> map = connection.getHeaderFields(); + // 遍历所有的响应头字段 + for (String key : map.keySet()) { + System.out.println(key + "--->" + map.get(key)); + } + // 定义 BufferedReader输入流来读取URL的响应 + in = new BufferedReader(new InputStreamReader( + connection.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + result += line; + } + } catch (Exception e) { + System.out.println("发送GET请求出现异常!" + e); + e.printStackTrace(); + } + // 使用finally块来关闭输入流 + finally { + try { + if (in != null) { + in.close(); + } + } catch (Exception e2) { + e2.printStackTrace(); + } + } + return result; + } + + /** + * 向指定 URL 发送POST方法的请求 + * + * @param url + * 发送请求的 URL + * @param param + * 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 + * @return 所代表远程资源的响应结果 + */ + public static String sendPost(String url, String param) { + PrintWriter out = null; + BufferedReader in = null; + String result = ""; + try { + URL realUrl = new URL(url); + // 打开和URL之间的连接 + URLConnection conn = realUrl.openConnection(); + // 设置通用的请求属性 + conn.setRequestProperty("accept", "*/*"); + conn.setRequestProperty("connection", "Keep-Alive"); + conn.setRequestProperty("user-agent", + "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + // 发送POST请求必须设置如下两行 + conn.setDoOutput(true); + conn.setDoInput(true); + // 获取URLConnection对象对应的输出流 + out = new PrintWriter(conn.getOutputStream()); + // 发送请求参数 + out.print(param); + // flush输出流的缓冲 + out.flush(); + // 定义BufferedReader输入流来读取URL的响应 + in = new BufferedReader( + new InputStreamReader(conn.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + result += line; + } + } catch (Exception e) { + System.out.println("发送 POST 请求出现异常!"+e); + e.printStackTrace(); + } + //使用finally块来关闭输出流、输入流 + finally{ + try{ + if(out!=null){ + out.close(); + } + if(in!=null){ + in.close(); + } + } + catch(IOException ex){ + ex.printStackTrace(); + } + } + return result; + } + } \ No newline at end of file diff --git a/src/main/java/com/casic/accessControl/util/TimeFormat.java b/src/main/java/com/casic/accessControl/util/TimeFormat.java new file mode 100644 index 0000000..e9168d5 --- /dev/null +++ b/src/main/java/com/casic/accessControl/util/TimeFormat.java @@ -0,0 +1,148 @@ +package com.casic.accessControl.util; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +/** + * 格式化日期工具类 + * 默认模式yyyy-MM-dd HH:mm:ss + * @author Administrator + * + */ +public class TimeFormat { + + private static final String DATE_FORMAT_STRING = "yyyy-MM-dd"; + private static final String TIME_FORMAT_STRING = "HH:mm:ss"; + private static final String TIMESTAMP_FORMAT_STRING = "yyyy-MM-dd HH:mm:ss"; + + // 默认格式化格式 + private static SimpleDateFormat defaultFormat = new SimpleDateFormat(TIMESTAMP_FORMAT_STRING); + + public static void setFormatString(String pattern) { + defaultFormat.applyPattern(pattern); + } + + /** + * 默认格式化日期 + * + * @param Date date + * @return String + */ + public static String format(Date date) { + return defaultFormat.format(date); + } + + /** + * 日期格式化 + * + * @param date + * @return + */ + public static String formatDate(Date date) { + return TimeFormat.format(date, DATE_FORMAT_STRING); + } + + /** + * 时间格式化 + * + * @param date + * @return + */ + public static String formatTime(Date date) { + return TimeFormat.format(date, TIME_FORMAT_STRING); + } + + /** + * 时间戳格式化 + * + * @param date + * @return + */ + public static String formatTimestamp(Date date) { + return TimeFormat.format(date, TIMESTAMP_FORMAT_STRING); + } + + /** + * 以指定模式格式化日期 + * + * @param Date date + * @param String pattern + * @return String + */ + public static String format(Date date, String pattern) { + SimpleDateFormat formatter = new SimpleDateFormat(pattern); + return formatter.format(date); + } + + /** + * 根据起止日期生成日期序列 + * 包括start和end的日期 + * + * @param start + * @param end + * @return + */ + public static List generateDates(String start, String end) throws ParseException { + List dates = new ArrayList(); + Calendar s = Calendar.getInstance(); + Calendar e = Calendar.getInstance(); + s.setTime(TimeFormat.parse(start, DATE_FORMAT_STRING)); + s.set(Calendar.HOUR_OF_DAY, 0); + s.set(Calendar.MINUTE, 0); + s.set(Calendar.SECOND, 0); + e.setTime(TimeFormat.parse(end, DATE_FORMAT_STRING)); + e.set(Calendar.HOUR_OF_DAY, 0); + e.set(Calendar.MINUTE, 0); + e.set(Calendar.SECOND, 0); + while (s.before(e) == true) { + dates.add(TimeFormat.formatDate(s.getTime())); + s.add(Calendar.DATE, 1); + } + + dates.add(end); + return dates; + } + + + /** + * 解析日期字符串 + * + * @param String source + * @return Date + * + * @throws ParseException + */ + public static Date parse(String source) throws ParseException { + return defaultFormat.parse(source); + } + + /** + * 以指定模式解析日期 + * + * @param String source + * @param String pattern + * @return Date + * + * @throws ParseException + */ + public static Date parse(String source, String pattern) throws ParseException { + SimpleDateFormat formatter = new SimpleDateFormat(pattern); + return formatter.parse(source); + } + + + public static Date parseDateWithoutTime(String source) throws ParseException { + SimpleDateFormat formatter = new SimpleDateFormat(DATE_FORMAT_STRING); + Calendar date = Calendar.getInstance(); + date.setTime(formatter.parse(source)); + date.set(Calendar.HOUR, 0); + date.set(Calendar.HOUR, 0); + date.set(Calendar.MINUTE, 0); + return date.getTime(); + } + +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 53c91ea..cea976f 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -15,19 +15,17 @@ # ============================================================================ # db # ============================================================================ -#db.default.driverClassName=oracle.jdbc.driver.OracleDriver -#db.default.url=jdbc:oracle:thin:@192.168.0.203:1521:SZHTDB2 -#db.default.username=scott -#db.default.password=SZHTDB2 db.default.driverClassName=com.mysql.jdbc.Driver -db.default.url=jdbc:mysql://127.0.0.1:3306/ems?useUnicode=true&characterEncoding=UTF-8 -db.default.username=emsweb -db.default.password=emsweb +db.default.url=jdbc:mysql://127.0.0.1:3306/ems_tong?useUnicode=true&characterEncoding=UTF-8 +db.default.username=root +db.default.password=root +#db.default.username=emsweb +#db.default.password=emsweb #db.default.url=jdbc:mysql://119.254.110.71:3307/ems?useUnicode=true&characterEncoding=UTF-8 #db.default.username=root #db.default.password=rootems - -# ============================================================================ +# +## ============================================================================ # log4jdbc # ============================================================================ log4jdbc.enable=true diff --git a/src/main/resources/spring/applicationContext-filter.xml b/src/main/resources/spring/applicationContext-filter.xml index a08c5fc..98ac7d6 100644 --- a/src/main/resources/spring/applicationContext-filter.xml +++ b/src/main/resources/spring/applicationContext-filter.xml @@ -35,9 +35,13 @@ /user/ill-login.do /marker/exportMarker.do /marker/batchSave-na.do + /marker/batch-save-no-update.do + /marker/save-marker-photo.do /event/save-event.do /task/get-task.do + /app/get-latest-version.do /xls/* + /apk/* diff --git a/src/main/resources/spring/applicationContext-hibernate.xml b/src/main/resources/spring/applicationContext-hibernate.xml index 5bb1a7e..dc54192 100644 --- a/src/main/resources/spring/applicationContext-hibernate.xml +++ b/src/main/resources/spring/applicationContext-hibernate.xml @@ -65,6 +65,7 @@ com.casic.accessControl.task.domain.Position com.casic.accessControl.event.domain.Event com.casic.accessControl.marker.domain.OptionItem + com.casic.accessControl.app.domain.ApkVersion diff --git a/src/main/webapp/common/layout/menu_new.jsp b/src/main/webapp/common/layout/menu_new.jsp index 3cf4b4e..cbd822e 100644 --- a/src/main/webapp/common/layout/menu_new.jsp +++ b/src/main/webapp/common/layout/menu_new.jsp @@ -20,7 +20,7 @@
                                  • - + @@ -54,7 +54,7 @@
                                  • - + diff --git a/src/main/webapp/content/ems/ems-gd.jsp b/src/main/webapp/content/ems/ems-gd.jsp new file mode 100644 index 0000000..5137b49 --- /dev/null +++ b/src/main/webapp/content/ems/ems-gd.jsp @@ -0,0 +1,604 @@ +<%@page contentType="text/html;charset=UTF-8" %> + +<%@include file="/taglibs.jsp" %> + +<%pageContext.setAttribute("currentMenu", "ems");%> + + + + + + + + + + + + + 地下管线电子标识系统 + + + + + + + + + + + + + + + + + + +<%-- + +--%> + + + + + + + + + + + + + + +<%@include file="/common/layout/header.jsp" %> + +
                                    + + + + <%@include file="/common/layout/menu_new.jsp" %> + + + +
                                    + + + +
                                    + +
                                    + + +
                                    +
                                    +
                                    +
                                    + +
                                    +
                                    + +
                                    +
                                    + +
                                    +
                                    + +
                                    +
                                    + +
                                    + +
                                    + +
                                    + +
                                    + +
                                    + +
                                    +
                                    +
                                    + + + + +
                                    +
                                    +
                                    +
                                    + + + + +
                                    +
                                    +
                                    + +
                                    + +
                                    + +<%--todo list:错误使用方法 + +--%> +
                                    + +
                                    +
                                    + +
                                    + +
                                    + +
                                    + + +
                                    + +
                                    + + 移动 + 绘制区域 + 新增标识器 + 删除标识器 + 保存标识器 + 批量导入 + 导出Excel + 清空 + +
                                    + +
                                    +
                                    + +
                                    + + + +
                                    + +
                                    + +
                                    + + + + +
                                    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/webapp/content/task/task-gd.jsp b/src/main/webapp/content/task/task-gd.jsp new file mode 100644 index 0000000..d2d5549 --- /dev/null +++ b/src/main/webapp/content/task/task-gd.jsp @@ -0,0 +1,374 @@ +<%@page contentType="text/html;charset=UTF-8" %> + +<%@include file="/taglibs.jsp" %> + +<%pageContext.setAttribute("currentMenu", "task");%> + + + + + + + + + + + + + 地下管线电子标识系统 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +<%@include file="/common/layout/header.jsp" %> + +
                                    + + + + <%@include file="/common/layout/menu_new.jsp" %> + + + +
                                    + + + +
                                    + +
                                    + +
                                    + + 移动 + 绘制区域 + 选择多点创建工单 + 清空选择 + +
                                    + +
                                    + +
                                    + + +
                                    + +
                                    + +
                                    + +
                                    历史工单
                                    + +
                                    + +
                                    + +
                                    + <%--巡检员:--%> +
                                    +
                                    + + +
                                    +
                                    + + +
                                      +
                                    +
                                      +
                                      + +
                                      + +
                                      + +
                                      + +
                                      +
                                      + +
                                      + + + +
                                      + +
                                      + +
                                      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/webapp/images/drop/0.png b/src/main/webapp/images/drop/0.png new file mode 100644 index 0000000..f4b966b --- /dev/null +++ b/src/main/webapp/images/drop/0.png Binary files differ diff --git a/src/main/webapp/images/drop/1.png b/src/main/webapp/images/drop/1.png new file mode 100644 index 0000000..9284b64 --- /dev/null +++ b/src/main/webapp/images/drop/1.png Binary files differ diff --git a/src/main/webapp/images/drop/2.png b/src/main/webapp/images/drop/2.png new file mode 100644 index 0000000..b5425db --- /dev/null +++ b/src/main/webapp/images/drop/2.png Binary files differ diff --git a/src/main/webapp/images/drop/3.png b/src/main/webapp/images/drop/3.png new file mode 100644 index 0000000..dd09655 --- /dev/null +++ b/src/main/webapp/images/drop/3.png Binary files differ diff --git a/src/main/webapp/images/drop/4.png b/src/main/webapp/images/drop/4.png new file mode 100644 index 0000000..50cf1f7 --- /dev/null +++ b/src/main/webapp/images/drop/4.png Binary files differ diff --git a/src/main/webapp/images/drop/5.png b/src/main/webapp/images/drop/5.png new file mode 100644 index 0000000..a2029bd --- /dev/null +++ b/src/main/webapp/images/drop/5.png Binary files differ diff --git a/src/main/webapp/images/drop/6.png b/src/main/webapp/images/drop/6.png new file mode 100644 index 0000000..b53248a --- /dev/null +++ b/src/main/webapp/images/drop/6.png Binary files differ diff --git a/src/main/webapp/images/ems/point.png b/src/main/webapp/images/ems/point.png new file mode 100644 index 0000000..a814351 --- /dev/null +++ b/src/main/webapp/images/ems/point.png Binary files differ diff --git a/src/main/webapp/images/ems/rect.png b/src/main/webapp/images/ems/rect.png new file mode 100644 index 0000000..99d0c9e --- /dev/null +++ b/src/main/webapp/images/ems/rect.png Binary files differ diff --git a/src/main/webapp/images/events/red_icon.png b/src/main/webapp/images/events/red_icon.png new file mode 100644 index 0000000..78c26e4 --- /dev/null +++ b/src/main/webapp/images/events/red_icon.png Binary files differ diff --git a/src/main/webapp/images/point-task.png b/src/main/webapp/images/point-task.png new file mode 100644 index 0000000..b2e22c6 --- /dev/null +++ b/src/main/webapp/images/point-task.png Binary files differ diff --git a/src/main/webapp/images/point.png b/src/main/webapp/images/point.png new file mode 100644 index 0000000..4b887dc --- /dev/null +++ b/src/main/webapp/images/point.png Binary files differ diff --git a/src/main/webapp/images/tasks/point.png b/src/main/webapp/images/tasks/point.png new file mode 100644 index 0000000..a814351 --- /dev/null +++ b/src/main/webapp/images/tasks/point.png Binary files differ diff --git a/src/main/webapp/images/tasks/rect.png b/src/main/webapp/images/tasks/rect.png new file mode 100644 index 0000000..99d0c9e --- /dev/null +++ b/src/main/webapp/images/tasks/rect.png Binary files differ diff --git a/src/main/webapp/s/app/ems/EMSBean.js b/src/main/webapp/s/app/ems/EMSBean.js index ca6914b..a3b1dca 100644 --- a/src/main/webapp/s/app/ems/EMSBean.js +++ b/src/main/webapp/s/app/ems/EMSBean.js @@ -1,5 +1,6 @@ EMSBean = function (markerObjectType,pipeMaterial,pipeDiameter, layStyle, depth, belowType, belowDepth, belowDiameter, belowMaterial, road, - constructTime, ownerComp, markerObjectId, markerId, markerType, markerDepth, creator, createTime, memo, lat, long, recordType,id,line,area) { + constructTime, ownerComp, markerObjectId, markerId, markerType, markerDepth, creator, createTime, memo, lat, long, + recordType,id,line,area, colorType) { this.markerObjectType = markerObjectType; this.pipeMaterial = pipeMaterial; @@ -26,5 +27,5 @@ this.id = id; this.line=line; this.area =area; - + this.colorType = colorType; }; diff --git a/src/main/webapp/s/app/ems/ems-gd.js b/src/main/webapp/s/app/ems/ems-gd.js new file mode 100644 index 0000000..8875ae8 --- /dev/null +++ b/src/main/webapp/s/app/ems/ems-gd.js @@ -0,0 +1,627 @@ +/** + * Created by lenovo on 2016/4/13. + */ +//定义全局变量,缓存组织结构 + +var EmsGd = function () { + var isSaveStatus = false; + var map = null; + var mouseTool = null; + var drawOverlays = new Array(); + var readyToUploadMarkers = new Array(); + var vectorMarkers = []; + var markerData = []; + var hadRequest = false; + + var blueIcon = new AMap.Icon({ + size: new AMap.Size(25, 34), + image: $('#context').val() + '/images/drop/0.png' + }); + + var orangeIcon = new AMap.Icon({ + size: new AMap.Size(25, 34), + image: $('#context').val() + '/images/drop/1.png' + }); + + var redIcon = new AMap.Icon({ + size: new AMap.Size(25, 34), + image: $('#context').val() + '/images/drop/2.png' + }); + + var blackIcon = new AMap.Icon({ + size: new AMap.Size(25, 34), + image: $('#context').val() + '/images/drop/3.png' + }); + + var pinkIcon = new AMap.Icon({ + size: new AMap.Size(25, 34), + image: $('#context').val() + '/images/drop/4.png' + }); + + var yellowIcon = new AMap.Icon({ + size: new AMap.Size(25, 34), + image: $('#context').val() + '/images/drop/5.png' + }); + + var greenIcon = new AMap.Icon({ + size: new AMap.Size(25, 34), + image: $('#context').val() + '/images/drop/6.png' + }); + + var handleDatePickers = function () { + + if (jQuery().datepicker) { + $('.date-picker').datepicker({ + rtl: App.isRTL() + }); + } + } + + function requestMarkers() { + if (markerData.length == 0&!hadRequest) { + hadRequest = true; + $.ajax({ + type: "get", + url: $('#context').val() + "/marker/all-point-list.do", + dataType: "json", +// async:false, + cache: false, + success: function (r) { + if (r.data) {//请求成功,将获取到的数据加载到地图上 + //1.解析返回的结果,.设置全局变量data的值 + markerData = [];//清空原来的数据 + for (var t = 0; t < r.data.length; t++) { + var markerDto = r.data[t]; + var emsBean = new EMSBean(markerDto.markerObjectType, markerDto.pipeMaterial, markerDto.pipeDiameter, markerDto.layStyle, + markerDto.depth, markerDto.belowType, markerDto.belowDepth, markerDto.belowDiameter, + markerDto.belowMaterial, markerDto.road, markerDto.constructTime, markerDto.ownerComp, + markerDto.markerObjectId, markerDto.markerId, markerDto.markerType, markerDto.markerDepth, + markerDto.creator, markerDto.createTime, markerDto.memo, markerDto.latitude, markerDto.longitude, + markerDto.recordType, markerDto.id,markerDto.line,markerDto.area,markerDto.colorType); + markerData[t] = emsBean; + } + //2.增加marker + EmsGd.addMarker(markerData); + } + hadRequest = false; + map.off("complete", requestMarkers()); + }, + error: function (d) {//请求出错 + hadRequest = false; + map.off("complete", requestMarkers()); + } + }); + } else if(!hadRequest){ + EmsGd.addMarker(markerData); + } + + } + + return { + + //添加标识器 + emsAddCallBack: function () { + $('#addModal').modal('show'); + }, + + //删除标识器 + emsDelCallBack: function () { + //绘制矩形区域: + if (drawOverlays.length == 0) { + swal("请先绘制区域", "", "warning"); + return; + } + + var pointArray = new Array(); + var readyToDel = ""; + for (var i = 0; i < drawOverlays.length; i++) { + var layer = drawOverlays[i]; + try { + // 生成判断是否在多边形内的数据格式 + var path = []; + for (var k = 0; k < layer.He.path.length; k++) { + var pos = []; + pos.push(layer.He.path[k].lng, layer.He.path[k].lat); + path.push(pos); + } + for (var j = 0; j < markerData.length; j++) { + var emsBean = markerData[j]; + var point = new AMap.LngLat(emsBean.longitude, emsBean.latitude); + var isPointInRing = AMap.GeometryUtil.isPointInRing(point, path); + if (isPointInRing) { + pointArray.push(point); + readyToDel = readyToDel + emsBean.id + ","; + } + } + } catch (e) { + swal("脚本异常", e.message, "error"); + } + if (pointArray.length <= 0) { + swal("选择区域没有要删除的点", "", "warning"); + for (var i in drawOverlays) { + map.remove(drawOverlays[i]); + } + return; + } + + swal({ + title: "是否确认删除?", + text: "删除是不可恢复的", + type: "warning", + showCancelButton: true, + confirmButtonText: "确认", + cancelButtonText: "取消", + closeOnConfirm: false + }, function() { + $.ajax({ + type: "get", + url: $('#context').val() + "/marker/delMarkerByIds.do", + dataType: "json", + cache: false, + data: { + "ids": readyToDel + }, + success: function (r) { + if (r.success) {//请求成功 + swal({ + title: "删除标识器成功", + text: "", + type: "success", + confirmButtonText: "确认", + closeOnConfirm: false + }, function() { + location.href = $('#context').val() + "/content/ems/ems-gd.jsp"; + }); + } + }, + error: function (d) {//请求出错 + swal("请求异常", d.responseText, "error"); + } + }); + }); + } + }, + + //保存标识器 + emsSaveCallBack: function () { + + if (readyToUploadMarkers.length == 0) { + return; + } + if (isSaveStatus) { + swal("保存过于频繁", "请稍后操作", "warning"); + return; + } + isSaveStatus = true; + //TODO LIST:上传 + var uploadMaker = new Array(); + for (var i = 0; i < readyToUploadMarkers.length; i++) { + var emsBean = readyToUploadMarkers[i].Tag; + + if (!emsBean.depth) { + emsBean.depth = 0; + } + uploadMaker.push(emsBean); + } + $.ajax({ + type: "get", + url: $('#context').val() + "/marker/batchSave.do", + dataType: "json", + cache: false, + data: { + markers: JSON.stringify(uploadMaker) + }, + success: function (r) { + if (r.success) {//请求成功 + swal({ + title: "保存标识器成功", + text: "", + type: "success", + confirmButtonText: "确认", + closeOnConfirm: false + }, function() { + location.href = $('#context').val() + "/content/ems/ems-gd.jsp"; + }); + } + }, + error: function (d) {//请求出错 + swal("请求出错", d.responseText, "error"); + isSaveStatus = false; + } + }); + }, + + emsUploadCallBack: function () { + // map.zoomTo(map.getZoom() + 2); + //TODO LIST:弹出对应的对话框 + $('#uploadModal').modal('show'); + }, + + emsExportCallBack: function () { + //TODO LIST:选择导出的文件 +// map.zoomTo(map.getZoom() + 2); + location.href = $('#context').val() + "/marker/export.do"; + + }, + + // 清除地图上所有后添加的标记点 + clearOverlays: function () { + mouseTool.close(true)//关闭,并清除覆盖物 + + for (var i = 0; i < drawOverlays.length; i++) { + map.remove(drawOverlays[i]); + } + for (var i = 0; i < readyToUploadMarkers.length; i++) { + map.remove(readyToUploadMarkers[i]); + } + for (var i = 0; i < vectorMarkers.length; i++) { + map.remove(vectorMarkers[i]); + } + + drawOverlays = []; + readyToUploadMarkers = []; + vectorMarkers = []; + }, + + initMap: function () { + + // 创建地图实例 + map = new AMap.Map("container", { + zoom: 13, + resizeEnable: true, + zooms: [4,18],//设置地图级别范围 + }); + + //声明全局变量 + if (!markerData || markerData.length == 0) { + markerData = new Array(); + } + + // 鼠标操作工具栏 + mouseTool = new AMap.MouseTool(map); + mouseTool.on('draw',function(e){ + drawOverlays.push(e.obj); + }) + + //加载完毕请求标识点信息 + map.on("complete", requestMarkers); + }, + + // 绘制区域矩形框 + drawRect: function () { + mouseTool.rectangle(); + }, + + //取消绘制区域矩形框 + moveMap: function () { + mouseTool.close(true)//关闭,并清除覆盖物 + }, + + initForm: function () { + handleDatePickers(); + $("#selectObjectType").chosen(); + $("#resetEms").live("click", function (e) { + $("#markerObjectType").val(""); + $("#pipeDiameter").val(""); + $("#pipeMaterial").val(""); + $("#belowPipeType").val(""); + $("#belowPipeDepth").val(""); + $("#belowPipeDiameter").val(""); + $("#belowPipeMaterial").val(""); + $("#pipeDepth").val(""); + $("#layStyle").val(""); + $("#line").val(""); + $("#area").val(""); + $("#road").val(""); + $("#constructTime").val(""); + $("#ownerComp").val(""); + $("#markerObjectId").val(""); + $("#markerId").val(""); + $("#markerType").val(""); + $("#markerDepth").val(""); + $("#creator").val(""); + $("#memo").val(""); + + }); + + $('#localize').click(function (e) { + $('#addModal').modal('hide'); + + //注册地图点击事件 + function showInfo(e) { + map.off("click", showInfo); + var lng = e.lnglat.lng; + var lat = e.lnglat.lat; + //TODO LIST:获取填写表单的信息 所属区域也需要保存的 + var selectObjectType = $("#selectObjectType").val();//判断是哪个类别 + var markerObjectType = $("#markerObjectType").val(); + var pipeDiameter = $("#pipeDiameter").val(); + var pipeMaterial = $("#pipeMaterial").val(); + var belowPipeType = $("#belowPipeType").val(); + var belowPipeDepth = $("#belowPipeDepth").val(); + var belowPipeDiameter = $("#belowPipeDiameter").val(); + var belowPipeMaterial = $("#belowPipeMaterial").val(); + var pipeDepth = $("#pipeDepth").val(); + var layStyle = $("#layStyle").val(); + var road = $("#road").val(); + var constructTime = $("#constructTime").val(); + var ownerComp = $("#ownerComp").val(); + var markerObjectId = $("#markerObjectId").val(); + var markerId = $("#markerId").val(); + var markerType = $("#markerType").val(); + var markerDepth = $("#markerDepth").val(); + var creator = $("#creator").val(); + var memo = $("#memo").val(); + var line = $("#line").val(); + var area = $("#area").val(); + var emsBean = new EMSBean(markerObjectType, pipeMaterial, pipeDiameter, layStyle, pipeDepth, belowPipeType, belowPipeDepth, belowPipeDiameter, belowPipeMaterial, + road, constructTime, ownerComp, markerObjectId, markerId, markerType, markerDepth, creator, null, memo, lat, lng, selectObjectType,null,line,area); + var marker = new AMap.Marker({ + position: [lng, lat], + draggable: true + }); + + marker.on("click", attribute); + marker.Tag = emsBean; + map.add(marker); //增加点 + readyToUploadMarkers.push(marker); + function attribute() { + var emsBean2 = marker.Tag; + var searchInfoWindow = null; + var msg = ""; + var height = 0; + var titleName =""; + if (emsBean.recordType == 1) { + titleName = "
                                      管线
                                      "; + msg = msg + "管线种类:" + emsBean2.markerObjectType + "
                                      " + + "管线直径(mm):" + emsBean2.pipeDiameter + "
                                      " + + "管线材质:" + emsBean2.pipeMaterial + "
                                      " + + "埋设方式:" + emsBean2.layStyle + "
                                      " + + "管线埋深(mm):" + emsBean2.depth + "
                                      "; + height = 100; + } else if (emsBean.recordType == 2) { + titleName = "
                                      管线附属物
                                      "; + msg = msg + "附属物名称:" + emsBean2.markerObjectType + "
                                      " + + "井深(mm):" + emsBean2.depth + "
                                      "; + height = 40; + } else if (emsBean.recordType == 3) { + titleName = "
                                      管线特征管点
                                      "; + msg = msg + "管点特征:" + emsBean2.markerObjectType + "
                                      " + + "特征点埋深(mm):" + emsBean2.depth + "
                                      "; + height = 40; + } else { + titleName = "
                                      交叉穿越点
                                      "; + msg = msg + "上层管种类:" + emsBean2.markerObjectType + "
                                      " + + "上层管埋深(mm):" + emsBean2.depth + "
                                      " + + "上层管直径(mm):" + emsBean2.pipeDiameter + "
                                      " + + "上层管材料:" + emsBean2.pipeMaterial + "
                                      " + + "下层管种类:" + emsBean2.belowType + "
                                      " + + "下层管埋深(mm):" + emsBean2.belowDepth + "
                                      "+ + "下层管直径(mm):" + emsBean2.belowDiameter + "
                                      " + + "下层管材料:" + emsBean2.belowMaterial + "
                                      " ; + height = 160; + } + height = height +225; + msg = msg + "所属区域:" + emsBean2.area + "
                                      " + + "所属线路:" + emsBean2.line + "
                                      " + + "所属道路:" + emsBean2.road + "
                                      " + + "建设年代:" + emsBean2.constructTime + "
                                      " + + "权属单位:" + emsBean2.ownerComp + "
                                      " + + "标识器ID:" + emsBean2.markerId + "
                                      " + + "标识器类型:" + emsBean2.markerType + "
                                      " + + "标识器埋深(mm):" + emsBean2.markerDepth + "
                                      " + + "安装部门:" + emsBean2.creator + "
                                      " + + "最后修改时间:"+emsBean2.createTime + "
                                      " + + "备注:" + emsBean2.memo + "
                                      "; + var imgUrl = $('#context').val() + "/images/ems.jpg"; + var content = titleName + '
                                      ' + + '' + msg + + '
                                      '; + + var infowindow = new AMap.AdvancedInfoWindow({ + content: content, + width: 290, //宽度 + height: height, //高度 + panel: "panel", //检索结果面板 + enableAutoPan: true //自动平移 + }); + + infowindow.open(map, [e.lnglat.lng, e.lnglat.lat]); + } + + } + map.on("click", showInfo); + }); + + $("#searchMarker").click(function (e) { + var Marker = {}; + if (vectorMarkers.length != 0) { + for (var i = 0; i < vectorMarkers.length; i++) { + map.remove(vectorMarkers[i]); + } + } + vectorMarkers = []; + Marker.road = $("#roadCondition").val(); + Marker.memo = $("#memoCondition").val(); + Marker.area = $("#select_area").val(); + Marker.line = $("#select_line").val(); + Marker.ownerComp = $("#company").val(); + Marker.creator = $("#department").val(); + Marker.sDate = $("#txt_begin_day").val(); + Marker.eDate = $("#txt_end_day").val(); + //请求后台的id列表,然后遍历marker列表,修改marker的颜色 + $.ajax({ + type: "POST", + url: $('#context').val() + "/marker/getMarkerListByCondition.do", + data: {"strMarkerDto": JSON.stringify(Marker)}, + dataType: "json", + success: function (r) { + if (r.data) { + var pointArray = new Array(); + if (r.data.length > 1000) { + swal("有超过一千个点符合筛选条件", "会造成浏览器卡顿,请重新选择", "warning"); + } else { + if (r.data.length == 0) { + swal("没有搜到符合条件的标识器", "请重新选择", "warning"); + return; + } + for (var a in r.data) {//遍历列表,添加marker + var vectorMarker = new AMap.Marker({ + position: [r.data[a].longitude,r.data[a].latitude], + size: new AMap.Size(30, 30), + icon: $('#context').val() + '/images/point.png' + }); + vectorMarkers.push(vectorMarker); + map.add(vectorMarker); + } + map.setFitView(vectorMarkers); + } + + } + }, + error: function (request) { + //提示错误信息 + swal("脚本异常", r.message, "error"); + } + }); + }); + + //控制不同种类对象的标签信息显示 + $("#selectObjectType").die().live("change", function (e) { + var type = $("#selectObjectType").val(); + OptionItemProcess.initPipeTypeList(type); + if (type == 1) {//管线 + $("#pipeTypeLabel").text("管线种类"); + $(".up-pipe").show(); + $("#pipeDiameterLabel").text("管线直径"); + $("#pipeMaterialLabel").text("管线材质"); + $(".below").addClass("hidden"); + $("#pipeDepthLabel").text("管线埋深"); + $(".pipeOnly").show(); + } else if (type == 2) {//管线附属物 + $("#pipeTypeLabel").text("附属物名称"); + $(".up-pipe").hide(); + $(".below").addClass("hidden"); + $("#pipeDepthLabel").text("井深"); + $(".pipeOnly").hide(); + } else if (type == 3) {//管线特征点 + $("#pipeTypeLabel").text("管点特征"); + $(".up-pipe").hide(); + $(".below").addClass("hidden"); + $("#pipeDepthLabel").text("特征点埋深"); + $(".pipeOnly").hide(); + } else {//交叉穿越点 + $("#pipeTypeLabel").text("上层管种类"); + $(".up-pipe").show(); + $("#pipeDiameterLabel").text("上层管直径"); + $("#pipeMaterialLabel").text("上层管材料"); + $(".below").removeClass("hidden"); + $("#pipeDepthLabel").text("上层管埋深"); + $(".pipeOnly").hide(); + } + }); + + OptionItemProcess.initPipeTypeList($("#selectObjectType").val()); + OptionItemProcess.initBelowPipeTypeList(); + OptionItemProcess.initAreaList(); + OptionItemProcess.initLayStyleList(); + OptionItemProcess.initMaterialList(); + }, + + initSelect: function () { + $("#selectObjectType").chosen(); + }, + + addMarker: function (data) { + for (var i = 0; i < data.length; i++) { + var icon = blueIcon; + var color = data[i].colorType; + if (color == "1") { + icon = orangeIcon; + } else if (color == "2") { + icon = redIcon; + } else if (color == "3") { + icon = blackIcon; + } else if (color == "4") { + icon = pinkIcon; + } else if (color == "5") { + icon = yellowIcon; + } else if (color == "6") { + icon = greenIcon; + } + + var marker = new AMap.Marker({ + position: [data[i].longitude, data[i].latitude], + icon: icon + }); + marker.Tag = data[i]; + + marker.on("click", function (e) { + + var emsBean = e.target.Tag; + var msg = ""; + var height = 0; + var titleName =""; + if (emsBean.recordType == 1) { + titleName = "
                                      管线
                                      "; + msg = msg + "管线种类:" + emsBean.markerObjectType + "
                                      " + + "管线直径(mm):" + emsBean.pipeDiameter + "
                                      " + + "管线材质:" + emsBean.pipeMaterial + "
                                      " + + "埋设方式:" + emsBean.layStyle + "
                                      " + + "管线埋深(mm):" + emsBean.depth + "
                                      "; + height = 100; + } else if (emsBean.recordType == 2) { + titleName = "
                                      管线附属物
                                      "; + msg = msg + "附属物名称:" + emsBean.markerObjectType + "
                                      " + + "井深(mm):" + emsBean.depth + "
                                      "; + height = 40; + } else if (emsBean.recordType == 3) { + titleName = "
                                      管线特征管点
                                      "; + msg = msg + "管点特征:" + emsBean.markerObjectType + "
                                      " + + "特征点埋深(mm):" + emsBean.depth + "
                                      "; + height = 40; + } else { + titleName = "
                                      交叉穿越点
                                      "; + msg = msg + "上层管种类:" + emsBean.markerObjectType + "
                                      " + + "上层管埋深(mm):" + emsBean.depth + "
                                      " + + "上层管直径(mm):" + emsBean.pipeDiameter + "
                                      " + + "上层管材料:" + emsBean.pipeMaterial + "
                                      " + + "下层管种类:" + emsBean.belowType + "
                                      " + + "下层管埋深(mm):" + emsBean.belowDepth + "
                                      "+ + "下层管直径(mm):" + emsBean.belowDiameter + "
                                      " + + "下层管材料:" + emsBean.belowMaterial + "
                                      " ; + height = 160; + } + height = height +225; + msg = msg + "所属区域:" + emsBean.area + "
                                      " + + "所属线路:" + emsBean.line + "
                                      " + + "所属道路:" + emsBean.road + "
                                      " + + "建设年代:" + emsBean.constructTime + "
                                      " + + "权属单位:" + emsBean.ownerComp + "
                                      " + + "标识器ID:" + emsBean.markerId + "
                                      " + + "标识器类型:" + emsBean.markerType + "
                                      " + + "标识器埋深(mm):" + emsBean.markerDepth + "
                                      " + + "安装部门:" + emsBean.creator + "
                                      " + + "最后修改时间:"+emsBean.createTime + "
                                      " + + "备注:" + emsBean.memo + "
                                      "; + var imgUrl = $('#context').val() + "/images/ems.jpg"; + var content = titleName + '
                                      ' + + '' + msg + + '
                                      '; + + var infowindow = new AMap.AdvancedInfoWindow({ + content: content, + width: 290, //宽度 + height: height, //高度 + panel: "panel", //检索结果面板 + enableAutoPan: true //自动平移 + }); + + infowindow.open(map, [e.lnglat.lng, e.lnglat.lat]); + }); + + map.add(marker); + } + } + }; +}(); \ No newline at end of file diff --git a/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java new file mode 100644 index 0000000..634ceae --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java @@ -0,0 +1,46 @@ +package com.casic.accessControl.app.domain; + +import javax.persistence.*; +import java.util.Date; + +/** + * app的版本信息 + */ +//工单 +@Entity +@Table(name = "apkVersion") +public class ApkVersion { + private String version; + private String path; + private Date ts;//时间戳 + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "version") + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + @Column(name = "path") + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + @Column(name = "ts") + public Date getTs() { + return ts; + } + + public void setTs(Date ts) { + this.ts = ts; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java new file mode 100644 index 0000000..1d0242a --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java @@ -0,0 +1,50 @@ +package com.casic.accessControl.app.dto; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.util.TimeFormat; + +/** + * Created by lenovo on 2016/4/13. + */ +public class ApkVersionDto { + private String version; + private String path; + private String ts; + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public String getTs() { + return ts; + } + + public void setTs(String ts) { + this.ts = ts; + } + + public static ApkVersionDto Convert(ApkVersion version) { + if (version == null) { + return null; + } + ApkVersionDto versionDto = new ApkVersionDto(); + versionDto.setVersion(version.getVersion()); + versionDto.setPath(version.getVersion()); + versionDto.setTs(TimeFormat.formatTimestamp(version.getTs())); + + return versionDto; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java b/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java new file mode 100644 index 0000000..28b12a7 --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java @@ -0,0 +1,27 @@ +package com.casic.accessControl.app.manager; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.core.hibernate.HibernateEntityDao; +import org.hibernate.Query; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * + */ +@Service("apkVersionManager") +public class ApkVersionManager extends HibernateEntityDao { + + public ApkVersion getLatestVersion() { + String sql = "from ApkVersion order by ts desc"; + Query query = getSession().createQuery(sql); + List list = query.list(); + if (null != list && list.isEmpty() == false) { + return list.get(0); + } + + return null; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java b/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java new file mode 100644 index 0000000..065d3cc --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java @@ -0,0 +1,66 @@ +package com.casic.accessControl.app.web; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.app.manager.ApkVersionManager; +import com.casic.accessControl.marker.domain.Marker; +import com.casic.accessControl.marker.manager.MarkerManager; +import com.casic.accessControl.task.domain.Task; +import com.casic.accessControl.task.domain.TaskDetail; +import com.casic.accessControl.task.dto.TaskDetailDto; +import com.casic.accessControl.task.dto.TaskDto; +import com.casic.accessControl.task.dto.TaskStatus; +import com.casic.accessControl.task.manager.TaskDetailManager; +import com.casic.accessControl.task.manager.TaskManager; +import com.casic.accessControl.user.domain.Company; +import com.casic.accessControl.user.domain.Role; +import com.casic.accessControl.user.domain.User; +import com.casic.accessControl.user.dto.UserDto; +import com.casic.accessControl.user.manager.RoleManager; +import com.casic.accessControl.user.manager.UserManager; +import com.casic.accessControl.util.DataTable; +import com.casic.accessControl.util.StringUtils; +import com.google.gson.Gson; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +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.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * Created by lenovo on 2016/4/13. + */ +@Controller +@RequestMapping("app") +public class ApkVersionController { + + @Resource + private ApkVersionManager apkVersionManager; + + @RequestMapping("get-latest-version") + @ResponseBody + public Map getLatestVersion(HttpServletResponse response, HttpSession session) { + Map result = new HashMap(); + try { + ApkVersion latest = apkVersionManager.getLatestVersion(); + if (null != latest) { + result.put("version", latest.getVersion()); + result.put("path", latest.getPath()); + } else { + result.put("version", "1.0.0"); + } + } catch (Exception e) { + e.printStackTrace(); + result.put("version", "1.0.0"); + } + + return result; + } + +} diff --git a/src/main/java/com/casic/accessControl/marker/domain/Marker.java b/src/main/java/com/casic/accessControl/marker/domain/Marker.java index 0575cfe..7d5b854 100644 --- a/src/main/java/com/casic/accessControl/marker/domain/Marker.java +++ b/src/main/java/com/casic/accessControl/marker/domain/Marker.java @@ -67,6 +67,10 @@ private String area; @Column(name = "line") private String line; + @Column(name = "colorType") + private String colorType; + @Column(name = "photos") + private String photos; @@ -315,4 +319,20 @@ public void setArea(String area) { this.area = area; } + + public String getColorType() { + return colorType; + } + + public void setColorType(String colorType) { + this.colorType = colorType; + } + + public String getPhotos() { + return photos; + } + + public void setPhotos(String photos) { + this.photos = photos; + } } diff --git a/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java b/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java index 506f31d..c5f8cf5 100644 --- a/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java +++ b/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java @@ -2,12 +2,12 @@ //import com.casic.accessControl.feature.domain.Feature; import com.casic.accessControl.marker.domain.Marker; +import com.casic.accessControl.util.StringUtils; +import com.casic.accessControl.util.TimeFormat; import org.apache.commons.collections.CollectionUtils; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.List; +import java.text.ParseException; +import java.util.*; /** * Created by lenovo on 2016/5/16. @@ -43,6 +43,8 @@ private Long userId; private String area; private String line; + private String colorType; + private String photos; private String btnEdit = "编辑"; private String btnDelete = "删除"; @@ -296,6 +298,23 @@ this.area = area; } + public String getColorType() { + if (StringUtils.isEmpty(colorType)) return "0"; + return colorType; + } + + public void setColorType(String colorType) { + this.colorType = colorType; + } + + public String getPhotos() { + return photos; + } + + public void setPhotos(String photos) { + this.photos = photos; + } + public String getLine() { return line; } @@ -335,6 +354,52 @@ result.setRoad(doNullChange(marker.getRoad())); result.setArea(doNullChange(marker.getArea())); result.setLine(doNullChange(marker.getLine())); + result.setColorType(marker.getColorType()); + result.setPhotos(marker.getPhotos()); + return result; + } + + public static Marker convert2Marker(MarkerDto markerDto) { + if (markerDto == null) return null; + Marker result = new Marker(); + if(markerDto.getLongitude()==null||markerDto.getLatitude()==null) return null; + if (null != markerDto.getCreateTime() && markerDto.getCreateTime().length() == 19) { + try { + result.setCreateTime(TimeFormat.parse(markerDto.getCreateTime(), "yyyy-MM-dd HH:mm:ss")); + } catch (ParseException pex) { + result.setCreateTime(Calendar.getInstance().getTime()); + } + } else { + result.setCreateTime(Calendar.getInstance().getTime()); + } + result.setDepth(doNullChange(markerDto.getDepth())); + result.setId(markerDto.getId()); + result.setLatitude(markerDto.getLatitude()); + result.setLongitude(markerDto.getLongitude()); + result.setMarkerId(markerDto.getMarkerId()); + result.setMarkerDepth(doNullChange(markerDto.getMarkerDepth())); + result.setMarkerObjectId(doNullChange(markerDto.getMarkerObjectId())); + result.setMarkerObjectType(doNullChange(markerDto.getMarkerObjectType())); + result.setOwnerComp(doNullChange(markerDto.getOwnerComp())); + result.setIsValid(markerDto.getIsValid()); + result.setMemo(doNullChange(markerDto.getMemo())); + result.setPipeDiameter(doNullChange(markerDto.getPipeDiameter())); + result.setPipeMaterial(doNullChange(markerDto.getPipeMaterial())); + result.setMarkerType(doNullChange(markerDto.getMarkerType())); + result.setCreator(doNullChange(markerDto.getCreator())); + + result.setLayStyle(doNullChange(markerDto.getLayStyle())); + result.setBelowDepth(doNullChange(markerDto.getBelowDepth())); + result.setBelowDiameter(doNullChange(markerDto.getBelowDiameter())); + result.setBelowMaterial(doNullChange(markerDto.getBelowMaterial())); + result.setBelowType(doNullChange(markerDto.getBelowType())); + result.setConstructTime(doNullChange(markerDto.getConstructTime())); + result.setRecordType(markerDto.getRecordType()); + result.setRoad(doNullChange(markerDto.getRoad())); + result.setArea(doNullChange(markerDto.getArea())); + result.setLine(doNullChange(markerDto.getLine())); + result.setColorType(markerDto.getColorType()); + result.setPhotos(markerDto.getPhotos()); return result; } diff --git a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java index dd0fa4b..ba5a1fb 100644 --- a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java +++ b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java @@ -9,10 +9,7 @@ import com.casic.accessControl.marker.domain.Marker; import com.casic.accessControl.user.domain.Company; import com.casic.accessControl.user.domain.User; -import com.casic.accessControl.util.DataTable; -import com.casic.accessControl.util.DataTableParameter; -import com.casic.accessControl.util.DataTableUtils; -import com.casic.accessControl.util.DateUtils; +import com.casic.accessControl.util.*; import com.google.gson.Gson; import jxl.*; import jxl.read.biff.BiffException; @@ -31,11 +28,15 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; +import sun.misc.BASE64Decoder; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.File; +import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.text.ParseException; @@ -183,6 +184,53 @@ } /** + * 保存标识器和图片信息 + * @param markerDto + * @param companyId + * @param fileNames + * @param fileBuffers + * @return + */ + public boolean saveMarkerAndPhotos(MarkerDto markerDto, Long companyId, String[] fileNames, String[] fileBuffers) { + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + String strDirPath = request.getSession().getServletContext().getRealPath(""); + FileOutputStream fos = null; + String month = TimeFormat.format(Calendar.getInstance().getTime(), "yyyyMM"); + String webPath = "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String toDir = strDirPath + "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String filePaths = ""; + try { + for (int i = 0; i < fileBuffers.length; i++) { + if (fileBuffers[i] != null && fileNames[i] != null) { +// filePaths += toDir+fileNames[i]+","; + filePaths += webPath + fileNames[i] + ","; + byte[] buffer = new BASE64Decoder().decodeBuffer(fileBuffers[i]); //对android传过来的图片字符串进行解码 + File destDir = new File(toDir); + if (!destDir.exists()) + destDir.mkdirs(); + File imageFile = new File(destDir, fileNames[i]); + fos = new FileOutputStream(imageFile); //保存图片 + fos.write(buffer); + fos.flush(); + fos.close(); + } + } + if (filePaths.endsWith(",")) { + filePaths = filePaths.substring(0, filePaths.length() - 1); + } + } catch (Exception e) { + return false; + } + Marker marker = MarkerDto.convert2Marker(markerDto); + marker.setIsValid(1); + marker.setCompanyId(companyId); + marker.setPhotos(filePaths); + save(marker); + return true; + + } + + /** * 新增标识器 8-9 * * @param markers @@ -582,7 +630,7 @@ "所属区域","所属线路","所属道路","建设年代","权属单位","标示对象ID", "标识器ID","标识器类型","标识器埋深","安装部门","经度", "纬度", "最后修改时间","备注","下层管种类", "下层管埋深", - "下层管直径", "下层管材料", "标识对象类别"}; + "下层管直径", "下层管材料", "标识对象类别", "标识点颜色", "图片地址"}; Label[][] labels = new Label[markerDtos.size() + 1][titleTxt.length]; for(int k=0;k saveMarkerAndPhotos(@RequestParam(value = "fileBuffer1", required = false) MultipartFile fileBuffer1, + @RequestParam(value = "fileBuffer2", required = false) MultipartFile fileBuffer2, + @RequestParam(value = "fileBuffer3", required = false) MultipartFile fileBuffer3, + @RequestParam(value = "jsonMarker", required = true) String jsonMarker) { + Map map = new HashMap(); + map.put("message", "安装无标识器信息"); + Gson gson = new Gson(); + try { + MarkerDto marker = gson.fromJson(jsonMarker, MarkerDto.class); + + if (null == marker.getMarkerId()) { + map.put("message", "无标识器ID"); + map.put("success", "false"); + return map; + } else if (markerManager.getMarkerByMarkerId(marker.getMarkerId()).size() > 0) { + map.put("message", "已安装过该标识器[" + marker.getMarkerId() + "]"); + map.put("success", "false"); + return map; + } else { + String[] fileNames = new String[3]; + String[] fileBuffers = new String[3]; + if (fileBuffer1 != null) { + fileNames[0] = marker.getMarkerId() + "_" + fileBuffer1.getOriginalFilename(); + byte[] fis = fileBuffer1.getBytes(); + fileBuffers[0] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, com.sun.org.apache.xml.internal.security.utils.Base64.BASE64DEFAULTLENGTH)); + } + if (fileBuffer2 != null) { + fileNames[1] = marker.getMarkerId() + "_" + fileBuffer2.getOriginalFilename(); + byte[] fis = fileBuffer2.getBytes(); + fileBuffers[1] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, com.sun.org.apache.xml.internal.security.utils.Base64.BASE64DEFAULTLENGTH)); + } + if (fileBuffer3 != null) { + fileNames[2] = marker.getMarkerId() + "_" + fileBuffer3.getOriginalFilename(); + byte[] fis = fileBuffer3.getBytes(); + fileBuffers[2] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, Base64.BASE64DEFAULTLENGTH)); + } + Long companyId = marker.getCompanyId(); + if (companyId == null) { + return map; + } + boolean result = markerManager.saveMarkerAndPhotos(marker, companyId, fileNames, fileBuffers); + if (!result) { + return map; + } + } + } catch (Exception e) { + return map; + } + map.put("success", "true"); + map.put("message", "保存成功"); + return map; + } + + @RequestMapping("marker-info-delete") @ResponseBody public Map delete(@RequestParam(value = "id", required = true) Long id) { @@ -144,6 +208,9 @@ map.put("message", "删除需要ID信息"); return map; } + + System.out.println(ids); + markerManager.delMarkerByIds(ids); map.put("success", true); map.put("message", "删除成功"); @@ -240,6 +307,54 @@ return map; } + /** + * 批量上传标识点,用于无信号地区标识器信息统一上传,不修改已有标识点信息 + * @param strMarkers + * @return + */ + @RequestMapping("batch-save-no-update") + @ResponseBody + public Map batchSaveOrUpdate(@RequestParam(value = "markers", required = true) String strMarkers) { + strMarkers = strMarkers.replace('\n',' '); + Map map = new HashMap(); + map.put("message", "批量导入失败,或无导入标识器信息"); + Gson gson = new Gson(); + try { + List markers = gson.fromJson(strMarkers, new TypeToken>() { + }.getType()); + if (CollectionUtils.isEmpty(markers)) {//批量导入数据不存在,直接返回 + map.put("message", "批量导入数据不存在"); + return map; + } + + Long companyId = markers.get(0).getCompanyId(); + if (companyId == null) { + map.put("message", "未找到所属公司属性"); + return map; + } + + List markerDtoForSave = new ArrayList(); + for (MarkerDto markerDto : markers) { + // 上传marker的Id不为空且数据库中不存在记录,经纬度不为空,允许保存 + if (StringUtils.isNotBlank(markerDto.getMarkerId()) && markerManager.getMarkerByMarkerId(markerDto.getMarkerId()).size() <= 0) { + if (null != markerDto.getLongitude() && null != markerDto.getLatitude()) { + markerDtoForSave.add(markerDto); + } + } + } + boolean result = markerManager.batchSave(markerDtoForSave, companyId); + if (!result) { + return map; + } + } catch (Exception e) { + e.printStackTrace(); + return map; + } + map.put("success", true); + map.put("message", "保存成功"); + return map; + } + @RequestMapping("getMarkerListByCondition") @ResponseBody @POST diff --git a/src/main/java/com/casic/accessControl/user/web/UserController.java b/src/main/java/com/casic/accessControl/user/web/UserController.java index feab678..3534a97 100644 --- a/src/main/java/com/casic/accessControl/user/web/UserController.java +++ b/src/main/java/com/casic/accessControl/user/web/UserController.java @@ -46,6 +46,7 @@ @ResponseBody public Map login(@ModelAttribute User userInfo, HttpSession session) { Map result = new HashMap(); + User user = null; try{ user = userManager.login(userInfo); diff --git a/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java b/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java new file mode 100644 index 0000000..582120f --- /dev/null +++ b/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java @@ -0,0 +1,129 @@ +package com.casic.accessControl.util; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.net.URL; +import java.net.URLConnection; +import java.util.List; +import java.util.Map; + +/** + * Created by lenovo on 2016/8/31. + */ +public class HttpRequestUtils { + + /** + * 向指定URL发送GET方法的请求 + * + * @param url + * 发送请求的URL + * @param param + * 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 + * @return URL 所代表远程资源的响应结果 + */ + public static String sendGet(String url, String param) { + String result = ""; + BufferedReader in = null; + try { + String urlNameString = url + "?" + param; + URL realUrl = new URL(urlNameString); + // 打开和URL之间的连接 + URLConnection connection = realUrl.openConnection(); + // 设置通用的请求属性 + connection.setRequestProperty("accept", "*/*"); + connection.setRequestProperty("connection", "Keep-Alive"); + connection.setRequestProperty("user-agent", + "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + // 建立实际的连接 + connection.connect(); + // 获取所有响应头字段 + Map> map = connection.getHeaderFields(); + // 遍历所有的响应头字段 + for (String key : map.keySet()) { + System.out.println(key + "--->" + map.get(key)); + } + // 定义 BufferedReader输入流来读取URL的响应 + in = new BufferedReader(new InputStreamReader( + connection.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + result += line; + } + } catch (Exception e) { + System.out.println("发送GET请求出现异常!" + e); + e.printStackTrace(); + } + // 使用finally块来关闭输入流 + finally { + try { + if (in != null) { + in.close(); + } + } catch (Exception e2) { + e2.printStackTrace(); + } + } + return result; + } + + /** + * 向指定 URL 发送POST方法的请求 + * + * @param url + * 发送请求的 URL + * @param param + * 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 + * @return 所代表远程资源的响应结果 + */ + public static String sendPost(String url, String param) { + PrintWriter out = null; + BufferedReader in = null; + String result = ""; + try { + URL realUrl = new URL(url); + // 打开和URL之间的连接 + URLConnection conn = realUrl.openConnection(); + // 设置通用的请求属性 + conn.setRequestProperty("accept", "*/*"); + conn.setRequestProperty("connection", "Keep-Alive"); + conn.setRequestProperty("user-agent", + "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + // 发送POST请求必须设置如下两行 + conn.setDoOutput(true); + conn.setDoInput(true); + // 获取URLConnection对象对应的输出流 + out = new PrintWriter(conn.getOutputStream()); + // 发送请求参数 + out.print(param); + // flush输出流的缓冲 + out.flush(); + // 定义BufferedReader输入流来读取URL的响应 + in = new BufferedReader( + new InputStreamReader(conn.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + result += line; + } + } catch (Exception e) { + System.out.println("发送 POST 请求出现异常!"+e); + e.printStackTrace(); + } + //使用finally块来关闭输出流、输入流 + finally{ + try{ + if(out!=null){ + out.close(); + } + if(in!=null){ + in.close(); + } + } + catch(IOException ex){ + ex.printStackTrace(); + } + } + return result; + } + } \ No newline at end of file diff --git a/src/main/java/com/casic/accessControl/util/TimeFormat.java b/src/main/java/com/casic/accessControl/util/TimeFormat.java new file mode 100644 index 0000000..e9168d5 --- /dev/null +++ b/src/main/java/com/casic/accessControl/util/TimeFormat.java @@ -0,0 +1,148 @@ +package com.casic.accessControl.util; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +/** + * 格式化日期工具类 + * 默认模式yyyy-MM-dd HH:mm:ss + * @author Administrator + * + */ +public class TimeFormat { + + private static final String DATE_FORMAT_STRING = "yyyy-MM-dd"; + private static final String TIME_FORMAT_STRING = "HH:mm:ss"; + private static final String TIMESTAMP_FORMAT_STRING = "yyyy-MM-dd HH:mm:ss"; + + // 默认格式化格式 + private static SimpleDateFormat defaultFormat = new SimpleDateFormat(TIMESTAMP_FORMAT_STRING); + + public static void setFormatString(String pattern) { + defaultFormat.applyPattern(pattern); + } + + /** + * 默认格式化日期 + * + * @param Date date + * @return String + */ + public static String format(Date date) { + return defaultFormat.format(date); + } + + /** + * 日期格式化 + * + * @param date + * @return + */ + public static String formatDate(Date date) { + return TimeFormat.format(date, DATE_FORMAT_STRING); + } + + /** + * 时间格式化 + * + * @param date + * @return + */ + public static String formatTime(Date date) { + return TimeFormat.format(date, TIME_FORMAT_STRING); + } + + /** + * 时间戳格式化 + * + * @param date + * @return + */ + public static String formatTimestamp(Date date) { + return TimeFormat.format(date, TIMESTAMP_FORMAT_STRING); + } + + /** + * 以指定模式格式化日期 + * + * @param Date date + * @param String pattern + * @return String + */ + public static String format(Date date, String pattern) { + SimpleDateFormat formatter = new SimpleDateFormat(pattern); + return formatter.format(date); + } + + /** + * 根据起止日期生成日期序列 + * 包括start和end的日期 + * + * @param start + * @param end + * @return + */ + public static List generateDates(String start, String end) throws ParseException { + List dates = new ArrayList(); + Calendar s = Calendar.getInstance(); + Calendar e = Calendar.getInstance(); + s.setTime(TimeFormat.parse(start, DATE_FORMAT_STRING)); + s.set(Calendar.HOUR_OF_DAY, 0); + s.set(Calendar.MINUTE, 0); + s.set(Calendar.SECOND, 0); + e.setTime(TimeFormat.parse(end, DATE_FORMAT_STRING)); + e.set(Calendar.HOUR_OF_DAY, 0); + e.set(Calendar.MINUTE, 0); + e.set(Calendar.SECOND, 0); + while (s.before(e) == true) { + dates.add(TimeFormat.formatDate(s.getTime())); + s.add(Calendar.DATE, 1); + } + + dates.add(end); + return dates; + } + + + /** + * 解析日期字符串 + * + * @param String source + * @return Date + * + * @throws ParseException + */ + public static Date parse(String source) throws ParseException { + return defaultFormat.parse(source); + } + + /** + * 以指定模式解析日期 + * + * @param String source + * @param String pattern + * @return Date + * + * @throws ParseException + */ + public static Date parse(String source, String pattern) throws ParseException { + SimpleDateFormat formatter = new SimpleDateFormat(pattern); + return formatter.parse(source); + } + + + public static Date parseDateWithoutTime(String source) throws ParseException { + SimpleDateFormat formatter = new SimpleDateFormat(DATE_FORMAT_STRING); + Calendar date = Calendar.getInstance(); + date.setTime(formatter.parse(source)); + date.set(Calendar.HOUR, 0); + date.set(Calendar.HOUR, 0); + date.set(Calendar.MINUTE, 0); + return date.getTime(); + } + +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 53c91ea..cea976f 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -15,19 +15,17 @@ # ============================================================================ # db # ============================================================================ -#db.default.driverClassName=oracle.jdbc.driver.OracleDriver -#db.default.url=jdbc:oracle:thin:@192.168.0.203:1521:SZHTDB2 -#db.default.username=scott -#db.default.password=SZHTDB2 db.default.driverClassName=com.mysql.jdbc.Driver -db.default.url=jdbc:mysql://127.0.0.1:3306/ems?useUnicode=true&characterEncoding=UTF-8 -db.default.username=emsweb -db.default.password=emsweb +db.default.url=jdbc:mysql://127.0.0.1:3306/ems_tong?useUnicode=true&characterEncoding=UTF-8 +db.default.username=root +db.default.password=root +#db.default.username=emsweb +#db.default.password=emsweb #db.default.url=jdbc:mysql://119.254.110.71:3307/ems?useUnicode=true&characterEncoding=UTF-8 #db.default.username=root #db.default.password=rootems - -# ============================================================================ +# +## ============================================================================ # log4jdbc # ============================================================================ log4jdbc.enable=true diff --git a/src/main/resources/spring/applicationContext-filter.xml b/src/main/resources/spring/applicationContext-filter.xml index a08c5fc..98ac7d6 100644 --- a/src/main/resources/spring/applicationContext-filter.xml +++ b/src/main/resources/spring/applicationContext-filter.xml @@ -35,9 +35,13 @@ /user/ill-login.do /marker/exportMarker.do /marker/batchSave-na.do + /marker/batch-save-no-update.do + /marker/save-marker-photo.do /event/save-event.do /task/get-task.do + /app/get-latest-version.do /xls/* + /apk/* diff --git a/src/main/resources/spring/applicationContext-hibernate.xml b/src/main/resources/spring/applicationContext-hibernate.xml index 5bb1a7e..dc54192 100644 --- a/src/main/resources/spring/applicationContext-hibernate.xml +++ b/src/main/resources/spring/applicationContext-hibernate.xml @@ -65,6 +65,7 @@ com.casic.accessControl.task.domain.Position com.casic.accessControl.event.domain.Event com.casic.accessControl.marker.domain.OptionItem + com.casic.accessControl.app.domain.ApkVersion diff --git a/src/main/webapp/common/layout/menu_new.jsp b/src/main/webapp/common/layout/menu_new.jsp index 3cf4b4e..cbd822e 100644 --- a/src/main/webapp/common/layout/menu_new.jsp +++ b/src/main/webapp/common/layout/menu_new.jsp @@ -20,7 +20,7 @@
                                    • - + @@ -54,7 +54,7 @@
                                    • - + diff --git a/src/main/webapp/content/ems/ems-gd.jsp b/src/main/webapp/content/ems/ems-gd.jsp new file mode 100644 index 0000000..5137b49 --- /dev/null +++ b/src/main/webapp/content/ems/ems-gd.jsp @@ -0,0 +1,604 @@ +<%@page contentType="text/html;charset=UTF-8" %> + +<%@include file="/taglibs.jsp" %> + +<%pageContext.setAttribute("currentMenu", "ems");%> + + + + + + + + + + + + + 地下管线电子标识系统 + + + + + + + + + + + + + + + + + + +<%-- + +--%> + + + + + + + + + + + + + + +<%@include file="/common/layout/header.jsp" %> + +
                                      + + + + <%@include file="/common/layout/menu_new.jsp" %> + + + +
                                      + + + +
                                      + +
                                      + + +
                                      +
                                      +
                                      +
                                      + +
                                      +
                                      + +
                                      +
                                      + +
                                      +
                                      + +
                                      +
                                      + +
                                      + +
                                      + +
                                      + +
                                      + +
                                      + +
                                      +
                                      +
                                      + + + + +
                                      +
                                      +
                                      +
                                      + + + + +
                                      +
                                      +
                                      + +
                                      + +
                                      + +<%--todo list:错误使用方法 + +--%> +
                                      + +
                                      +
                                      + +
                                      + +
                                      + +
                                      + + +
                                      + +
                                      + + 移动 + 绘制区域 + 新增标识器 + 删除标识器 + 保存标识器 + 批量导入 + 导出Excel + 清空 + +
                                      + +
                                      +
                                      + +
                                      + + + +
                                      + +
                                      + +
                                      + + + + +
                                      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/webapp/content/task/task-gd.jsp b/src/main/webapp/content/task/task-gd.jsp new file mode 100644 index 0000000..d2d5549 --- /dev/null +++ b/src/main/webapp/content/task/task-gd.jsp @@ -0,0 +1,374 @@ +<%@page contentType="text/html;charset=UTF-8" %> + +<%@include file="/taglibs.jsp" %> + +<%pageContext.setAttribute("currentMenu", "task");%> + + + + + + + + + + + + + 地下管线电子标识系统 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +<%@include file="/common/layout/header.jsp" %> + +
                                      + + + + <%@include file="/common/layout/menu_new.jsp" %> + + + +
                                      + + + +
                                      + +
                                      + +
                                      + + 移动 + 绘制区域 + 选择多点创建工单 + 清空选择 + +
                                      + +
                                      + +
                                      + + +
                                      + +
                                      + +
                                      + +
                                      历史工单
                                      + +
                                      + +
                                      + +
                                      + <%--巡检员:--%> +
                                      +
                                      + + +
                                      +
                                      + + +
                                        +
                                      +
                                        +
                                        + +
                                        + +
                                        + +
                                        + +
                                        +
                                        + +
                                        + + + +
                                        + +
                                        + +
                                        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/webapp/images/drop/0.png b/src/main/webapp/images/drop/0.png new file mode 100644 index 0000000..f4b966b --- /dev/null +++ b/src/main/webapp/images/drop/0.png Binary files differ diff --git a/src/main/webapp/images/drop/1.png b/src/main/webapp/images/drop/1.png new file mode 100644 index 0000000..9284b64 --- /dev/null +++ b/src/main/webapp/images/drop/1.png Binary files differ diff --git a/src/main/webapp/images/drop/2.png b/src/main/webapp/images/drop/2.png new file mode 100644 index 0000000..b5425db --- /dev/null +++ b/src/main/webapp/images/drop/2.png Binary files differ diff --git a/src/main/webapp/images/drop/3.png b/src/main/webapp/images/drop/3.png new file mode 100644 index 0000000..dd09655 --- /dev/null +++ b/src/main/webapp/images/drop/3.png Binary files differ diff --git a/src/main/webapp/images/drop/4.png b/src/main/webapp/images/drop/4.png new file mode 100644 index 0000000..50cf1f7 --- /dev/null +++ b/src/main/webapp/images/drop/4.png Binary files differ diff --git a/src/main/webapp/images/drop/5.png b/src/main/webapp/images/drop/5.png new file mode 100644 index 0000000..a2029bd --- /dev/null +++ b/src/main/webapp/images/drop/5.png Binary files differ diff --git a/src/main/webapp/images/drop/6.png b/src/main/webapp/images/drop/6.png new file mode 100644 index 0000000..b53248a --- /dev/null +++ b/src/main/webapp/images/drop/6.png Binary files differ diff --git a/src/main/webapp/images/ems/point.png b/src/main/webapp/images/ems/point.png new file mode 100644 index 0000000..a814351 --- /dev/null +++ b/src/main/webapp/images/ems/point.png Binary files differ diff --git a/src/main/webapp/images/ems/rect.png b/src/main/webapp/images/ems/rect.png new file mode 100644 index 0000000..99d0c9e --- /dev/null +++ b/src/main/webapp/images/ems/rect.png Binary files differ diff --git a/src/main/webapp/images/events/red_icon.png b/src/main/webapp/images/events/red_icon.png new file mode 100644 index 0000000..78c26e4 --- /dev/null +++ b/src/main/webapp/images/events/red_icon.png Binary files differ diff --git a/src/main/webapp/images/point-task.png b/src/main/webapp/images/point-task.png new file mode 100644 index 0000000..b2e22c6 --- /dev/null +++ b/src/main/webapp/images/point-task.png Binary files differ diff --git a/src/main/webapp/images/point.png b/src/main/webapp/images/point.png new file mode 100644 index 0000000..4b887dc --- /dev/null +++ b/src/main/webapp/images/point.png Binary files differ diff --git a/src/main/webapp/images/tasks/point.png b/src/main/webapp/images/tasks/point.png new file mode 100644 index 0000000..a814351 --- /dev/null +++ b/src/main/webapp/images/tasks/point.png Binary files differ diff --git a/src/main/webapp/images/tasks/rect.png b/src/main/webapp/images/tasks/rect.png new file mode 100644 index 0000000..99d0c9e --- /dev/null +++ b/src/main/webapp/images/tasks/rect.png Binary files differ diff --git a/src/main/webapp/s/app/ems/EMSBean.js b/src/main/webapp/s/app/ems/EMSBean.js index ca6914b..a3b1dca 100644 --- a/src/main/webapp/s/app/ems/EMSBean.js +++ b/src/main/webapp/s/app/ems/EMSBean.js @@ -1,5 +1,6 @@ EMSBean = function (markerObjectType,pipeMaterial,pipeDiameter, layStyle, depth, belowType, belowDepth, belowDiameter, belowMaterial, road, - constructTime, ownerComp, markerObjectId, markerId, markerType, markerDepth, creator, createTime, memo, lat, long, recordType,id,line,area) { + constructTime, ownerComp, markerObjectId, markerId, markerType, markerDepth, creator, createTime, memo, lat, long, + recordType,id,line,area, colorType) { this.markerObjectType = markerObjectType; this.pipeMaterial = pipeMaterial; @@ -26,5 +27,5 @@ this.id = id; this.line=line; this.area =area; - + this.colorType = colorType; }; diff --git a/src/main/webapp/s/app/ems/ems-gd.js b/src/main/webapp/s/app/ems/ems-gd.js new file mode 100644 index 0000000..8875ae8 --- /dev/null +++ b/src/main/webapp/s/app/ems/ems-gd.js @@ -0,0 +1,627 @@ +/** + * Created by lenovo on 2016/4/13. + */ +//定义全局变量,缓存组织结构 + +var EmsGd = function () { + var isSaveStatus = false; + var map = null; + var mouseTool = null; + var drawOverlays = new Array(); + var readyToUploadMarkers = new Array(); + var vectorMarkers = []; + var markerData = []; + var hadRequest = false; + + var blueIcon = new AMap.Icon({ + size: new AMap.Size(25, 34), + image: $('#context').val() + '/images/drop/0.png' + }); + + var orangeIcon = new AMap.Icon({ + size: new AMap.Size(25, 34), + image: $('#context').val() + '/images/drop/1.png' + }); + + var redIcon = new AMap.Icon({ + size: new AMap.Size(25, 34), + image: $('#context').val() + '/images/drop/2.png' + }); + + var blackIcon = new AMap.Icon({ + size: new AMap.Size(25, 34), + image: $('#context').val() + '/images/drop/3.png' + }); + + var pinkIcon = new AMap.Icon({ + size: new AMap.Size(25, 34), + image: $('#context').val() + '/images/drop/4.png' + }); + + var yellowIcon = new AMap.Icon({ + size: new AMap.Size(25, 34), + image: $('#context').val() + '/images/drop/5.png' + }); + + var greenIcon = new AMap.Icon({ + size: new AMap.Size(25, 34), + image: $('#context').val() + '/images/drop/6.png' + }); + + var handleDatePickers = function () { + + if (jQuery().datepicker) { + $('.date-picker').datepicker({ + rtl: App.isRTL() + }); + } + } + + function requestMarkers() { + if (markerData.length == 0&!hadRequest) { + hadRequest = true; + $.ajax({ + type: "get", + url: $('#context').val() + "/marker/all-point-list.do", + dataType: "json", +// async:false, + cache: false, + success: function (r) { + if (r.data) {//请求成功,将获取到的数据加载到地图上 + //1.解析返回的结果,.设置全局变量data的值 + markerData = [];//清空原来的数据 + for (var t = 0; t < r.data.length; t++) { + var markerDto = r.data[t]; + var emsBean = new EMSBean(markerDto.markerObjectType, markerDto.pipeMaterial, markerDto.pipeDiameter, markerDto.layStyle, + markerDto.depth, markerDto.belowType, markerDto.belowDepth, markerDto.belowDiameter, + markerDto.belowMaterial, markerDto.road, markerDto.constructTime, markerDto.ownerComp, + markerDto.markerObjectId, markerDto.markerId, markerDto.markerType, markerDto.markerDepth, + markerDto.creator, markerDto.createTime, markerDto.memo, markerDto.latitude, markerDto.longitude, + markerDto.recordType, markerDto.id,markerDto.line,markerDto.area,markerDto.colorType); + markerData[t] = emsBean; + } + //2.增加marker + EmsGd.addMarker(markerData); + } + hadRequest = false; + map.off("complete", requestMarkers()); + }, + error: function (d) {//请求出错 + hadRequest = false; + map.off("complete", requestMarkers()); + } + }); + } else if(!hadRequest){ + EmsGd.addMarker(markerData); + } + + } + + return { + + //添加标识器 + emsAddCallBack: function () { + $('#addModal').modal('show'); + }, + + //删除标识器 + emsDelCallBack: function () { + //绘制矩形区域: + if (drawOverlays.length == 0) { + swal("请先绘制区域", "", "warning"); + return; + } + + var pointArray = new Array(); + var readyToDel = ""; + for (var i = 0; i < drawOverlays.length; i++) { + var layer = drawOverlays[i]; + try { + // 生成判断是否在多边形内的数据格式 + var path = []; + for (var k = 0; k < layer.He.path.length; k++) { + var pos = []; + pos.push(layer.He.path[k].lng, layer.He.path[k].lat); + path.push(pos); + } + for (var j = 0; j < markerData.length; j++) { + var emsBean = markerData[j]; + var point = new AMap.LngLat(emsBean.longitude, emsBean.latitude); + var isPointInRing = AMap.GeometryUtil.isPointInRing(point, path); + if (isPointInRing) { + pointArray.push(point); + readyToDel = readyToDel + emsBean.id + ","; + } + } + } catch (e) { + swal("脚本异常", e.message, "error"); + } + if (pointArray.length <= 0) { + swal("选择区域没有要删除的点", "", "warning"); + for (var i in drawOverlays) { + map.remove(drawOverlays[i]); + } + return; + } + + swal({ + title: "是否确认删除?", + text: "删除是不可恢复的", + type: "warning", + showCancelButton: true, + confirmButtonText: "确认", + cancelButtonText: "取消", + closeOnConfirm: false + }, function() { + $.ajax({ + type: "get", + url: $('#context').val() + "/marker/delMarkerByIds.do", + dataType: "json", + cache: false, + data: { + "ids": readyToDel + }, + success: function (r) { + if (r.success) {//请求成功 + swal({ + title: "删除标识器成功", + text: "", + type: "success", + confirmButtonText: "确认", + closeOnConfirm: false + }, function() { + location.href = $('#context').val() + "/content/ems/ems-gd.jsp"; + }); + } + }, + error: function (d) {//请求出错 + swal("请求异常", d.responseText, "error"); + } + }); + }); + } + }, + + //保存标识器 + emsSaveCallBack: function () { + + if (readyToUploadMarkers.length == 0) { + return; + } + if (isSaveStatus) { + swal("保存过于频繁", "请稍后操作", "warning"); + return; + } + isSaveStatus = true; + //TODO LIST:上传 + var uploadMaker = new Array(); + for (var i = 0; i < readyToUploadMarkers.length; i++) { + var emsBean = readyToUploadMarkers[i].Tag; + + if (!emsBean.depth) { + emsBean.depth = 0; + } + uploadMaker.push(emsBean); + } + $.ajax({ + type: "get", + url: $('#context').val() + "/marker/batchSave.do", + dataType: "json", + cache: false, + data: { + markers: JSON.stringify(uploadMaker) + }, + success: function (r) { + if (r.success) {//请求成功 + swal({ + title: "保存标识器成功", + text: "", + type: "success", + confirmButtonText: "确认", + closeOnConfirm: false + }, function() { + location.href = $('#context').val() + "/content/ems/ems-gd.jsp"; + }); + } + }, + error: function (d) {//请求出错 + swal("请求出错", d.responseText, "error"); + isSaveStatus = false; + } + }); + }, + + emsUploadCallBack: function () { + // map.zoomTo(map.getZoom() + 2); + //TODO LIST:弹出对应的对话框 + $('#uploadModal').modal('show'); + }, + + emsExportCallBack: function () { + //TODO LIST:选择导出的文件 +// map.zoomTo(map.getZoom() + 2); + location.href = $('#context').val() + "/marker/export.do"; + + }, + + // 清除地图上所有后添加的标记点 + clearOverlays: function () { + mouseTool.close(true)//关闭,并清除覆盖物 + + for (var i = 0; i < drawOverlays.length; i++) { + map.remove(drawOverlays[i]); + } + for (var i = 0; i < readyToUploadMarkers.length; i++) { + map.remove(readyToUploadMarkers[i]); + } + for (var i = 0; i < vectorMarkers.length; i++) { + map.remove(vectorMarkers[i]); + } + + drawOverlays = []; + readyToUploadMarkers = []; + vectorMarkers = []; + }, + + initMap: function () { + + // 创建地图实例 + map = new AMap.Map("container", { + zoom: 13, + resizeEnable: true, + zooms: [4,18],//设置地图级别范围 + }); + + //声明全局变量 + if (!markerData || markerData.length == 0) { + markerData = new Array(); + } + + // 鼠标操作工具栏 + mouseTool = new AMap.MouseTool(map); + mouseTool.on('draw',function(e){ + drawOverlays.push(e.obj); + }) + + //加载完毕请求标识点信息 + map.on("complete", requestMarkers); + }, + + // 绘制区域矩形框 + drawRect: function () { + mouseTool.rectangle(); + }, + + //取消绘制区域矩形框 + moveMap: function () { + mouseTool.close(true)//关闭,并清除覆盖物 + }, + + initForm: function () { + handleDatePickers(); + $("#selectObjectType").chosen(); + $("#resetEms").live("click", function (e) { + $("#markerObjectType").val(""); + $("#pipeDiameter").val(""); + $("#pipeMaterial").val(""); + $("#belowPipeType").val(""); + $("#belowPipeDepth").val(""); + $("#belowPipeDiameter").val(""); + $("#belowPipeMaterial").val(""); + $("#pipeDepth").val(""); + $("#layStyle").val(""); + $("#line").val(""); + $("#area").val(""); + $("#road").val(""); + $("#constructTime").val(""); + $("#ownerComp").val(""); + $("#markerObjectId").val(""); + $("#markerId").val(""); + $("#markerType").val(""); + $("#markerDepth").val(""); + $("#creator").val(""); + $("#memo").val(""); + + }); + + $('#localize').click(function (e) { + $('#addModal').modal('hide'); + + //注册地图点击事件 + function showInfo(e) { + map.off("click", showInfo); + var lng = e.lnglat.lng; + var lat = e.lnglat.lat; + //TODO LIST:获取填写表单的信息 所属区域也需要保存的 + var selectObjectType = $("#selectObjectType").val();//判断是哪个类别 + var markerObjectType = $("#markerObjectType").val(); + var pipeDiameter = $("#pipeDiameter").val(); + var pipeMaterial = $("#pipeMaterial").val(); + var belowPipeType = $("#belowPipeType").val(); + var belowPipeDepth = $("#belowPipeDepth").val(); + var belowPipeDiameter = $("#belowPipeDiameter").val(); + var belowPipeMaterial = $("#belowPipeMaterial").val(); + var pipeDepth = $("#pipeDepth").val(); + var layStyle = $("#layStyle").val(); + var road = $("#road").val(); + var constructTime = $("#constructTime").val(); + var ownerComp = $("#ownerComp").val(); + var markerObjectId = $("#markerObjectId").val(); + var markerId = $("#markerId").val(); + var markerType = $("#markerType").val(); + var markerDepth = $("#markerDepth").val(); + var creator = $("#creator").val(); + var memo = $("#memo").val(); + var line = $("#line").val(); + var area = $("#area").val(); + var emsBean = new EMSBean(markerObjectType, pipeMaterial, pipeDiameter, layStyle, pipeDepth, belowPipeType, belowPipeDepth, belowPipeDiameter, belowPipeMaterial, + road, constructTime, ownerComp, markerObjectId, markerId, markerType, markerDepth, creator, null, memo, lat, lng, selectObjectType,null,line,area); + var marker = new AMap.Marker({ + position: [lng, lat], + draggable: true + }); + + marker.on("click", attribute); + marker.Tag = emsBean; + map.add(marker); //增加点 + readyToUploadMarkers.push(marker); + function attribute() { + var emsBean2 = marker.Tag; + var searchInfoWindow = null; + var msg = ""; + var height = 0; + var titleName =""; + if (emsBean.recordType == 1) { + titleName = "
                                        管线
                                        "; + msg = msg + "管线种类:" + emsBean2.markerObjectType + "
                                        " + + "管线直径(mm):" + emsBean2.pipeDiameter + "
                                        " + + "管线材质:" + emsBean2.pipeMaterial + "
                                        " + + "埋设方式:" + emsBean2.layStyle + "
                                        " + + "管线埋深(mm):" + emsBean2.depth + "
                                        "; + height = 100; + } else if (emsBean.recordType == 2) { + titleName = "
                                        管线附属物
                                        "; + msg = msg + "附属物名称:" + emsBean2.markerObjectType + "
                                        " + + "井深(mm):" + emsBean2.depth + "
                                        "; + height = 40; + } else if (emsBean.recordType == 3) { + titleName = "
                                        管线特征管点
                                        "; + msg = msg + "管点特征:" + emsBean2.markerObjectType + "
                                        " + + "特征点埋深(mm):" + emsBean2.depth + "
                                        "; + height = 40; + } else { + titleName = "
                                        交叉穿越点
                                        "; + msg = msg + "上层管种类:" + emsBean2.markerObjectType + "
                                        " + + "上层管埋深(mm):" + emsBean2.depth + "
                                        " + + "上层管直径(mm):" + emsBean2.pipeDiameter + "
                                        " + + "上层管材料:" + emsBean2.pipeMaterial + "
                                        " + + "下层管种类:" + emsBean2.belowType + "
                                        " + + "下层管埋深(mm):" + emsBean2.belowDepth + "
                                        "+ + "下层管直径(mm):" + emsBean2.belowDiameter + "
                                        " + + "下层管材料:" + emsBean2.belowMaterial + "
                                        " ; + height = 160; + } + height = height +225; + msg = msg + "所属区域:" + emsBean2.area + "
                                        " + + "所属线路:" + emsBean2.line + "
                                        " + + "所属道路:" + emsBean2.road + "
                                        " + + "建设年代:" + emsBean2.constructTime + "
                                        " + + "权属单位:" + emsBean2.ownerComp + "
                                        " + + "标识器ID:" + emsBean2.markerId + "
                                        " + + "标识器类型:" + emsBean2.markerType + "
                                        " + + "标识器埋深(mm):" + emsBean2.markerDepth + "
                                        " + + "安装部门:" + emsBean2.creator + "
                                        " + + "最后修改时间:"+emsBean2.createTime + "
                                        " + + "备注:" + emsBean2.memo + "
                                        "; + var imgUrl = $('#context').val() + "/images/ems.jpg"; + var content = titleName + '
                                        ' + + '' + msg + + '
                                        '; + + var infowindow = new AMap.AdvancedInfoWindow({ + content: content, + width: 290, //宽度 + height: height, //高度 + panel: "panel", //检索结果面板 + enableAutoPan: true //自动平移 + }); + + infowindow.open(map, [e.lnglat.lng, e.lnglat.lat]); + } + + } + map.on("click", showInfo); + }); + + $("#searchMarker").click(function (e) { + var Marker = {}; + if (vectorMarkers.length != 0) { + for (var i = 0; i < vectorMarkers.length; i++) { + map.remove(vectorMarkers[i]); + } + } + vectorMarkers = []; + Marker.road = $("#roadCondition").val(); + Marker.memo = $("#memoCondition").val(); + Marker.area = $("#select_area").val(); + Marker.line = $("#select_line").val(); + Marker.ownerComp = $("#company").val(); + Marker.creator = $("#department").val(); + Marker.sDate = $("#txt_begin_day").val(); + Marker.eDate = $("#txt_end_day").val(); + //请求后台的id列表,然后遍历marker列表,修改marker的颜色 + $.ajax({ + type: "POST", + url: $('#context').val() + "/marker/getMarkerListByCondition.do", + data: {"strMarkerDto": JSON.stringify(Marker)}, + dataType: "json", + success: function (r) { + if (r.data) { + var pointArray = new Array(); + if (r.data.length > 1000) { + swal("有超过一千个点符合筛选条件", "会造成浏览器卡顿,请重新选择", "warning"); + } else { + if (r.data.length == 0) { + swal("没有搜到符合条件的标识器", "请重新选择", "warning"); + return; + } + for (var a in r.data) {//遍历列表,添加marker + var vectorMarker = new AMap.Marker({ + position: [r.data[a].longitude,r.data[a].latitude], + size: new AMap.Size(30, 30), + icon: $('#context').val() + '/images/point.png' + }); + vectorMarkers.push(vectorMarker); + map.add(vectorMarker); + } + map.setFitView(vectorMarkers); + } + + } + }, + error: function (request) { + //提示错误信息 + swal("脚本异常", r.message, "error"); + } + }); + }); + + //控制不同种类对象的标签信息显示 + $("#selectObjectType").die().live("change", function (e) { + var type = $("#selectObjectType").val(); + OptionItemProcess.initPipeTypeList(type); + if (type == 1) {//管线 + $("#pipeTypeLabel").text("管线种类"); + $(".up-pipe").show(); + $("#pipeDiameterLabel").text("管线直径"); + $("#pipeMaterialLabel").text("管线材质"); + $(".below").addClass("hidden"); + $("#pipeDepthLabel").text("管线埋深"); + $(".pipeOnly").show(); + } else if (type == 2) {//管线附属物 + $("#pipeTypeLabel").text("附属物名称"); + $(".up-pipe").hide(); + $(".below").addClass("hidden"); + $("#pipeDepthLabel").text("井深"); + $(".pipeOnly").hide(); + } else if (type == 3) {//管线特征点 + $("#pipeTypeLabel").text("管点特征"); + $(".up-pipe").hide(); + $(".below").addClass("hidden"); + $("#pipeDepthLabel").text("特征点埋深"); + $(".pipeOnly").hide(); + } else {//交叉穿越点 + $("#pipeTypeLabel").text("上层管种类"); + $(".up-pipe").show(); + $("#pipeDiameterLabel").text("上层管直径"); + $("#pipeMaterialLabel").text("上层管材料"); + $(".below").removeClass("hidden"); + $("#pipeDepthLabel").text("上层管埋深"); + $(".pipeOnly").hide(); + } + }); + + OptionItemProcess.initPipeTypeList($("#selectObjectType").val()); + OptionItemProcess.initBelowPipeTypeList(); + OptionItemProcess.initAreaList(); + OptionItemProcess.initLayStyleList(); + OptionItemProcess.initMaterialList(); + }, + + initSelect: function () { + $("#selectObjectType").chosen(); + }, + + addMarker: function (data) { + for (var i = 0; i < data.length; i++) { + var icon = blueIcon; + var color = data[i].colorType; + if (color == "1") { + icon = orangeIcon; + } else if (color == "2") { + icon = redIcon; + } else if (color == "3") { + icon = blackIcon; + } else if (color == "4") { + icon = pinkIcon; + } else if (color == "5") { + icon = yellowIcon; + } else if (color == "6") { + icon = greenIcon; + } + + var marker = new AMap.Marker({ + position: [data[i].longitude, data[i].latitude], + icon: icon + }); + marker.Tag = data[i]; + + marker.on("click", function (e) { + + var emsBean = e.target.Tag; + var msg = ""; + var height = 0; + var titleName =""; + if (emsBean.recordType == 1) { + titleName = "
                                        管线
                                        "; + msg = msg + "管线种类:" + emsBean.markerObjectType + "
                                        " + + "管线直径(mm):" + emsBean.pipeDiameter + "
                                        " + + "管线材质:" + emsBean.pipeMaterial + "
                                        " + + "埋设方式:" + emsBean.layStyle + "
                                        " + + "管线埋深(mm):" + emsBean.depth + "
                                        "; + height = 100; + } else if (emsBean.recordType == 2) { + titleName = "
                                        管线附属物
                                        "; + msg = msg + "附属物名称:" + emsBean.markerObjectType + "
                                        " + + "井深(mm):" + emsBean.depth + "
                                        "; + height = 40; + } else if (emsBean.recordType == 3) { + titleName = "
                                        管线特征管点
                                        "; + msg = msg + "管点特征:" + emsBean.markerObjectType + "
                                        " + + "特征点埋深(mm):" + emsBean.depth + "
                                        "; + height = 40; + } else { + titleName = "
                                        交叉穿越点
                                        "; + msg = msg + "上层管种类:" + emsBean.markerObjectType + "
                                        " + + "上层管埋深(mm):" + emsBean.depth + "
                                        " + + "上层管直径(mm):" + emsBean.pipeDiameter + "
                                        " + + "上层管材料:" + emsBean.pipeMaterial + "
                                        " + + "下层管种类:" + emsBean.belowType + "
                                        " + + "下层管埋深(mm):" + emsBean.belowDepth + "
                                        "+ + "下层管直径(mm):" + emsBean.belowDiameter + "
                                        " + + "下层管材料:" + emsBean.belowMaterial + "
                                        " ; + height = 160; + } + height = height +225; + msg = msg + "所属区域:" + emsBean.area + "
                                        " + + "所属线路:" + emsBean.line + "
                                        " + + "所属道路:" + emsBean.road + "
                                        " + + "建设年代:" + emsBean.constructTime + "
                                        " + + "权属单位:" + emsBean.ownerComp + "
                                        " + + "标识器ID:" + emsBean.markerId + "
                                        " + + "标识器类型:" + emsBean.markerType + "
                                        " + + "标识器埋深(mm):" + emsBean.markerDepth + "
                                        " + + "安装部门:" + emsBean.creator + "
                                        " + + "最后修改时间:"+emsBean.createTime + "
                                        " + + "备注:" + emsBean.memo + "
                                        "; + var imgUrl = $('#context').val() + "/images/ems.jpg"; + var content = titleName + '
                                        ' + + '' + msg + + '
                                        '; + + var infowindow = new AMap.AdvancedInfoWindow({ + content: content, + width: 290, //宽度 + height: height, //高度 + panel: "panel", //检索结果面板 + enableAutoPan: true //自动平移 + }); + + infowindow.open(map, [e.lnglat.lng, e.lnglat.lat]); + }); + + map.add(marker); + } + } + }; +}(); \ No newline at end of file diff --git a/src/main/webapp/s/app/task/task-gd.js b/src/main/webapp/s/app/task/task-gd.js new file mode 100644 index 0000000..abf4da0 --- /dev/null +++ b/src/main/webapp/s/app/task/task-gd.js @@ -0,0 +1,689 @@ +/** + * Created by lenovo on 2016/4/13. + */ +//定义全局变量,缓存组织结构 + +var TaskGd = function () { + + var map = null; + var mouseTool = null; + var taskMarkers = ""; + var drawOverlays = new Array(); + var drawTaskOverlays = new Array(); + var drawEventOverlays = []; + var taskLists; + var taskDetailLists = new Array(); + var eventBeanList = []; + var viewPoints = []; + var markerData = []; + var hadRequest = false; + + var blueIcon = new AMap.Icon({ + size: new AMap.Size(25, 34), + image: $('#context').val() + '/images/drop/0.png' + }); + + var orangeIcon = new AMap.Icon({ + size: new AMap.Size(25, 34), + image: $('#context').val() + '/images/drop/1.png' + }); + + var redIcon = new AMap.Icon({ + size: new AMap.Size(25, 34), + image: $('#context').val() + '/images/drop/2.png' + }); + + var blackIcon = new AMap.Icon({ + size: new AMap.Size(25, 34), + image: $('#context').val() + '/images/drop/3.png' + }); + + var pinkIcon = new AMap.Icon({ + size: new AMap.Size(25, 34), + image: $('#context').val() + '/images/drop/4.png' + }); + + var yellowIcon = new AMap.Icon({ + size: new AMap.Size(25, 34), + image: $('#context').val() + '/images/drop/5.png' + }); + + var greenIcon = new AMap.Icon({ + size: new AMap.Size(25, 34), + image: $('#context').val() + '/images/drop/6.png' + }); + + // 历史工单列表属性 + var options = { + valueNames: [ 'id', 'patrolerName', 'status', 'deployDate', 'beginDate', 'endDate', 'description', {attr: 'src', name: 'image'} ], + item: '
                                      • ' + + '

                                        ' + + '

                                        ' + + '

                                        ' + + '

                                        ' + + '

                                        ' + + '

                                        ' + + '' + + '
                                        ' + + '
                                        ' + + '
                                      • ', + page: 3, + plugins: [ ListPagination({}) ] + }; + + // 清除所有绘制的区域图层 + function clearAll() { + for (var i = 0; i < drawOverlays.length; i++) { + map.remove(drawOverlays[i]); + } + drawOverlays.length = 0; + } + + // 清除工单任务绘制的标识器点 + function clearAllTaskPoint() { + for (var i = 0; i < drawTaskOverlays.length; i++) { + map.remove(drawTaskOverlays[i]); + } + drawTaskOverlays.length = 0; + taskDetailLists.length = 0; + } + + // 清除工单任务绘制的事件点 + function clearAllEventPoint() { + for (var i = 0; i < drawEventOverlays.length; i++) { + map.remove(drawEventOverlays[i]); + } +// drawEventOverlays.length = 0; + drawEventOverlays = []; + eventBeanList = []; + } + + // 查询巡检任务列表 + function getTaskInfo(patroler) { + taskLists.clear(); + $.ajax({ + type: "get", + url: $('#context').val() + "/task/get-task.do", + dataType: "json", + cache: false, + data: { + + }, + success: function (r) { + if (r.success) {//请求成功 + for (var data in r.data) { + var icon = $('#context').val() + "/images/accidents/worker.png"; + var id = r.data[data].id; + var patrolerName = r.data[data].patrolerName; + if (patroler && patrolerName != patroler) { + continue; + } + var description = r.data[data].description; + var deployDate = r.data[data].deployDate; + var beginDate = r.data[data].beginDate; + var endDate = r.data[data].endDate; + var status = r.data[data].status; + var creatorName = r.data[data].creatorName; + var task = new TaskBean(id, icon, patrolerName, description, deployDate, beginDate, endDate, status, creatorName); + + task.patrolerName = "巡检员:" + task.patrolerName; + task.description = "任务描述:" + task.description; + task.deployDate = "下发时间:" + task.deployDate; + task.beginDate = task.beginDate == null ? "开始时间:" : "开始时间:" + task.beginDate; + task.endDate = task.endDate == null ? "完成时间:" : "完成时间:" + task.endDate; + task.status = "任务状态:" + task.status; + taskLists.add(task); + } + } else { + swal("后台数据请求异常", r.message, "error"); + } + }, + error: function (d) {//请求出错 + swal("后台数据请求出错", d.responseText, "error"); + } + }); + } + + // 展示事件信息 + function showEventInfo(e) { + var p = e.target; + var imgName = p.Tag.imageName; + var images = imgName.split(",");//图片路径数组 +// alert(images[0]); + var msg2 = "事件描述:" + p.Tag.description + "
                                        " + + "上传时间:" + p.Tag.createTime + "
                                        "; + $("#eventImg").children().remove();//avatar1.jpg + var imageDivs="
                                        "; +// var imageDivs =""; + var width = 100/images.length;//动态展示 + $("#viewHelper").children().remove(); + for(var i =0;i" + + "
                                        " + + "
                                        " + +// "
                                        "+ +// ""+ +// ""+ +// " "+ +// ""+ +// "
                                        " + + "
                                        " + +// imageDivs +=""; + } + imageDivs+="" + $(".fancybox-close").die().live("click",function(){ + $('#eventModal').modal('show').css({width: "300px"}); + }); + $(".zoom-icon").die().live("click",function(){ + $('#eventModal').modal('hide'); + }); +// alert(eval(imageDivs)) + $("#eventImg").append(imageDivs) + $("#eventDescription").html(msg2); + $('#eventModal').modal('show').css({width: "300px"}); +// alert("showEventInfo:"+images); +// eventImgPage(images.length, 1, images); + + } + + // 获取标识器点 + function requestMarkers() { + if (markerData.length == 0&&!hadRequest) { + hadRequest = true; + $.ajax({ + type: "get", + url: $('#context').val() + "/marker/all-point-list.do", + dataType: "json", + cache: false, + success: function (r) { + if (r.data) {//请求成功,将获取到的数据加载到地图上 + //1.解析返回的结果,.设置全局变量data的值 + markerData = [];//清空原来的数据 + for (var t = 0; t < r.data.length; t++) { + var markerDto = r.data[t]; + var emsBean = new EMSBean(markerDto.markerObjectType, markerDto.pipeMaterial, markerDto.pipeDiameter, markerDto.layStyle, + markerDto.depth, markerDto.belowType, markerDto.belowDepth, markerDto.belowDiameter, + markerDto.belowMaterial, markerDto.road, markerDto.constructTime, markerDto.ownerComp, + markerDto.markerObjectId, markerDto.markerId, markerDto.markerType, markerDto.markerDepth, + markerDto.creator, markerDto.createTime, markerDto.memo, markerDto.latitude, markerDto.longitude, + markerDto.recordType, markerDto.id,markerDto.line,markerDto.area, markerDto.colorType); + markerData[t] = emsBean; + } + //2.增加marker + TaskGd.addMarker(markerData); + } + hadRequest = false; + map.off("complete", requestMarkers()); + + }, + error: function (d) {//请求出错 + hadRequest = false; + map.off("complete", requestMarkers()); + } + }); + } else if(!hadRequest){ + TaskGd.addMarker(markerData); + } + + } + return { + + //添加工单 + selectMarkerCallBack: function () { + //绘制矩形区域: + taskMarkers = ""; + if (drawOverlays.length == 0) { + swal("请先绘制区域", "", "warning"); + return; + } + for (var i = 0; i < drawOverlays.length; i++) { + var layer = drawOverlays[i]; + try { + // 生成判断是否在多边形内的数据格式 + var path = []; + for (var k = 0; k < layer.He.path.length; k++) { + var pos = []; + pos.push(layer.He.path[k].lng, layer.He.path[k].lat); + path.push(pos); + } + + for (var j = 0; j < markerData.length; j++) { + var emsBean = markerData[j]; + var point = new AMap.LngLat(emsBean.longitude, emsBean.latitude); + var isPointInRing = AMap.GeometryUtil.isPointInRing(point, path); + if (isPointInRing) { + taskMarkers = taskMarkers + emsBean.id + ","; + } + } + } catch (e) { + swal("脚本异常", e.message, "error"); + } + } + if (taskMarkers == "") { + swal("请选择标识器点!", "", "error"); + return; + } + + $('#addTaskModal2').modal('show'); + clearAll(); + }, + + //清除 + clearCallBack: function () { + taskMarkers = ""; + clearAll(); + }, + + //上传工单 + uploadTaskCallBack: function (patrolerId, description) { + $.ajax({ + type: "get", + url: $('#context').val() + "/task/task-Save.do", + dataType: "json", + cache: false, + data: { + markers: taskMarkers, + patrolerId: patrolerId, + description: description + }, + success: function (r) { + if (r.success) {//请求成功 + swal({ + title: "请求成功", + text: r.message, + type: "success", + confirmButtonText: "确认" + }, function() { + TaskGd.updateList(); + }); + } else { + swal("请求失败", r.message, "error"); + } + }, + error: function (d) {//请求出错 + swal("请求失败", d.message, "error"); + } + }); + }, + + // 初始化地图 + initMap: function () { + + map = new AMap.Map("container", { + zoom: 13, + resizeEnable: true, + zooms: [4,18],//设置地图级别范围 + }); + + //声明全局变量 + if (!markerData || markerData.length == 0) { + markerData = new Array(); + } + + // 鼠标操作工具栏 + mouseTool = new AMap.MouseTool(map); + mouseTool.on('draw',function(e){ + drawOverlays.push(e.obj); + }); + + //加载完毕请求标识点信息 + map.on("complete", requestMarkers); + }, + + initList: function () { + taskLists = new List('worksheets', options); + TaskGd.updateList(); + //$('.sort').click(); + $('#btnSort').trigger("click"); + $('#btnSort').trigger("click"); + + $('#btnSort').css("padding", 0); + $('#btnSort').css("padding-left", 10); + $('#btnSort').css("padding-right", 15); + $('#btnSort').css("margin-bottom", 10); + + TaskGd.bindClickEvent(); + + $('#selectPatroler3').live('change', function (e) {//下拉列表更改的时候查询数据,更新列表,待优化为查询条件在后台利用 + TaskGd.updateList($("#selectPatroler3").val()); + }); + }, + + // 绑定任务列表单击事件 + bindClickEvent: function () { + $('#worksheets ul li').live('click', function (e) { + viewPoints = []; + if (null == this.getElementsByClassName("id")[0]) { + return; + } + clearAllTaskPoint(); + clearAllEventPoint(); + var taskId = this.getElementsByClassName("id")[0].innerHTML; + var i = 0; + //请求任务 + $.ajax({ + type: "get", + url: $('#context').val() + "/task/get-task-markers.do", + dataType: "json", + async:false, + cache: false, + data: { + taskId: taskId + }, + success: function (r) { + if (r.success) {//请求成功 + for (var data in r.data) { + var id = r.data[data].id; + var markerName = r.data[data].markerIdReal; + var latitude = r.data[data].latitude; + var longitude = r.data[data].longitude; + var finishTime = r.data[data].finishTime == null ? "" : r.data[data].finishTime; + var description = r.data[data].description == null ? "" : r.data[data].description; + var status = r.data[data].isChecked; + var icon = ""; + var isChecked = ""; + if (status == 0) { + icon = $('#context').val() + "/images/point-task.png"; + isChecked = "未巡检"; + } + else { + icon = $('#context').val() + "/images/point.png"; + isChecked = "已巡检"; + } + + var taskDetailBean = new TaskDetailBean(id, icon, markerName, latitude, longitude, isChecked, finishTime, description); + taskDetailLists.push(taskDetailBean); + + } + TaskGd.addTaskDetailMarker(taskDetailLists); + } + else { + alert(r.message); + } + }, + error: function (d) {//请求出错 + alert(d.message); + } + }); + + //请求该任务上报的事件 + $.ajax({ + type: "get", + url: $('#context').val() + "/event/get-event-list.do", + dataType: "json", + cache: false, + async:false, + data: { + taskId: taskId + }, + success: function (r) { + if (r.success) {//请求成功 + for (var data in r.data) { + var id = r.data[data].id; + var imageName = r.data[data].imageName; + var latitude = r.data[data].latitude; + var longitude = r.data[data].longitude; + var createTime = r.data[data].createTime == null ? "" : r.data[data].createTime; + var description = r.data[data].description == null ? "" : r.data[data].description; + var status = r.data[data].status; + var eventBean = new EventBean(id, imageName, latitude, longitude, description, status, createTime); + + eventBeanList.push(eventBean); + + } + TaskGd.addEventMarker(eventBeanList); + } + else { + alert(r.message); + } + }, + error: function (d) {//请求出错 + alert(d.message); + } + }); + + map.setFitView(viewPoints); + + }); + + }, + + /* + * 增加报警信息到列表 + * */ + updateList: function (patroler) { + getTaskInfo(patroler); + }, + + // 初始化表单操作 + initForm: function () { + $("#saveTask2").click(function (e) { + //alert(taskMarkers); + var patrolerId = $("#selectPatroler2").val(); + var description = $("#description2").val(); + TaskGd.uploadTaskCallBack(patrolerId, description); + $('#addTaskModal2').modal('hide'); + $("#description2").val(""); + }); + }, + + //获取巡检员列表 + initPatrolerArray: function () { + + $.ajax({ + type: "POST", + url: $('#context').val() + "/user/get-patroler.do", + data: {}, + dataType: "json", + success: function (r) { + //获取面的列表,将下拉列表初始化 + if (r.data) { + for (var user in r.data) { + //alert(r.data[user].id+":"+r.data[user].userName); + $("#selectPatroler").append(" "); + $("#selectPatroler2").append(" "); + $("#selectPatroler3").append(" "); + } + $("#selectPatroler").chosen(); + $("#selectPatroler2").chosen(); + $("#selectPatroler3").chosen(); + } + }, + error: function (d) { + //提示错误信息 + swal("请求巡检员列表出错", d.responseText, "error"); + } + }); + + }, + + // 绘制区域矩形框 + drawRect: function () { + mouseTool.rectangle(); + }, + + //取消绘制区域矩形框 + moveMap: function () { + mouseTool.close(true)//关闭,并清除覆盖物 + }, + + //初始化下拉列表框 + initSelect: function () { + TaskGd.initPatrolerArray(); + }, + + // 显示标识器点 + addMarker: function (data) { + for (var i = 0; i < data.length; i++) { + var icon = blueIcon; + var color = data[i].colorType; + if (color == "1") { + icon = orangeIcon; + } else if (color == "2") { + icon = redIcon; + } else if (color == "3") { + icon = blackIcon; + } else if (color == "4") { + icon = pinkIcon; + } else if (color == "5") { + icon = yellowIcon; + } else if (color == "6") { + icon = greenIcon; + } + + var marker = new AMap.Marker({ + position: [data[i].longitude, data[i].latitude], + icon: icon + }); + marker.Tag = data[i]; + + marker.on("click", function (e) { + + var emsBean = e.target.Tag; + var msg = ""; + var height = 0; + var titleName =""; + if (emsBean.recordType == 1) { + titleName = "
                                        管线
                                        "; + msg = msg + "管线种类:" + emsBean.markerObjectType + "
                                        " + + "管线直径(mm):" + emsBean.pipeDiameter + "
                                        " + + "管线材质:" + emsBean.pipeMaterial + "
                                        " + + "埋设方式:" + emsBean.layStyle + "
                                        " + + "管线埋深(mm):" + emsBean.depth + "
                                        "; + height = 100; + } else if (emsBean.recordType == 2) { + titleName = "
                                        管线附属物
                                        "; + msg = msg + "附属物名称:" + emsBean.markerObjectType + "
                                        " + + "井深(mm):" + emsBean.depth + "
                                        "; + height = 40; + } else if (emsBean.recordType == 3) { + titleName = "
                                        管线特征管点
                                        "; + msg = msg + "管点特征:" + emsBean.markerObjectType + "
                                        " + + "特征点埋深(mm):" + emsBean.depth + "
                                        "; + height = 40; + } else { + titleName = "
                                        交叉穿越点
                                        "; + msg = msg + "上层管种类:" + emsBean.markerObjectType + "
                                        " + + "上层管埋深(mm):" + emsBean.depth + "
                                        " + + "上层管直径(mm):" + emsBean.pipeDiameter + "
                                        " + + "上层管材料:" + emsBean.pipeMaterial + "
                                        " + + "下层管种类:" + emsBean.belowType + "
                                        " + + "下层管埋深(mm):" + emsBean.belowDepth + "
                                        "+ + "下层管直径(mm):" + emsBean.belowDiameter + "
                                        " + + "下层管材料:" + emsBean.belowMaterial + "
                                        " ; + height = 160; + } + height = height +225; + msg = msg + "所属区域:" + emsBean.area + "
                                        " + + "所属线路:" + emsBean.line + "
                                        " + + "所属道路:" + emsBean.road + "
                                        " + + "建设年代:" + emsBean.constructTime + "
                                        " + + "权属单位:" + emsBean.ownerComp + "
                                        " + + "标识器ID:" + emsBean.markerId + "
                                        " + + "标识器类型:" + emsBean.markerType + "
                                        " + + "标识器埋深(mm):" + emsBean.markerDepth + "
                                        " + + "安装部门:" + emsBean.creator + "
                                        " + + "最后修改时间:"+emsBean.createTime + "
                                        " + + "备注:" + emsBean.memo + "
                                        "; + var imgUrl = $('#context').val() + "/images/ems.jpg"; + var content = titleName + '
                                        ' + + '' + msg + + '
                                        '; + + var infowindow = new AMap.AdvancedInfoWindow({ + content: content, + width: 290, //宽度 + height: height, //高度 + panel: "panel", //检索结果面板 + enableAutoPan: true //自动平移 + }); + + infowindow.open(map, [e.lnglat.lng, e.lnglat.lat]); + }); + + map.add(marker); + } + }, + + //增加事件图片的marker + addEventMarker: function () { + console.log(eventBeanList); + for (var i = 0; i < eventBeanList.length; i++) { + var eventMarker = new AMap.Marker({ + position: [eventBeanList[i].longitude, eventBeanList[i].latitude], + size: new AMap.Size(30, 30), + icon: new AMap.Icon({ + size: new AMap.Size(38, 38), + image: $('#context').val() + "/images/events/red_icon.png" + }) + }); + + var msg = "事件描述:" + eventBeanList[i].description + "\r\n" + + "上传时间:" + eventBeanList[i].createTime + "\r\n"; + eventMarker.setTitle(msg); + eventMarker.Tag = eventBeanList[i]; + viewPoints.push(eventMarker); + eventMarker.on("click", showEventInfo); + map.add(eventMarker); // 将标注添加到地图中 + drawEventOverlays.push(eventMarker); + } + }, + + // 点击任务列表绘制任务对应的标识器点 + addTaskDetailMarker: function (data) { + for (var i = 0; i < data.length; i++) { + var msg = "标识器名称:" + data[i].markerName + "\r\n" + + "巡检状态:" + data[i].isChecked + "\r\n" + + "巡检时间:" + data[i].finishTime + "\r\n" + + "描述:" + data[i].description + "\r\n"; + + var marker = new AMap.Marker({ + position: [data[i].longitude, data[i].latitude], + size: new AMap.Size(30, 30), + icon: data[i].icon + }); + + marker.setTitle(msg); + + viewPoints.push(marker); + drawTaskOverlays.push(marker); + map.add(marker); // 将标注添加到地图中 + } + } + }; +}(); + +TaskBean = function (id, icon, patrolerName, description, deployDate, beginDate, endDate, status, creatorName) { + this.id = id; + this.image = icon; + this.patrolerName = patrolerName; + this.description = description; + this.deployDate = deployDate; + this.beginDate = beginDate; + this.endDate = endDate; + this.status = status; + this.creatorName = creatorName; +}; + +TaskDetailBean = function (id, icon, markerName, latitude, longitude, isChecked, finishTime, description) { + this.id = id; + this.icon = icon; + this.markerName = markerName; + this.latitude = latitude; + this.longitude = longitude; + this.isChecked = isChecked; + this.finishTime = finishTime; + this.description = description; +}; + +EventBean = function (id, imageName, latitude, longitude, description, status, createTime) { + this.id = id; + this.imageName = imageName; + this.latitude = latitude; + this.longitude = longitude; + this.description = description; + this.status = status; + this.createTime = createTime; +} \ No newline at end of file diff --git a/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java new file mode 100644 index 0000000..634ceae --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java @@ -0,0 +1,46 @@ +package com.casic.accessControl.app.domain; + +import javax.persistence.*; +import java.util.Date; + +/** + * app的版本信息 + */ +//工单 +@Entity +@Table(name = "apkVersion") +public class ApkVersion { + private String version; + private String path; + private Date ts;//时间戳 + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "version") + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + @Column(name = "path") + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + @Column(name = "ts") + public Date getTs() { + return ts; + } + + public void setTs(Date ts) { + this.ts = ts; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java new file mode 100644 index 0000000..1d0242a --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java @@ -0,0 +1,50 @@ +package com.casic.accessControl.app.dto; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.util.TimeFormat; + +/** + * Created by lenovo on 2016/4/13. + */ +public class ApkVersionDto { + private String version; + private String path; + private String ts; + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public String getTs() { + return ts; + } + + public void setTs(String ts) { + this.ts = ts; + } + + public static ApkVersionDto Convert(ApkVersion version) { + if (version == null) { + return null; + } + ApkVersionDto versionDto = new ApkVersionDto(); + versionDto.setVersion(version.getVersion()); + versionDto.setPath(version.getVersion()); + versionDto.setTs(TimeFormat.formatTimestamp(version.getTs())); + + return versionDto; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java b/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java new file mode 100644 index 0000000..28b12a7 --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java @@ -0,0 +1,27 @@ +package com.casic.accessControl.app.manager; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.core.hibernate.HibernateEntityDao; +import org.hibernate.Query; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * + */ +@Service("apkVersionManager") +public class ApkVersionManager extends HibernateEntityDao { + + public ApkVersion getLatestVersion() { + String sql = "from ApkVersion order by ts desc"; + Query query = getSession().createQuery(sql); + List list = query.list(); + if (null != list && list.isEmpty() == false) { + return list.get(0); + } + + return null; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java b/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java new file mode 100644 index 0000000..065d3cc --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java @@ -0,0 +1,66 @@ +package com.casic.accessControl.app.web; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.app.manager.ApkVersionManager; +import com.casic.accessControl.marker.domain.Marker; +import com.casic.accessControl.marker.manager.MarkerManager; +import com.casic.accessControl.task.domain.Task; +import com.casic.accessControl.task.domain.TaskDetail; +import com.casic.accessControl.task.dto.TaskDetailDto; +import com.casic.accessControl.task.dto.TaskDto; +import com.casic.accessControl.task.dto.TaskStatus; +import com.casic.accessControl.task.manager.TaskDetailManager; +import com.casic.accessControl.task.manager.TaskManager; +import com.casic.accessControl.user.domain.Company; +import com.casic.accessControl.user.domain.Role; +import com.casic.accessControl.user.domain.User; +import com.casic.accessControl.user.dto.UserDto; +import com.casic.accessControl.user.manager.RoleManager; +import com.casic.accessControl.user.manager.UserManager; +import com.casic.accessControl.util.DataTable; +import com.casic.accessControl.util.StringUtils; +import com.google.gson.Gson; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +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.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * Created by lenovo on 2016/4/13. + */ +@Controller +@RequestMapping("app") +public class ApkVersionController { + + @Resource + private ApkVersionManager apkVersionManager; + + @RequestMapping("get-latest-version") + @ResponseBody + public Map getLatestVersion(HttpServletResponse response, HttpSession session) { + Map result = new HashMap(); + try { + ApkVersion latest = apkVersionManager.getLatestVersion(); + if (null != latest) { + result.put("version", latest.getVersion()); + result.put("path", latest.getPath()); + } else { + result.put("version", "1.0.0"); + } + } catch (Exception e) { + e.printStackTrace(); + result.put("version", "1.0.0"); + } + + return result; + } + +} diff --git a/src/main/java/com/casic/accessControl/marker/domain/Marker.java b/src/main/java/com/casic/accessControl/marker/domain/Marker.java index 0575cfe..7d5b854 100644 --- a/src/main/java/com/casic/accessControl/marker/domain/Marker.java +++ b/src/main/java/com/casic/accessControl/marker/domain/Marker.java @@ -67,6 +67,10 @@ private String area; @Column(name = "line") private String line; + @Column(name = "colorType") + private String colorType; + @Column(name = "photos") + private String photos; @@ -315,4 +319,20 @@ public void setArea(String area) { this.area = area; } + + public String getColorType() { + return colorType; + } + + public void setColorType(String colorType) { + this.colorType = colorType; + } + + public String getPhotos() { + return photos; + } + + public void setPhotos(String photos) { + this.photos = photos; + } } diff --git a/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java b/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java index 506f31d..c5f8cf5 100644 --- a/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java +++ b/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java @@ -2,12 +2,12 @@ //import com.casic.accessControl.feature.domain.Feature; import com.casic.accessControl.marker.domain.Marker; +import com.casic.accessControl.util.StringUtils; +import com.casic.accessControl.util.TimeFormat; import org.apache.commons.collections.CollectionUtils; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.List; +import java.text.ParseException; +import java.util.*; /** * Created by lenovo on 2016/5/16. @@ -43,6 +43,8 @@ private Long userId; private String area; private String line; + private String colorType; + private String photos; private String btnEdit = "编辑"; private String btnDelete = "删除"; @@ -296,6 +298,23 @@ this.area = area; } + public String getColorType() { + if (StringUtils.isEmpty(colorType)) return "0"; + return colorType; + } + + public void setColorType(String colorType) { + this.colorType = colorType; + } + + public String getPhotos() { + return photos; + } + + public void setPhotos(String photos) { + this.photos = photos; + } + public String getLine() { return line; } @@ -335,6 +354,52 @@ result.setRoad(doNullChange(marker.getRoad())); result.setArea(doNullChange(marker.getArea())); result.setLine(doNullChange(marker.getLine())); + result.setColorType(marker.getColorType()); + result.setPhotos(marker.getPhotos()); + return result; + } + + public static Marker convert2Marker(MarkerDto markerDto) { + if (markerDto == null) return null; + Marker result = new Marker(); + if(markerDto.getLongitude()==null||markerDto.getLatitude()==null) return null; + if (null != markerDto.getCreateTime() && markerDto.getCreateTime().length() == 19) { + try { + result.setCreateTime(TimeFormat.parse(markerDto.getCreateTime(), "yyyy-MM-dd HH:mm:ss")); + } catch (ParseException pex) { + result.setCreateTime(Calendar.getInstance().getTime()); + } + } else { + result.setCreateTime(Calendar.getInstance().getTime()); + } + result.setDepth(doNullChange(markerDto.getDepth())); + result.setId(markerDto.getId()); + result.setLatitude(markerDto.getLatitude()); + result.setLongitude(markerDto.getLongitude()); + result.setMarkerId(markerDto.getMarkerId()); + result.setMarkerDepth(doNullChange(markerDto.getMarkerDepth())); + result.setMarkerObjectId(doNullChange(markerDto.getMarkerObjectId())); + result.setMarkerObjectType(doNullChange(markerDto.getMarkerObjectType())); + result.setOwnerComp(doNullChange(markerDto.getOwnerComp())); + result.setIsValid(markerDto.getIsValid()); + result.setMemo(doNullChange(markerDto.getMemo())); + result.setPipeDiameter(doNullChange(markerDto.getPipeDiameter())); + result.setPipeMaterial(doNullChange(markerDto.getPipeMaterial())); + result.setMarkerType(doNullChange(markerDto.getMarkerType())); + result.setCreator(doNullChange(markerDto.getCreator())); + + result.setLayStyle(doNullChange(markerDto.getLayStyle())); + result.setBelowDepth(doNullChange(markerDto.getBelowDepth())); + result.setBelowDiameter(doNullChange(markerDto.getBelowDiameter())); + result.setBelowMaterial(doNullChange(markerDto.getBelowMaterial())); + result.setBelowType(doNullChange(markerDto.getBelowType())); + result.setConstructTime(doNullChange(markerDto.getConstructTime())); + result.setRecordType(markerDto.getRecordType()); + result.setRoad(doNullChange(markerDto.getRoad())); + result.setArea(doNullChange(markerDto.getArea())); + result.setLine(doNullChange(markerDto.getLine())); + result.setColorType(markerDto.getColorType()); + result.setPhotos(markerDto.getPhotos()); return result; } diff --git a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java index dd0fa4b..ba5a1fb 100644 --- a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java +++ b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java @@ -9,10 +9,7 @@ import com.casic.accessControl.marker.domain.Marker; import com.casic.accessControl.user.domain.Company; import com.casic.accessControl.user.domain.User; -import com.casic.accessControl.util.DataTable; -import com.casic.accessControl.util.DataTableParameter; -import com.casic.accessControl.util.DataTableUtils; -import com.casic.accessControl.util.DateUtils; +import com.casic.accessControl.util.*; import com.google.gson.Gson; import jxl.*; import jxl.read.biff.BiffException; @@ -31,11 +28,15 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; +import sun.misc.BASE64Decoder; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.File; +import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.text.ParseException; @@ -183,6 +184,53 @@ } /** + * 保存标识器和图片信息 + * @param markerDto + * @param companyId + * @param fileNames + * @param fileBuffers + * @return + */ + public boolean saveMarkerAndPhotos(MarkerDto markerDto, Long companyId, String[] fileNames, String[] fileBuffers) { + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + String strDirPath = request.getSession().getServletContext().getRealPath(""); + FileOutputStream fos = null; + String month = TimeFormat.format(Calendar.getInstance().getTime(), "yyyyMM"); + String webPath = "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String toDir = strDirPath + "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String filePaths = ""; + try { + for (int i = 0; i < fileBuffers.length; i++) { + if (fileBuffers[i] != null && fileNames[i] != null) { +// filePaths += toDir+fileNames[i]+","; + filePaths += webPath + fileNames[i] + ","; + byte[] buffer = new BASE64Decoder().decodeBuffer(fileBuffers[i]); //对android传过来的图片字符串进行解码 + File destDir = new File(toDir); + if (!destDir.exists()) + destDir.mkdirs(); + File imageFile = new File(destDir, fileNames[i]); + fos = new FileOutputStream(imageFile); //保存图片 + fos.write(buffer); + fos.flush(); + fos.close(); + } + } + if (filePaths.endsWith(",")) { + filePaths = filePaths.substring(0, filePaths.length() - 1); + } + } catch (Exception e) { + return false; + } + Marker marker = MarkerDto.convert2Marker(markerDto); + marker.setIsValid(1); + marker.setCompanyId(companyId); + marker.setPhotos(filePaths); + save(marker); + return true; + + } + + /** * 新增标识器 8-9 * * @param markers @@ -582,7 +630,7 @@ "所属区域","所属线路","所属道路","建设年代","权属单位","标示对象ID", "标识器ID","标识器类型","标识器埋深","安装部门","经度", "纬度", "最后修改时间","备注","下层管种类", "下层管埋深", - "下层管直径", "下层管材料", "标识对象类别"}; + "下层管直径", "下层管材料", "标识对象类别", "标识点颜色", "图片地址"}; Label[][] labels = new Label[markerDtos.size() + 1][titleTxt.length]; for(int k=0;k saveMarkerAndPhotos(@RequestParam(value = "fileBuffer1", required = false) MultipartFile fileBuffer1, + @RequestParam(value = "fileBuffer2", required = false) MultipartFile fileBuffer2, + @RequestParam(value = "fileBuffer3", required = false) MultipartFile fileBuffer3, + @RequestParam(value = "jsonMarker", required = true) String jsonMarker) { + Map map = new HashMap(); + map.put("message", "安装无标识器信息"); + Gson gson = new Gson(); + try { + MarkerDto marker = gson.fromJson(jsonMarker, MarkerDto.class); + + if (null == marker.getMarkerId()) { + map.put("message", "无标识器ID"); + map.put("success", "false"); + return map; + } else if (markerManager.getMarkerByMarkerId(marker.getMarkerId()).size() > 0) { + map.put("message", "已安装过该标识器[" + marker.getMarkerId() + "]"); + map.put("success", "false"); + return map; + } else { + String[] fileNames = new String[3]; + String[] fileBuffers = new String[3]; + if (fileBuffer1 != null) { + fileNames[0] = marker.getMarkerId() + "_" + fileBuffer1.getOriginalFilename(); + byte[] fis = fileBuffer1.getBytes(); + fileBuffers[0] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, com.sun.org.apache.xml.internal.security.utils.Base64.BASE64DEFAULTLENGTH)); + } + if (fileBuffer2 != null) { + fileNames[1] = marker.getMarkerId() + "_" + fileBuffer2.getOriginalFilename(); + byte[] fis = fileBuffer2.getBytes(); + fileBuffers[1] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, com.sun.org.apache.xml.internal.security.utils.Base64.BASE64DEFAULTLENGTH)); + } + if (fileBuffer3 != null) { + fileNames[2] = marker.getMarkerId() + "_" + fileBuffer3.getOriginalFilename(); + byte[] fis = fileBuffer3.getBytes(); + fileBuffers[2] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, Base64.BASE64DEFAULTLENGTH)); + } + Long companyId = marker.getCompanyId(); + if (companyId == null) { + return map; + } + boolean result = markerManager.saveMarkerAndPhotos(marker, companyId, fileNames, fileBuffers); + if (!result) { + return map; + } + } + } catch (Exception e) { + return map; + } + map.put("success", "true"); + map.put("message", "保存成功"); + return map; + } + + @RequestMapping("marker-info-delete") @ResponseBody public Map delete(@RequestParam(value = "id", required = true) Long id) { @@ -144,6 +208,9 @@ map.put("message", "删除需要ID信息"); return map; } + + System.out.println(ids); + markerManager.delMarkerByIds(ids); map.put("success", true); map.put("message", "删除成功"); @@ -240,6 +307,54 @@ return map; } + /** + * 批量上传标识点,用于无信号地区标识器信息统一上传,不修改已有标识点信息 + * @param strMarkers + * @return + */ + @RequestMapping("batch-save-no-update") + @ResponseBody + public Map batchSaveOrUpdate(@RequestParam(value = "markers", required = true) String strMarkers) { + strMarkers = strMarkers.replace('\n',' '); + Map map = new HashMap(); + map.put("message", "批量导入失败,或无导入标识器信息"); + Gson gson = new Gson(); + try { + List markers = gson.fromJson(strMarkers, new TypeToken>() { + }.getType()); + if (CollectionUtils.isEmpty(markers)) {//批量导入数据不存在,直接返回 + map.put("message", "批量导入数据不存在"); + return map; + } + + Long companyId = markers.get(0).getCompanyId(); + if (companyId == null) { + map.put("message", "未找到所属公司属性"); + return map; + } + + List markerDtoForSave = new ArrayList(); + for (MarkerDto markerDto : markers) { + // 上传marker的Id不为空且数据库中不存在记录,经纬度不为空,允许保存 + if (StringUtils.isNotBlank(markerDto.getMarkerId()) && markerManager.getMarkerByMarkerId(markerDto.getMarkerId()).size() <= 0) { + if (null != markerDto.getLongitude() && null != markerDto.getLatitude()) { + markerDtoForSave.add(markerDto); + } + } + } + boolean result = markerManager.batchSave(markerDtoForSave, companyId); + if (!result) { + return map; + } + } catch (Exception e) { + e.printStackTrace(); + return map; + } + map.put("success", true); + map.put("message", "保存成功"); + return map; + } + @RequestMapping("getMarkerListByCondition") @ResponseBody @POST diff --git a/src/main/java/com/casic/accessControl/user/web/UserController.java b/src/main/java/com/casic/accessControl/user/web/UserController.java index feab678..3534a97 100644 --- a/src/main/java/com/casic/accessControl/user/web/UserController.java +++ b/src/main/java/com/casic/accessControl/user/web/UserController.java @@ -46,6 +46,7 @@ @ResponseBody public Map login(@ModelAttribute User userInfo, HttpSession session) { Map result = new HashMap(); + User user = null; try{ user = userManager.login(userInfo); diff --git a/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java b/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java new file mode 100644 index 0000000..582120f --- /dev/null +++ b/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java @@ -0,0 +1,129 @@ +package com.casic.accessControl.util; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.net.URL; +import java.net.URLConnection; +import java.util.List; +import java.util.Map; + +/** + * Created by lenovo on 2016/8/31. + */ +public class HttpRequestUtils { + + /** + * 向指定URL发送GET方法的请求 + * + * @param url + * 发送请求的URL + * @param param + * 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 + * @return URL 所代表远程资源的响应结果 + */ + public static String sendGet(String url, String param) { + String result = ""; + BufferedReader in = null; + try { + String urlNameString = url + "?" + param; + URL realUrl = new URL(urlNameString); + // 打开和URL之间的连接 + URLConnection connection = realUrl.openConnection(); + // 设置通用的请求属性 + connection.setRequestProperty("accept", "*/*"); + connection.setRequestProperty("connection", "Keep-Alive"); + connection.setRequestProperty("user-agent", + "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + // 建立实际的连接 + connection.connect(); + // 获取所有响应头字段 + Map> map = connection.getHeaderFields(); + // 遍历所有的响应头字段 + for (String key : map.keySet()) { + System.out.println(key + "--->" + map.get(key)); + } + // 定义 BufferedReader输入流来读取URL的响应 + in = new BufferedReader(new InputStreamReader( + connection.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + result += line; + } + } catch (Exception e) { + System.out.println("发送GET请求出现异常!" + e); + e.printStackTrace(); + } + // 使用finally块来关闭输入流 + finally { + try { + if (in != null) { + in.close(); + } + } catch (Exception e2) { + e2.printStackTrace(); + } + } + return result; + } + + /** + * 向指定 URL 发送POST方法的请求 + * + * @param url + * 发送请求的 URL + * @param param + * 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 + * @return 所代表远程资源的响应结果 + */ + public static String sendPost(String url, String param) { + PrintWriter out = null; + BufferedReader in = null; + String result = ""; + try { + URL realUrl = new URL(url); + // 打开和URL之间的连接 + URLConnection conn = realUrl.openConnection(); + // 设置通用的请求属性 + conn.setRequestProperty("accept", "*/*"); + conn.setRequestProperty("connection", "Keep-Alive"); + conn.setRequestProperty("user-agent", + "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + // 发送POST请求必须设置如下两行 + conn.setDoOutput(true); + conn.setDoInput(true); + // 获取URLConnection对象对应的输出流 + out = new PrintWriter(conn.getOutputStream()); + // 发送请求参数 + out.print(param); + // flush输出流的缓冲 + out.flush(); + // 定义BufferedReader输入流来读取URL的响应 + in = new BufferedReader( + new InputStreamReader(conn.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + result += line; + } + } catch (Exception e) { + System.out.println("发送 POST 请求出现异常!"+e); + e.printStackTrace(); + } + //使用finally块来关闭输出流、输入流 + finally{ + try{ + if(out!=null){ + out.close(); + } + if(in!=null){ + in.close(); + } + } + catch(IOException ex){ + ex.printStackTrace(); + } + } + return result; + } + } \ No newline at end of file diff --git a/src/main/java/com/casic/accessControl/util/TimeFormat.java b/src/main/java/com/casic/accessControl/util/TimeFormat.java new file mode 100644 index 0000000..e9168d5 --- /dev/null +++ b/src/main/java/com/casic/accessControl/util/TimeFormat.java @@ -0,0 +1,148 @@ +package com.casic.accessControl.util; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +/** + * 格式化日期工具类 + * 默认模式yyyy-MM-dd HH:mm:ss + * @author Administrator + * + */ +public class TimeFormat { + + private static final String DATE_FORMAT_STRING = "yyyy-MM-dd"; + private static final String TIME_FORMAT_STRING = "HH:mm:ss"; + private static final String TIMESTAMP_FORMAT_STRING = "yyyy-MM-dd HH:mm:ss"; + + // 默认格式化格式 + private static SimpleDateFormat defaultFormat = new SimpleDateFormat(TIMESTAMP_FORMAT_STRING); + + public static void setFormatString(String pattern) { + defaultFormat.applyPattern(pattern); + } + + /** + * 默认格式化日期 + * + * @param Date date + * @return String + */ + public static String format(Date date) { + return defaultFormat.format(date); + } + + /** + * 日期格式化 + * + * @param date + * @return + */ + public static String formatDate(Date date) { + return TimeFormat.format(date, DATE_FORMAT_STRING); + } + + /** + * 时间格式化 + * + * @param date + * @return + */ + public static String formatTime(Date date) { + return TimeFormat.format(date, TIME_FORMAT_STRING); + } + + /** + * 时间戳格式化 + * + * @param date + * @return + */ + public static String formatTimestamp(Date date) { + return TimeFormat.format(date, TIMESTAMP_FORMAT_STRING); + } + + /** + * 以指定模式格式化日期 + * + * @param Date date + * @param String pattern + * @return String + */ + public static String format(Date date, String pattern) { + SimpleDateFormat formatter = new SimpleDateFormat(pattern); + return formatter.format(date); + } + + /** + * 根据起止日期生成日期序列 + * 包括start和end的日期 + * + * @param start + * @param end + * @return + */ + public static List generateDates(String start, String end) throws ParseException { + List dates = new ArrayList(); + Calendar s = Calendar.getInstance(); + Calendar e = Calendar.getInstance(); + s.setTime(TimeFormat.parse(start, DATE_FORMAT_STRING)); + s.set(Calendar.HOUR_OF_DAY, 0); + s.set(Calendar.MINUTE, 0); + s.set(Calendar.SECOND, 0); + e.setTime(TimeFormat.parse(end, DATE_FORMAT_STRING)); + e.set(Calendar.HOUR_OF_DAY, 0); + e.set(Calendar.MINUTE, 0); + e.set(Calendar.SECOND, 0); + while (s.before(e) == true) { + dates.add(TimeFormat.formatDate(s.getTime())); + s.add(Calendar.DATE, 1); + } + + dates.add(end); + return dates; + } + + + /** + * 解析日期字符串 + * + * @param String source + * @return Date + * + * @throws ParseException + */ + public static Date parse(String source) throws ParseException { + return defaultFormat.parse(source); + } + + /** + * 以指定模式解析日期 + * + * @param String source + * @param String pattern + * @return Date + * + * @throws ParseException + */ + public static Date parse(String source, String pattern) throws ParseException { + SimpleDateFormat formatter = new SimpleDateFormat(pattern); + return formatter.parse(source); + } + + + public static Date parseDateWithoutTime(String source) throws ParseException { + SimpleDateFormat formatter = new SimpleDateFormat(DATE_FORMAT_STRING); + Calendar date = Calendar.getInstance(); + date.setTime(formatter.parse(source)); + date.set(Calendar.HOUR, 0); + date.set(Calendar.HOUR, 0); + date.set(Calendar.MINUTE, 0); + return date.getTime(); + } + +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 53c91ea..cea976f 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -15,19 +15,17 @@ # ============================================================================ # db # ============================================================================ -#db.default.driverClassName=oracle.jdbc.driver.OracleDriver -#db.default.url=jdbc:oracle:thin:@192.168.0.203:1521:SZHTDB2 -#db.default.username=scott -#db.default.password=SZHTDB2 db.default.driverClassName=com.mysql.jdbc.Driver -db.default.url=jdbc:mysql://127.0.0.1:3306/ems?useUnicode=true&characterEncoding=UTF-8 -db.default.username=emsweb -db.default.password=emsweb +db.default.url=jdbc:mysql://127.0.0.1:3306/ems_tong?useUnicode=true&characterEncoding=UTF-8 +db.default.username=root +db.default.password=root +#db.default.username=emsweb +#db.default.password=emsweb #db.default.url=jdbc:mysql://119.254.110.71:3307/ems?useUnicode=true&characterEncoding=UTF-8 #db.default.username=root #db.default.password=rootems - -# ============================================================================ +# +## ============================================================================ # log4jdbc # ============================================================================ log4jdbc.enable=true diff --git a/src/main/resources/spring/applicationContext-filter.xml b/src/main/resources/spring/applicationContext-filter.xml index a08c5fc..98ac7d6 100644 --- a/src/main/resources/spring/applicationContext-filter.xml +++ b/src/main/resources/spring/applicationContext-filter.xml @@ -35,9 +35,13 @@ /user/ill-login.do /marker/exportMarker.do /marker/batchSave-na.do + /marker/batch-save-no-update.do + /marker/save-marker-photo.do /event/save-event.do /task/get-task.do + /app/get-latest-version.do /xls/* + /apk/* diff --git a/src/main/resources/spring/applicationContext-hibernate.xml b/src/main/resources/spring/applicationContext-hibernate.xml index 5bb1a7e..dc54192 100644 --- a/src/main/resources/spring/applicationContext-hibernate.xml +++ b/src/main/resources/spring/applicationContext-hibernate.xml @@ -65,6 +65,7 @@ com.casic.accessControl.task.domain.Position com.casic.accessControl.event.domain.Event com.casic.accessControl.marker.domain.OptionItem + com.casic.accessControl.app.domain.ApkVersion diff --git a/src/main/webapp/common/layout/menu_new.jsp b/src/main/webapp/common/layout/menu_new.jsp index 3cf4b4e..cbd822e 100644 --- a/src/main/webapp/common/layout/menu_new.jsp +++ b/src/main/webapp/common/layout/menu_new.jsp @@ -20,7 +20,7 @@
                                      • - + @@ -54,7 +54,7 @@
                                      • - + diff --git a/src/main/webapp/content/ems/ems-gd.jsp b/src/main/webapp/content/ems/ems-gd.jsp new file mode 100644 index 0000000..5137b49 --- /dev/null +++ b/src/main/webapp/content/ems/ems-gd.jsp @@ -0,0 +1,604 @@ +<%@page contentType="text/html;charset=UTF-8" %> + +<%@include file="/taglibs.jsp" %> + +<%pageContext.setAttribute("currentMenu", "ems");%> + + + + + + + + + + + + + 地下管线电子标识系统 + + + + + + + + + + + + + + + + + + +<%-- + +--%> + + + + + + + + + + + + + + +<%@include file="/common/layout/header.jsp" %> + +
                                        + + + + <%@include file="/common/layout/menu_new.jsp" %> + + + +
                                        + + + +
                                        + +
                                        + + +
                                        +
                                        +
                                        +
                                        + +
                                        +
                                        + +
                                        +
                                        + +
                                        +
                                        + +
                                        +
                                        + +
                                        + +
                                        + +
                                        + +
                                        + +
                                        + +
                                        +
                                        +
                                        + + + + +
                                        +
                                        +
                                        +
                                        + + + + +
                                        +
                                        +
                                        + +
                                        + +
                                        + +<%--todo list:错误使用方法 + +--%> +
                                        + +
                                        +
                                        + +
                                        + +
                                        + +
                                        + + +
                                        + +
                                        + + 移动 + 绘制区域 + 新增标识器 + 删除标识器 + 保存标识器 + 批量导入 + 导出Excel + 清空 + +
                                        + +
                                        +
                                        + +
                                        + + + +
                                        + +
                                        + +
                                        + + + + +
                                        + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/webapp/content/task/task-gd.jsp b/src/main/webapp/content/task/task-gd.jsp new file mode 100644 index 0000000..d2d5549 --- /dev/null +++ b/src/main/webapp/content/task/task-gd.jsp @@ -0,0 +1,374 @@ +<%@page contentType="text/html;charset=UTF-8" %> + +<%@include file="/taglibs.jsp" %> + +<%pageContext.setAttribute("currentMenu", "task");%> + + + + + + + + + + + + + 地下管线电子标识系统 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +<%@include file="/common/layout/header.jsp" %> + +
                                        + + + + <%@include file="/common/layout/menu_new.jsp" %> + + + +
                                        + + + +
                                        + +
                                        + +
                                        + + 移动 + 绘制区域 + 选择多点创建工单 + 清空选择 + +
                                        + +
                                        + +
                                        + + +
                                        + +
                                        + +
                                        + +
                                        历史工单
                                        + +
                                        + +
                                        + +
                                        + <%--巡检员:--%> +
                                        +
                                        + + +
                                        +
                                        + + +
                                          +
                                        +
                                          +
                                          + +
                                          + +
                                          + +
                                          + +
                                          +
                                          + +
                                          + + + +
                                          + +
                                          + +
                                          + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/webapp/images/drop/0.png b/src/main/webapp/images/drop/0.png new file mode 100644 index 0000000..f4b966b --- /dev/null +++ b/src/main/webapp/images/drop/0.png Binary files differ diff --git a/src/main/webapp/images/drop/1.png b/src/main/webapp/images/drop/1.png new file mode 100644 index 0000000..9284b64 --- /dev/null +++ b/src/main/webapp/images/drop/1.png Binary files differ diff --git a/src/main/webapp/images/drop/2.png b/src/main/webapp/images/drop/2.png new file mode 100644 index 0000000..b5425db --- /dev/null +++ b/src/main/webapp/images/drop/2.png Binary files differ diff --git a/src/main/webapp/images/drop/3.png b/src/main/webapp/images/drop/3.png new file mode 100644 index 0000000..dd09655 --- /dev/null +++ b/src/main/webapp/images/drop/3.png Binary files differ diff --git a/src/main/webapp/images/drop/4.png b/src/main/webapp/images/drop/4.png new file mode 100644 index 0000000..50cf1f7 --- /dev/null +++ b/src/main/webapp/images/drop/4.png Binary files differ diff --git a/src/main/webapp/images/drop/5.png b/src/main/webapp/images/drop/5.png new file mode 100644 index 0000000..a2029bd --- /dev/null +++ b/src/main/webapp/images/drop/5.png Binary files differ diff --git a/src/main/webapp/images/drop/6.png b/src/main/webapp/images/drop/6.png new file mode 100644 index 0000000..b53248a --- /dev/null +++ b/src/main/webapp/images/drop/6.png Binary files differ diff --git a/src/main/webapp/images/ems/point.png b/src/main/webapp/images/ems/point.png new file mode 100644 index 0000000..a814351 --- /dev/null +++ b/src/main/webapp/images/ems/point.png Binary files differ diff --git a/src/main/webapp/images/ems/rect.png b/src/main/webapp/images/ems/rect.png new file mode 100644 index 0000000..99d0c9e --- /dev/null +++ b/src/main/webapp/images/ems/rect.png Binary files differ diff --git a/src/main/webapp/images/events/red_icon.png b/src/main/webapp/images/events/red_icon.png new file mode 100644 index 0000000..78c26e4 --- /dev/null +++ b/src/main/webapp/images/events/red_icon.png Binary files differ diff --git a/src/main/webapp/images/point-task.png b/src/main/webapp/images/point-task.png new file mode 100644 index 0000000..b2e22c6 --- /dev/null +++ b/src/main/webapp/images/point-task.png Binary files differ diff --git a/src/main/webapp/images/point.png b/src/main/webapp/images/point.png new file mode 100644 index 0000000..4b887dc --- /dev/null +++ b/src/main/webapp/images/point.png Binary files differ diff --git a/src/main/webapp/images/tasks/point.png b/src/main/webapp/images/tasks/point.png new file mode 100644 index 0000000..a814351 --- /dev/null +++ b/src/main/webapp/images/tasks/point.png Binary files differ diff --git a/src/main/webapp/images/tasks/rect.png b/src/main/webapp/images/tasks/rect.png new file mode 100644 index 0000000..99d0c9e --- /dev/null +++ b/src/main/webapp/images/tasks/rect.png Binary files differ diff --git a/src/main/webapp/s/app/ems/EMSBean.js b/src/main/webapp/s/app/ems/EMSBean.js index ca6914b..a3b1dca 100644 --- a/src/main/webapp/s/app/ems/EMSBean.js +++ b/src/main/webapp/s/app/ems/EMSBean.js @@ -1,5 +1,6 @@ EMSBean = function (markerObjectType,pipeMaterial,pipeDiameter, layStyle, depth, belowType, belowDepth, belowDiameter, belowMaterial, road, - constructTime, ownerComp, markerObjectId, markerId, markerType, markerDepth, creator, createTime, memo, lat, long, recordType,id,line,area) { + constructTime, ownerComp, markerObjectId, markerId, markerType, markerDepth, creator, createTime, memo, lat, long, + recordType,id,line,area, colorType) { this.markerObjectType = markerObjectType; this.pipeMaterial = pipeMaterial; @@ -26,5 +27,5 @@ this.id = id; this.line=line; this.area =area; - + this.colorType = colorType; }; diff --git a/src/main/webapp/s/app/ems/ems-gd.js b/src/main/webapp/s/app/ems/ems-gd.js new file mode 100644 index 0000000..8875ae8 --- /dev/null +++ b/src/main/webapp/s/app/ems/ems-gd.js @@ -0,0 +1,627 @@ +/** + * Created by lenovo on 2016/4/13. + */ +//定义全局变量,缓存组织结构 + +var EmsGd = function () { + var isSaveStatus = false; + var map = null; + var mouseTool = null; + var drawOverlays = new Array(); + var readyToUploadMarkers = new Array(); + var vectorMarkers = []; + var markerData = []; + var hadRequest = false; + + var blueIcon = new AMap.Icon({ + size: new AMap.Size(25, 34), + image: $('#context').val() + '/images/drop/0.png' + }); + + var orangeIcon = new AMap.Icon({ + size: new AMap.Size(25, 34), + image: $('#context').val() + '/images/drop/1.png' + }); + + var redIcon = new AMap.Icon({ + size: new AMap.Size(25, 34), + image: $('#context').val() + '/images/drop/2.png' + }); + + var blackIcon = new AMap.Icon({ + size: new AMap.Size(25, 34), + image: $('#context').val() + '/images/drop/3.png' + }); + + var pinkIcon = new AMap.Icon({ + size: new AMap.Size(25, 34), + image: $('#context').val() + '/images/drop/4.png' + }); + + var yellowIcon = new AMap.Icon({ + size: new AMap.Size(25, 34), + image: $('#context').val() + '/images/drop/5.png' + }); + + var greenIcon = new AMap.Icon({ + size: new AMap.Size(25, 34), + image: $('#context').val() + '/images/drop/6.png' + }); + + var handleDatePickers = function () { + + if (jQuery().datepicker) { + $('.date-picker').datepicker({ + rtl: App.isRTL() + }); + } + } + + function requestMarkers() { + if (markerData.length == 0&!hadRequest) { + hadRequest = true; + $.ajax({ + type: "get", + url: $('#context').val() + "/marker/all-point-list.do", + dataType: "json", +// async:false, + cache: false, + success: function (r) { + if (r.data) {//请求成功,将获取到的数据加载到地图上 + //1.解析返回的结果,.设置全局变量data的值 + markerData = [];//清空原来的数据 + for (var t = 0; t < r.data.length; t++) { + var markerDto = r.data[t]; + var emsBean = new EMSBean(markerDto.markerObjectType, markerDto.pipeMaterial, markerDto.pipeDiameter, markerDto.layStyle, + markerDto.depth, markerDto.belowType, markerDto.belowDepth, markerDto.belowDiameter, + markerDto.belowMaterial, markerDto.road, markerDto.constructTime, markerDto.ownerComp, + markerDto.markerObjectId, markerDto.markerId, markerDto.markerType, markerDto.markerDepth, + markerDto.creator, markerDto.createTime, markerDto.memo, markerDto.latitude, markerDto.longitude, + markerDto.recordType, markerDto.id,markerDto.line,markerDto.area,markerDto.colorType); + markerData[t] = emsBean; + } + //2.增加marker + EmsGd.addMarker(markerData); + } + hadRequest = false; + map.off("complete", requestMarkers()); + }, + error: function (d) {//请求出错 + hadRequest = false; + map.off("complete", requestMarkers()); + } + }); + } else if(!hadRequest){ + EmsGd.addMarker(markerData); + } + + } + + return { + + //添加标识器 + emsAddCallBack: function () { + $('#addModal').modal('show'); + }, + + //删除标识器 + emsDelCallBack: function () { + //绘制矩形区域: + if (drawOverlays.length == 0) { + swal("请先绘制区域", "", "warning"); + return; + } + + var pointArray = new Array(); + var readyToDel = ""; + for (var i = 0; i < drawOverlays.length; i++) { + var layer = drawOverlays[i]; + try { + // 生成判断是否在多边形内的数据格式 + var path = []; + for (var k = 0; k < layer.He.path.length; k++) { + var pos = []; + pos.push(layer.He.path[k].lng, layer.He.path[k].lat); + path.push(pos); + } + for (var j = 0; j < markerData.length; j++) { + var emsBean = markerData[j]; + var point = new AMap.LngLat(emsBean.longitude, emsBean.latitude); + var isPointInRing = AMap.GeometryUtil.isPointInRing(point, path); + if (isPointInRing) { + pointArray.push(point); + readyToDel = readyToDel + emsBean.id + ","; + } + } + } catch (e) { + swal("脚本异常", e.message, "error"); + } + if (pointArray.length <= 0) { + swal("选择区域没有要删除的点", "", "warning"); + for (var i in drawOverlays) { + map.remove(drawOverlays[i]); + } + return; + } + + swal({ + title: "是否确认删除?", + text: "删除是不可恢复的", + type: "warning", + showCancelButton: true, + confirmButtonText: "确认", + cancelButtonText: "取消", + closeOnConfirm: false + }, function() { + $.ajax({ + type: "get", + url: $('#context').val() + "/marker/delMarkerByIds.do", + dataType: "json", + cache: false, + data: { + "ids": readyToDel + }, + success: function (r) { + if (r.success) {//请求成功 + swal({ + title: "删除标识器成功", + text: "", + type: "success", + confirmButtonText: "确认", + closeOnConfirm: false + }, function() { + location.href = $('#context').val() + "/content/ems/ems-gd.jsp"; + }); + } + }, + error: function (d) {//请求出错 + swal("请求异常", d.responseText, "error"); + } + }); + }); + } + }, + + //保存标识器 + emsSaveCallBack: function () { + + if (readyToUploadMarkers.length == 0) { + return; + } + if (isSaveStatus) { + swal("保存过于频繁", "请稍后操作", "warning"); + return; + } + isSaveStatus = true; + //TODO LIST:上传 + var uploadMaker = new Array(); + for (var i = 0; i < readyToUploadMarkers.length; i++) { + var emsBean = readyToUploadMarkers[i].Tag; + + if (!emsBean.depth) { + emsBean.depth = 0; + } + uploadMaker.push(emsBean); + } + $.ajax({ + type: "get", + url: $('#context').val() + "/marker/batchSave.do", + dataType: "json", + cache: false, + data: { + markers: JSON.stringify(uploadMaker) + }, + success: function (r) { + if (r.success) {//请求成功 + swal({ + title: "保存标识器成功", + text: "", + type: "success", + confirmButtonText: "确认", + closeOnConfirm: false + }, function() { + location.href = $('#context').val() + "/content/ems/ems-gd.jsp"; + }); + } + }, + error: function (d) {//请求出错 + swal("请求出错", d.responseText, "error"); + isSaveStatus = false; + } + }); + }, + + emsUploadCallBack: function () { + // map.zoomTo(map.getZoom() + 2); + //TODO LIST:弹出对应的对话框 + $('#uploadModal').modal('show'); + }, + + emsExportCallBack: function () { + //TODO LIST:选择导出的文件 +// map.zoomTo(map.getZoom() + 2); + location.href = $('#context').val() + "/marker/export.do"; + + }, + + // 清除地图上所有后添加的标记点 + clearOverlays: function () { + mouseTool.close(true)//关闭,并清除覆盖物 + + for (var i = 0; i < drawOverlays.length; i++) { + map.remove(drawOverlays[i]); + } + for (var i = 0; i < readyToUploadMarkers.length; i++) { + map.remove(readyToUploadMarkers[i]); + } + for (var i = 0; i < vectorMarkers.length; i++) { + map.remove(vectorMarkers[i]); + } + + drawOverlays = []; + readyToUploadMarkers = []; + vectorMarkers = []; + }, + + initMap: function () { + + // 创建地图实例 + map = new AMap.Map("container", { + zoom: 13, + resizeEnable: true, + zooms: [4,18],//设置地图级别范围 + }); + + //声明全局变量 + if (!markerData || markerData.length == 0) { + markerData = new Array(); + } + + // 鼠标操作工具栏 + mouseTool = new AMap.MouseTool(map); + mouseTool.on('draw',function(e){ + drawOverlays.push(e.obj); + }) + + //加载完毕请求标识点信息 + map.on("complete", requestMarkers); + }, + + // 绘制区域矩形框 + drawRect: function () { + mouseTool.rectangle(); + }, + + //取消绘制区域矩形框 + moveMap: function () { + mouseTool.close(true)//关闭,并清除覆盖物 + }, + + initForm: function () { + handleDatePickers(); + $("#selectObjectType").chosen(); + $("#resetEms").live("click", function (e) { + $("#markerObjectType").val(""); + $("#pipeDiameter").val(""); + $("#pipeMaterial").val(""); + $("#belowPipeType").val(""); + $("#belowPipeDepth").val(""); + $("#belowPipeDiameter").val(""); + $("#belowPipeMaterial").val(""); + $("#pipeDepth").val(""); + $("#layStyle").val(""); + $("#line").val(""); + $("#area").val(""); + $("#road").val(""); + $("#constructTime").val(""); + $("#ownerComp").val(""); + $("#markerObjectId").val(""); + $("#markerId").val(""); + $("#markerType").val(""); + $("#markerDepth").val(""); + $("#creator").val(""); + $("#memo").val(""); + + }); + + $('#localize').click(function (e) { + $('#addModal').modal('hide'); + + //注册地图点击事件 + function showInfo(e) { + map.off("click", showInfo); + var lng = e.lnglat.lng; + var lat = e.lnglat.lat; + //TODO LIST:获取填写表单的信息 所属区域也需要保存的 + var selectObjectType = $("#selectObjectType").val();//判断是哪个类别 + var markerObjectType = $("#markerObjectType").val(); + var pipeDiameter = $("#pipeDiameter").val(); + var pipeMaterial = $("#pipeMaterial").val(); + var belowPipeType = $("#belowPipeType").val(); + var belowPipeDepth = $("#belowPipeDepth").val(); + var belowPipeDiameter = $("#belowPipeDiameter").val(); + var belowPipeMaterial = $("#belowPipeMaterial").val(); + var pipeDepth = $("#pipeDepth").val(); + var layStyle = $("#layStyle").val(); + var road = $("#road").val(); + var constructTime = $("#constructTime").val(); + var ownerComp = $("#ownerComp").val(); + var markerObjectId = $("#markerObjectId").val(); + var markerId = $("#markerId").val(); + var markerType = $("#markerType").val(); + var markerDepth = $("#markerDepth").val(); + var creator = $("#creator").val(); + var memo = $("#memo").val(); + var line = $("#line").val(); + var area = $("#area").val(); + var emsBean = new EMSBean(markerObjectType, pipeMaterial, pipeDiameter, layStyle, pipeDepth, belowPipeType, belowPipeDepth, belowPipeDiameter, belowPipeMaterial, + road, constructTime, ownerComp, markerObjectId, markerId, markerType, markerDepth, creator, null, memo, lat, lng, selectObjectType,null,line,area); + var marker = new AMap.Marker({ + position: [lng, lat], + draggable: true + }); + + marker.on("click", attribute); + marker.Tag = emsBean; + map.add(marker); //增加点 + readyToUploadMarkers.push(marker); + function attribute() { + var emsBean2 = marker.Tag; + var searchInfoWindow = null; + var msg = ""; + var height = 0; + var titleName =""; + if (emsBean.recordType == 1) { + titleName = "
                                          管线
                                          "; + msg = msg + "管线种类:" + emsBean2.markerObjectType + "
                                          " + + "管线直径(mm):" + emsBean2.pipeDiameter + "
                                          " + + "管线材质:" + emsBean2.pipeMaterial + "
                                          " + + "埋设方式:" + emsBean2.layStyle + "
                                          " + + "管线埋深(mm):" + emsBean2.depth + "
                                          "; + height = 100; + } else if (emsBean.recordType == 2) { + titleName = "
                                          管线附属物
                                          "; + msg = msg + "附属物名称:" + emsBean2.markerObjectType + "
                                          " + + "井深(mm):" + emsBean2.depth + "
                                          "; + height = 40; + } else if (emsBean.recordType == 3) { + titleName = "
                                          管线特征管点
                                          "; + msg = msg + "管点特征:" + emsBean2.markerObjectType + "
                                          " + + "特征点埋深(mm):" + emsBean2.depth + "
                                          "; + height = 40; + } else { + titleName = "
                                          交叉穿越点
                                          "; + msg = msg + "上层管种类:" + emsBean2.markerObjectType + "
                                          " + + "上层管埋深(mm):" + emsBean2.depth + "
                                          " + + "上层管直径(mm):" + emsBean2.pipeDiameter + "
                                          " + + "上层管材料:" + emsBean2.pipeMaterial + "
                                          " + + "下层管种类:" + emsBean2.belowType + "
                                          " + + "下层管埋深(mm):" + emsBean2.belowDepth + "
                                          "+ + "下层管直径(mm):" + emsBean2.belowDiameter + "
                                          " + + "下层管材料:" + emsBean2.belowMaterial + "
                                          " ; + height = 160; + } + height = height +225; + msg = msg + "所属区域:" + emsBean2.area + "
                                          " + + "所属线路:" + emsBean2.line + "
                                          " + + "所属道路:" + emsBean2.road + "
                                          " + + "建设年代:" + emsBean2.constructTime + "
                                          " + + "权属单位:" + emsBean2.ownerComp + "
                                          " + + "标识器ID:" + emsBean2.markerId + "
                                          " + + "标识器类型:" + emsBean2.markerType + "
                                          " + + "标识器埋深(mm):" + emsBean2.markerDepth + "
                                          " + + "安装部门:" + emsBean2.creator + "
                                          " + + "最后修改时间:"+emsBean2.createTime + "
                                          " + + "备注:" + emsBean2.memo + "
                                          "; + var imgUrl = $('#context').val() + "/images/ems.jpg"; + var content = titleName + '
                                          ' + + '' + msg + + '
                                          '; + + var infowindow = new AMap.AdvancedInfoWindow({ + content: content, + width: 290, //宽度 + height: height, //高度 + panel: "panel", //检索结果面板 + enableAutoPan: true //自动平移 + }); + + infowindow.open(map, [e.lnglat.lng, e.lnglat.lat]); + } + + } + map.on("click", showInfo); + }); + + $("#searchMarker").click(function (e) { + var Marker = {}; + if (vectorMarkers.length != 0) { + for (var i = 0; i < vectorMarkers.length; i++) { + map.remove(vectorMarkers[i]); + } + } + vectorMarkers = []; + Marker.road = $("#roadCondition").val(); + Marker.memo = $("#memoCondition").val(); + Marker.area = $("#select_area").val(); + Marker.line = $("#select_line").val(); + Marker.ownerComp = $("#company").val(); + Marker.creator = $("#department").val(); + Marker.sDate = $("#txt_begin_day").val(); + Marker.eDate = $("#txt_end_day").val(); + //请求后台的id列表,然后遍历marker列表,修改marker的颜色 + $.ajax({ + type: "POST", + url: $('#context').val() + "/marker/getMarkerListByCondition.do", + data: {"strMarkerDto": JSON.stringify(Marker)}, + dataType: "json", + success: function (r) { + if (r.data) { + var pointArray = new Array(); + if (r.data.length > 1000) { + swal("有超过一千个点符合筛选条件", "会造成浏览器卡顿,请重新选择", "warning"); + } else { + if (r.data.length == 0) { + swal("没有搜到符合条件的标识器", "请重新选择", "warning"); + return; + } + for (var a in r.data) {//遍历列表,添加marker + var vectorMarker = new AMap.Marker({ + position: [r.data[a].longitude,r.data[a].latitude], + size: new AMap.Size(30, 30), + icon: $('#context').val() + '/images/point.png' + }); + vectorMarkers.push(vectorMarker); + map.add(vectorMarker); + } + map.setFitView(vectorMarkers); + } + + } + }, + error: function (request) { + //提示错误信息 + swal("脚本异常", r.message, "error"); + } + }); + }); + + //控制不同种类对象的标签信息显示 + $("#selectObjectType").die().live("change", function (e) { + var type = $("#selectObjectType").val(); + OptionItemProcess.initPipeTypeList(type); + if (type == 1) {//管线 + $("#pipeTypeLabel").text("管线种类"); + $(".up-pipe").show(); + $("#pipeDiameterLabel").text("管线直径"); + $("#pipeMaterialLabel").text("管线材质"); + $(".below").addClass("hidden"); + $("#pipeDepthLabel").text("管线埋深"); + $(".pipeOnly").show(); + } else if (type == 2) {//管线附属物 + $("#pipeTypeLabel").text("附属物名称"); + $(".up-pipe").hide(); + $(".below").addClass("hidden"); + $("#pipeDepthLabel").text("井深"); + $(".pipeOnly").hide(); + } else if (type == 3) {//管线特征点 + $("#pipeTypeLabel").text("管点特征"); + $(".up-pipe").hide(); + $(".below").addClass("hidden"); + $("#pipeDepthLabel").text("特征点埋深"); + $(".pipeOnly").hide(); + } else {//交叉穿越点 + $("#pipeTypeLabel").text("上层管种类"); + $(".up-pipe").show(); + $("#pipeDiameterLabel").text("上层管直径"); + $("#pipeMaterialLabel").text("上层管材料"); + $(".below").removeClass("hidden"); + $("#pipeDepthLabel").text("上层管埋深"); + $(".pipeOnly").hide(); + } + }); + + OptionItemProcess.initPipeTypeList($("#selectObjectType").val()); + OptionItemProcess.initBelowPipeTypeList(); + OptionItemProcess.initAreaList(); + OptionItemProcess.initLayStyleList(); + OptionItemProcess.initMaterialList(); + }, + + initSelect: function () { + $("#selectObjectType").chosen(); + }, + + addMarker: function (data) { + for (var i = 0; i < data.length; i++) { + var icon = blueIcon; + var color = data[i].colorType; + if (color == "1") { + icon = orangeIcon; + } else if (color == "2") { + icon = redIcon; + } else if (color == "3") { + icon = blackIcon; + } else if (color == "4") { + icon = pinkIcon; + } else if (color == "5") { + icon = yellowIcon; + } else if (color == "6") { + icon = greenIcon; + } + + var marker = new AMap.Marker({ + position: [data[i].longitude, data[i].latitude], + icon: icon + }); + marker.Tag = data[i]; + + marker.on("click", function (e) { + + var emsBean = e.target.Tag; + var msg = ""; + var height = 0; + var titleName =""; + if (emsBean.recordType == 1) { + titleName = "
                                          管线
                                          "; + msg = msg + "管线种类:" + emsBean.markerObjectType + "
                                          " + + "管线直径(mm):" + emsBean.pipeDiameter + "
                                          " + + "管线材质:" + emsBean.pipeMaterial + "
                                          " + + "埋设方式:" + emsBean.layStyle + "
                                          " + + "管线埋深(mm):" + emsBean.depth + "
                                          "; + height = 100; + } else if (emsBean.recordType == 2) { + titleName = "
                                          管线附属物
                                          "; + msg = msg + "附属物名称:" + emsBean.markerObjectType + "
                                          " + + "井深(mm):" + emsBean.depth + "
                                          "; + height = 40; + } else if (emsBean.recordType == 3) { + titleName = "
                                          管线特征管点
                                          "; + msg = msg + "管点特征:" + emsBean.markerObjectType + "
                                          " + + "特征点埋深(mm):" + emsBean.depth + "
                                          "; + height = 40; + } else { + titleName = "
                                          交叉穿越点
                                          "; + msg = msg + "上层管种类:" + emsBean.markerObjectType + "
                                          " + + "上层管埋深(mm):" + emsBean.depth + "
                                          " + + "上层管直径(mm):" + emsBean.pipeDiameter + "
                                          " + + "上层管材料:" + emsBean.pipeMaterial + "
                                          " + + "下层管种类:" + emsBean.belowType + "
                                          " + + "下层管埋深(mm):" + emsBean.belowDepth + "
                                          "+ + "下层管直径(mm):" + emsBean.belowDiameter + "
                                          " + + "下层管材料:" + emsBean.belowMaterial + "
                                          " ; + height = 160; + } + height = height +225; + msg = msg + "所属区域:" + emsBean.area + "
                                          " + + "所属线路:" + emsBean.line + "
                                          " + + "所属道路:" + emsBean.road + "
                                          " + + "建设年代:" + emsBean.constructTime + "
                                          " + + "权属单位:" + emsBean.ownerComp + "
                                          " + + "标识器ID:" + emsBean.markerId + "
                                          " + + "标识器类型:" + emsBean.markerType + "
                                          " + + "标识器埋深(mm):" + emsBean.markerDepth + "
                                          " + + "安装部门:" + emsBean.creator + "
                                          " + + "最后修改时间:"+emsBean.createTime + "
                                          " + + "备注:" + emsBean.memo + "
                                          "; + var imgUrl = $('#context').val() + "/images/ems.jpg"; + var content = titleName + '
                                          ' + + '' + msg + + '
                                          '; + + var infowindow = new AMap.AdvancedInfoWindow({ + content: content, + width: 290, //宽度 + height: height, //高度 + panel: "panel", //检索结果面板 + enableAutoPan: true //自动平移 + }); + + infowindow.open(map, [e.lnglat.lng, e.lnglat.lat]); + }); + + map.add(marker); + } + } + }; +}(); \ No newline at end of file diff --git a/src/main/webapp/s/app/task/task-gd.js b/src/main/webapp/s/app/task/task-gd.js new file mode 100644 index 0000000..abf4da0 --- /dev/null +++ b/src/main/webapp/s/app/task/task-gd.js @@ -0,0 +1,689 @@ +/** + * Created by lenovo on 2016/4/13. + */ +//定义全局变量,缓存组织结构 + +var TaskGd = function () { + + var map = null; + var mouseTool = null; + var taskMarkers = ""; + var drawOverlays = new Array(); + var drawTaskOverlays = new Array(); + var drawEventOverlays = []; + var taskLists; + var taskDetailLists = new Array(); + var eventBeanList = []; + var viewPoints = []; + var markerData = []; + var hadRequest = false; + + var blueIcon = new AMap.Icon({ + size: new AMap.Size(25, 34), + image: $('#context').val() + '/images/drop/0.png' + }); + + var orangeIcon = new AMap.Icon({ + size: new AMap.Size(25, 34), + image: $('#context').val() + '/images/drop/1.png' + }); + + var redIcon = new AMap.Icon({ + size: new AMap.Size(25, 34), + image: $('#context').val() + '/images/drop/2.png' + }); + + var blackIcon = new AMap.Icon({ + size: new AMap.Size(25, 34), + image: $('#context').val() + '/images/drop/3.png' + }); + + var pinkIcon = new AMap.Icon({ + size: new AMap.Size(25, 34), + image: $('#context').val() + '/images/drop/4.png' + }); + + var yellowIcon = new AMap.Icon({ + size: new AMap.Size(25, 34), + image: $('#context').val() + '/images/drop/5.png' + }); + + var greenIcon = new AMap.Icon({ + size: new AMap.Size(25, 34), + image: $('#context').val() + '/images/drop/6.png' + }); + + // 历史工单列表属性 + var options = { + valueNames: [ 'id', 'patrolerName', 'status', 'deployDate', 'beginDate', 'endDate', 'description', {attr: 'src', name: 'image'} ], + item: '
                                        • ' + + '

                                          ' + + '

                                          ' + + '

                                          ' + + '

                                          ' + + '

                                          ' + + '

                                          ' + + '' + + '
                                          ' + + '
                                          ' + + '
                                        • ', + page: 3, + plugins: [ ListPagination({}) ] + }; + + // 清除所有绘制的区域图层 + function clearAll() { + for (var i = 0; i < drawOverlays.length; i++) { + map.remove(drawOverlays[i]); + } + drawOverlays.length = 0; + } + + // 清除工单任务绘制的标识器点 + function clearAllTaskPoint() { + for (var i = 0; i < drawTaskOverlays.length; i++) { + map.remove(drawTaskOverlays[i]); + } + drawTaskOverlays.length = 0; + taskDetailLists.length = 0; + } + + // 清除工单任务绘制的事件点 + function clearAllEventPoint() { + for (var i = 0; i < drawEventOverlays.length; i++) { + map.remove(drawEventOverlays[i]); + } +// drawEventOverlays.length = 0; + drawEventOverlays = []; + eventBeanList = []; + } + + // 查询巡检任务列表 + function getTaskInfo(patroler) { + taskLists.clear(); + $.ajax({ + type: "get", + url: $('#context').val() + "/task/get-task.do", + dataType: "json", + cache: false, + data: { + + }, + success: function (r) { + if (r.success) {//请求成功 + for (var data in r.data) { + var icon = $('#context').val() + "/images/accidents/worker.png"; + var id = r.data[data].id; + var patrolerName = r.data[data].patrolerName; + if (patroler && patrolerName != patroler) { + continue; + } + var description = r.data[data].description; + var deployDate = r.data[data].deployDate; + var beginDate = r.data[data].beginDate; + var endDate = r.data[data].endDate; + var status = r.data[data].status; + var creatorName = r.data[data].creatorName; + var task = new TaskBean(id, icon, patrolerName, description, deployDate, beginDate, endDate, status, creatorName); + + task.patrolerName = "巡检员:" + task.patrolerName; + task.description = "任务描述:" + task.description; + task.deployDate = "下发时间:" + task.deployDate; + task.beginDate = task.beginDate == null ? "开始时间:" : "开始时间:" + task.beginDate; + task.endDate = task.endDate == null ? "完成时间:" : "完成时间:" + task.endDate; + task.status = "任务状态:" + task.status; + taskLists.add(task); + } + } else { + swal("后台数据请求异常", r.message, "error"); + } + }, + error: function (d) {//请求出错 + swal("后台数据请求出错", d.responseText, "error"); + } + }); + } + + // 展示事件信息 + function showEventInfo(e) { + var p = e.target; + var imgName = p.Tag.imageName; + var images = imgName.split(",");//图片路径数组 +// alert(images[0]); + var msg2 = "事件描述:" + p.Tag.description + "
                                          " + + "上传时间:" + p.Tag.createTime + "
                                          "; + $("#eventImg").children().remove();//avatar1.jpg + var imageDivs="
                                          "; +// var imageDivs =""; + var width = 100/images.length;//动态展示 + $("#viewHelper").children().remove(); + for(var i =0;i" + + "
                                          " + + "
                                          " + +// "
                                          "+ +// ""+ +// ""+ +// " "+ +// ""+ +// "
                                          " + + "
                                          " + +// imageDivs +=""; + } + imageDivs+="" + $(".fancybox-close").die().live("click",function(){ + $('#eventModal').modal('show').css({width: "300px"}); + }); + $(".zoom-icon").die().live("click",function(){ + $('#eventModal').modal('hide'); + }); +// alert(eval(imageDivs)) + $("#eventImg").append(imageDivs) + $("#eventDescription").html(msg2); + $('#eventModal').modal('show').css({width: "300px"}); +// alert("showEventInfo:"+images); +// eventImgPage(images.length, 1, images); + + } + + // 获取标识器点 + function requestMarkers() { + if (markerData.length == 0&&!hadRequest) { + hadRequest = true; + $.ajax({ + type: "get", + url: $('#context').val() + "/marker/all-point-list.do", + dataType: "json", + cache: false, + success: function (r) { + if (r.data) {//请求成功,将获取到的数据加载到地图上 + //1.解析返回的结果,.设置全局变量data的值 + markerData = [];//清空原来的数据 + for (var t = 0; t < r.data.length; t++) { + var markerDto = r.data[t]; + var emsBean = new EMSBean(markerDto.markerObjectType, markerDto.pipeMaterial, markerDto.pipeDiameter, markerDto.layStyle, + markerDto.depth, markerDto.belowType, markerDto.belowDepth, markerDto.belowDiameter, + markerDto.belowMaterial, markerDto.road, markerDto.constructTime, markerDto.ownerComp, + markerDto.markerObjectId, markerDto.markerId, markerDto.markerType, markerDto.markerDepth, + markerDto.creator, markerDto.createTime, markerDto.memo, markerDto.latitude, markerDto.longitude, + markerDto.recordType, markerDto.id,markerDto.line,markerDto.area, markerDto.colorType); + markerData[t] = emsBean; + } + //2.增加marker + TaskGd.addMarker(markerData); + } + hadRequest = false; + map.off("complete", requestMarkers()); + + }, + error: function (d) {//请求出错 + hadRequest = false; + map.off("complete", requestMarkers()); + } + }); + } else if(!hadRequest){ + TaskGd.addMarker(markerData); + } + + } + return { + + //添加工单 + selectMarkerCallBack: function () { + //绘制矩形区域: + taskMarkers = ""; + if (drawOverlays.length == 0) { + swal("请先绘制区域", "", "warning"); + return; + } + for (var i = 0; i < drawOverlays.length; i++) { + var layer = drawOverlays[i]; + try { + // 生成判断是否在多边形内的数据格式 + var path = []; + for (var k = 0; k < layer.He.path.length; k++) { + var pos = []; + pos.push(layer.He.path[k].lng, layer.He.path[k].lat); + path.push(pos); + } + + for (var j = 0; j < markerData.length; j++) { + var emsBean = markerData[j]; + var point = new AMap.LngLat(emsBean.longitude, emsBean.latitude); + var isPointInRing = AMap.GeometryUtil.isPointInRing(point, path); + if (isPointInRing) { + taskMarkers = taskMarkers + emsBean.id + ","; + } + } + } catch (e) { + swal("脚本异常", e.message, "error"); + } + } + if (taskMarkers == "") { + swal("请选择标识器点!", "", "error"); + return; + } + + $('#addTaskModal2').modal('show'); + clearAll(); + }, + + //清除 + clearCallBack: function () { + taskMarkers = ""; + clearAll(); + }, + + //上传工单 + uploadTaskCallBack: function (patrolerId, description) { + $.ajax({ + type: "get", + url: $('#context').val() + "/task/task-Save.do", + dataType: "json", + cache: false, + data: { + markers: taskMarkers, + patrolerId: patrolerId, + description: description + }, + success: function (r) { + if (r.success) {//请求成功 + swal({ + title: "请求成功", + text: r.message, + type: "success", + confirmButtonText: "确认" + }, function() { + TaskGd.updateList(); + }); + } else { + swal("请求失败", r.message, "error"); + } + }, + error: function (d) {//请求出错 + swal("请求失败", d.message, "error"); + } + }); + }, + + // 初始化地图 + initMap: function () { + + map = new AMap.Map("container", { + zoom: 13, + resizeEnable: true, + zooms: [4,18],//设置地图级别范围 + }); + + //声明全局变量 + if (!markerData || markerData.length == 0) { + markerData = new Array(); + } + + // 鼠标操作工具栏 + mouseTool = new AMap.MouseTool(map); + mouseTool.on('draw',function(e){ + drawOverlays.push(e.obj); + }); + + //加载完毕请求标识点信息 + map.on("complete", requestMarkers); + }, + + initList: function () { + taskLists = new List('worksheets', options); + TaskGd.updateList(); + //$('.sort').click(); + $('#btnSort').trigger("click"); + $('#btnSort').trigger("click"); + + $('#btnSort').css("padding", 0); + $('#btnSort').css("padding-left", 10); + $('#btnSort').css("padding-right", 15); + $('#btnSort').css("margin-bottom", 10); + + TaskGd.bindClickEvent(); + + $('#selectPatroler3').live('change', function (e) {//下拉列表更改的时候查询数据,更新列表,待优化为查询条件在后台利用 + TaskGd.updateList($("#selectPatroler3").val()); + }); + }, + + // 绑定任务列表单击事件 + bindClickEvent: function () { + $('#worksheets ul li').live('click', function (e) { + viewPoints = []; + if (null == this.getElementsByClassName("id")[0]) { + return; + } + clearAllTaskPoint(); + clearAllEventPoint(); + var taskId = this.getElementsByClassName("id")[0].innerHTML; + var i = 0; + //请求任务 + $.ajax({ + type: "get", + url: $('#context').val() + "/task/get-task-markers.do", + dataType: "json", + async:false, + cache: false, + data: { + taskId: taskId + }, + success: function (r) { + if (r.success) {//请求成功 + for (var data in r.data) { + var id = r.data[data].id; + var markerName = r.data[data].markerIdReal; + var latitude = r.data[data].latitude; + var longitude = r.data[data].longitude; + var finishTime = r.data[data].finishTime == null ? "" : r.data[data].finishTime; + var description = r.data[data].description == null ? "" : r.data[data].description; + var status = r.data[data].isChecked; + var icon = ""; + var isChecked = ""; + if (status == 0) { + icon = $('#context').val() + "/images/point-task.png"; + isChecked = "未巡检"; + } + else { + icon = $('#context').val() + "/images/point.png"; + isChecked = "已巡检"; + } + + var taskDetailBean = new TaskDetailBean(id, icon, markerName, latitude, longitude, isChecked, finishTime, description); + taskDetailLists.push(taskDetailBean); + + } + TaskGd.addTaskDetailMarker(taskDetailLists); + } + else { + alert(r.message); + } + }, + error: function (d) {//请求出错 + alert(d.message); + } + }); + + //请求该任务上报的事件 + $.ajax({ + type: "get", + url: $('#context').val() + "/event/get-event-list.do", + dataType: "json", + cache: false, + async:false, + data: { + taskId: taskId + }, + success: function (r) { + if (r.success) {//请求成功 + for (var data in r.data) { + var id = r.data[data].id; + var imageName = r.data[data].imageName; + var latitude = r.data[data].latitude; + var longitude = r.data[data].longitude; + var createTime = r.data[data].createTime == null ? "" : r.data[data].createTime; + var description = r.data[data].description == null ? "" : r.data[data].description; + var status = r.data[data].status; + var eventBean = new EventBean(id, imageName, latitude, longitude, description, status, createTime); + + eventBeanList.push(eventBean); + + } + TaskGd.addEventMarker(eventBeanList); + } + else { + alert(r.message); + } + }, + error: function (d) {//请求出错 + alert(d.message); + } + }); + + map.setFitView(viewPoints); + + }); + + }, + + /* + * 增加报警信息到列表 + * */ + updateList: function (patroler) { + getTaskInfo(patroler); + }, + + // 初始化表单操作 + initForm: function () { + $("#saveTask2").click(function (e) { + //alert(taskMarkers); + var patrolerId = $("#selectPatroler2").val(); + var description = $("#description2").val(); + TaskGd.uploadTaskCallBack(patrolerId, description); + $('#addTaskModal2').modal('hide'); + $("#description2").val(""); + }); + }, + + //获取巡检员列表 + initPatrolerArray: function () { + + $.ajax({ + type: "POST", + url: $('#context').val() + "/user/get-patroler.do", + data: {}, + dataType: "json", + success: function (r) { + //获取面的列表,将下拉列表初始化 + if (r.data) { + for (var user in r.data) { + //alert(r.data[user].id+":"+r.data[user].userName); + $("#selectPatroler").append(" "); + $("#selectPatroler2").append(" "); + $("#selectPatroler3").append(" "); + } + $("#selectPatroler").chosen(); + $("#selectPatroler2").chosen(); + $("#selectPatroler3").chosen(); + } + }, + error: function (d) { + //提示错误信息 + swal("请求巡检员列表出错", d.responseText, "error"); + } + }); + + }, + + // 绘制区域矩形框 + drawRect: function () { + mouseTool.rectangle(); + }, + + //取消绘制区域矩形框 + moveMap: function () { + mouseTool.close(true)//关闭,并清除覆盖物 + }, + + //初始化下拉列表框 + initSelect: function () { + TaskGd.initPatrolerArray(); + }, + + // 显示标识器点 + addMarker: function (data) { + for (var i = 0; i < data.length; i++) { + var icon = blueIcon; + var color = data[i].colorType; + if (color == "1") { + icon = orangeIcon; + } else if (color == "2") { + icon = redIcon; + } else if (color == "3") { + icon = blackIcon; + } else if (color == "4") { + icon = pinkIcon; + } else if (color == "5") { + icon = yellowIcon; + } else if (color == "6") { + icon = greenIcon; + } + + var marker = new AMap.Marker({ + position: [data[i].longitude, data[i].latitude], + icon: icon + }); + marker.Tag = data[i]; + + marker.on("click", function (e) { + + var emsBean = e.target.Tag; + var msg = ""; + var height = 0; + var titleName =""; + if (emsBean.recordType == 1) { + titleName = "
                                          管线
                                          "; + msg = msg + "管线种类:" + emsBean.markerObjectType + "
                                          " + + "管线直径(mm):" + emsBean.pipeDiameter + "
                                          " + + "管线材质:" + emsBean.pipeMaterial + "
                                          " + + "埋设方式:" + emsBean.layStyle + "
                                          " + + "管线埋深(mm):" + emsBean.depth + "
                                          "; + height = 100; + } else if (emsBean.recordType == 2) { + titleName = "
                                          管线附属物
                                          "; + msg = msg + "附属物名称:" + emsBean.markerObjectType + "
                                          " + + "井深(mm):" + emsBean.depth + "
                                          "; + height = 40; + } else if (emsBean.recordType == 3) { + titleName = "
                                          管线特征管点
                                          "; + msg = msg + "管点特征:" + emsBean.markerObjectType + "
                                          " + + "特征点埋深(mm):" + emsBean.depth + "
                                          "; + height = 40; + } else { + titleName = "
                                          交叉穿越点
                                          "; + msg = msg + "上层管种类:" + emsBean.markerObjectType + "
                                          " + + "上层管埋深(mm):" + emsBean.depth + "
                                          " + + "上层管直径(mm):" + emsBean.pipeDiameter + "
                                          " + + "上层管材料:" + emsBean.pipeMaterial + "
                                          " + + "下层管种类:" + emsBean.belowType + "
                                          " + + "下层管埋深(mm):" + emsBean.belowDepth + "
                                          "+ + "下层管直径(mm):" + emsBean.belowDiameter + "
                                          " + + "下层管材料:" + emsBean.belowMaterial + "
                                          " ; + height = 160; + } + height = height +225; + msg = msg + "所属区域:" + emsBean.area + "
                                          " + + "所属线路:" + emsBean.line + "
                                          " + + "所属道路:" + emsBean.road + "
                                          " + + "建设年代:" + emsBean.constructTime + "
                                          " + + "权属单位:" + emsBean.ownerComp + "
                                          " + + "标识器ID:" + emsBean.markerId + "
                                          " + + "标识器类型:" + emsBean.markerType + "
                                          " + + "标识器埋深(mm):" + emsBean.markerDepth + "
                                          " + + "安装部门:" + emsBean.creator + "
                                          " + + "最后修改时间:"+emsBean.createTime + "
                                          " + + "备注:" + emsBean.memo + "
                                          "; + var imgUrl = $('#context').val() + "/images/ems.jpg"; + var content = titleName + '
                                          ' + + '' + msg + + '
                                          '; + + var infowindow = new AMap.AdvancedInfoWindow({ + content: content, + width: 290, //宽度 + height: height, //高度 + panel: "panel", //检索结果面板 + enableAutoPan: true //自动平移 + }); + + infowindow.open(map, [e.lnglat.lng, e.lnglat.lat]); + }); + + map.add(marker); + } + }, + + //增加事件图片的marker + addEventMarker: function () { + console.log(eventBeanList); + for (var i = 0; i < eventBeanList.length; i++) { + var eventMarker = new AMap.Marker({ + position: [eventBeanList[i].longitude, eventBeanList[i].latitude], + size: new AMap.Size(30, 30), + icon: new AMap.Icon({ + size: new AMap.Size(38, 38), + image: $('#context').val() + "/images/events/red_icon.png" + }) + }); + + var msg = "事件描述:" + eventBeanList[i].description + "\r\n" + + "上传时间:" + eventBeanList[i].createTime + "\r\n"; + eventMarker.setTitle(msg); + eventMarker.Tag = eventBeanList[i]; + viewPoints.push(eventMarker); + eventMarker.on("click", showEventInfo); + map.add(eventMarker); // 将标注添加到地图中 + drawEventOverlays.push(eventMarker); + } + }, + + // 点击任务列表绘制任务对应的标识器点 + addTaskDetailMarker: function (data) { + for (var i = 0; i < data.length; i++) { + var msg = "标识器名称:" + data[i].markerName + "\r\n" + + "巡检状态:" + data[i].isChecked + "\r\n" + + "巡检时间:" + data[i].finishTime + "\r\n" + + "描述:" + data[i].description + "\r\n"; + + var marker = new AMap.Marker({ + position: [data[i].longitude, data[i].latitude], + size: new AMap.Size(30, 30), + icon: data[i].icon + }); + + marker.setTitle(msg); + + viewPoints.push(marker); + drawTaskOverlays.push(marker); + map.add(marker); // 将标注添加到地图中 + } + } + }; +}(); + +TaskBean = function (id, icon, patrolerName, description, deployDate, beginDate, endDate, status, creatorName) { + this.id = id; + this.image = icon; + this.patrolerName = patrolerName; + this.description = description; + this.deployDate = deployDate; + this.beginDate = beginDate; + this.endDate = endDate; + this.status = status; + this.creatorName = creatorName; +}; + +TaskDetailBean = function (id, icon, markerName, latitude, longitude, isChecked, finishTime, description) { + this.id = id; + this.icon = icon; + this.markerName = markerName; + this.latitude = latitude; + this.longitude = longitude; + this.isChecked = isChecked; + this.finishTime = finishTime; + this.description = description; +}; + +EventBean = function (id, imageName, latitude, longitude, description, status, createTime) { + this.id = id; + this.imageName = imageName; + this.latitude = latitude; + this.longitude = longitude; + this.description = description; + this.status = status; + this.createTime = createTime; +} \ No newline at end of file diff --git a/src/main/webapp/s/media/css/sweetalert.css b/src/main/webapp/s/media/css/sweetalert.css new file mode 100644 index 0000000..f2af7e3 --- /dev/null +++ b/src/main/webapp/s/media/css/sweetalert.css @@ -0,0 +1,935 @@ +body.stop-scrolling { + height: 100%; + overflow: hidden; } + +.sweet-overlay { + background-color: black; + /* IE8 */ + -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=40)"; + /* IE8 */ + background-color: rgba(0, 0, 0, 0.4); + position: fixed; + left: 0; + right: 0; + top: 0; + bottom: 0; + display: none; + z-index: 10000; } + +.sweet-alert { + background-color: white; + font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif; + width: 478px; + padding: 17px; + border-radius: 5px; + text-align: center; + position: fixed; + left: 50%; + top: 50%; + margin-left: -256px; + margin-top: -200px; + overflow: hidden; + display: none; + z-index: 99999; } + @media all and (max-width: 540px) { + .sweet-alert { + width: auto; + margin-left: 0; + margin-right: 0; + left: 15px; + right: 15px; } } + .sweet-alert h2 { + color: #575757; + font-size: 30px; + text-align: center; + font-weight: 600; + text-transform: none; + position: relative; + margin: 25px 0; + padding: 0; + line-height: 40px; + display: block; } + .sweet-alert p { + color: #797979; + font-size: 16px; + text-align: center; + font-weight: 300; + position: relative; + text-align: inherit; + float: none; + margin: 0; + padding: 0; + line-height: normal; } + .sweet-alert fieldset { + border: none; + position: relative; } + .sweet-alert .sa-error-container { + background-color: #f1f1f1; + margin-left: -17px; + margin-right: -17px; + overflow: hidden; + padding: 0 10px; + max-height: 0; + webkit-transition: padding 0.15s, max-height 0.15s; + transition: padding 0.15s, max-height 0.15s; } + .sweet-alert .sa-error-container.show { + padding: 10px 0; + max-height: 100px; + webkit-transition: padding 0.2s, max-height 0.2s; + transition: padding 0.25s, max-height 0.25s; } + .sweet-alert .sa-error-container .icon { + display: inline-block; + width: 24px; + height: 24px; + border-radius: 50%; + background-color: #ea7d7d; + color: white; + line-height: 24px; + text-align: center; + margin-right: 3px; } + .sweet-alert .sa-error-container p { + display: inline-block; } + .sweet-alert .sa-input-error { + position: absolute; + top: 29px; + right: 26px; + width: 20px; + height: 20px; + opacity: 0; + -webkit-transform: scale(0.5); + transform: scale(0.5); + -webkit-transform-origin: 50% 50%; + transform-origin: 50% 50%; + -webkit-transition: all 0.1s; + transition: all 0.1s; } + .sweet-alert .sa-input-error::before, .sweet-alert .sa-input-error::after { + content: ""; + width: 20px; + height: 6px; + background-color: #f06e57; + border-radius: 3px; + position: absolute; + top: 50%; + margin-top: -4px; + left: 50%; + margin-left: -9px; } + .sweet-alert .sa-input-error::before { + -webkit-transform: rotate(-45deg); + transform: rotate(-45deg); } + .sweet-alert .sa-input-error::after { + -webkit-transform: rotate(45deg); + transform: rotate(45deg); } + .sweet-alert .sa-input-error.show { + opacity: 1; + -webkit-transform: scale(1); + transform: scale(1); } + .sweet-alert input { + width: 100%; + box-sizing: border-box; + border-radius: 3px; + border: 1px solid #d7d7d7; + height: 43px; + margin-top: 10px; + margin-bottom: 17px; + font-size: 18px; + box-shadow: inset 0px 1px 1px rgba(0, 0, 0, 0.06); + padding: 0 12px; + display: none; + -webkit-transition: all 0.3s; + transition: all 0.3s; } + .sweet-alert input:focus { + outline: none; + box-shadow: 0px 0px 3px #c4e6f5; + border: 1px solid #b4dbed; } + .sweet-alert input:focus::-moz-placeholder { + transition: opacity 0.3s 0.03s ease; + opacity: 0.5; } + .sweet-alert input:focus:-ms-input-placeholder { + transition: opacity 0.3s 0.03s ease; + opacity: 0.5; } + .sweet-alert input:focus::-webkit-input-placeholder { + transition: opacity 0.3s 0.03s ease; + opacity: 0.5; } + .sweet-alert input::-moz-placeholder { + color: #bdbdbd; } + .sweet-alert input::-ms-clear { + display: none; } + .sweet-alert input:-ms-input-placeholder { + color: #bdbdbd; } + .sweet-alert input::-webkit-input-placeholder { + color: #bdbdbd; } + .sweet-alert.show-input input { + display: block; } + .sweet-alert .sa-confirm-button-container { + display: inline-block; + position: relative; } + .sweet-alert .la-ball-fall { + position: absolute; + left: 50%; + top: 50%; + margin-left: -27px; + margin-top: 4px; + opacity: 0; + visibility: hidden; } + .sweet-alert button { + background-color: #8CD4F5; + color: white; + border: none; + box-shadow: none; + font-size: 17px; + font-weight: 500; + -webkit-border-radius: 4px; + border-radius: 5px; + padding: 10px 32px; + margin: 26px 5px 0 5px; + cursor: pointer; } + .sweet-alert button:focus { + outline: none; + box-shadow: 0 0 2px rgba(128, 179, 235, 0.5), inset 0 0 0 1px rgba(0, 0, 0, 0.05); } + .sweet-alert button:hover { + background-color: #7ecff4; } + .sweet-alert button:active { + background-color: #5dc2f1; } + .sweet-alert button.cancel { + background-color: #C1C1C1; } + .sweet-alert button.cancel:hover { + background-color: #b9b9b9; } + .sweet-alert button.cancel:active { + background-color: #a8a8a8; } + .sweet-alert button.cancel:focus { + box-shadow: rgba(197, 205, 211, 0.8) 0px 0px 2px, rgba(0, 0, 0, 0.0470588) 0px 0px 0px 1px inset !important; } + .sweet-alert button[disabled] { + opacity: .6; + cursor: default; } + .sweet-alert button.confirm[disabled] { + color: transparent; } + .sweet-alert button.confirm[disabled] ~ .la-ball-fall { + opacity: 1; + visibility: visible; + transition-delay: 0s; } + .sweet-alert button::-moz-focus-inner { + border: 0; } + .sweet-alert[data-has-cancel-button=false] button { + box-shadow: none !important; } + .sweet-alert[data-has-confirm-button=false][data-has-cancel-button=false] { + padding-bottom: 40px; } + .sweet-alert .sa-icon { + width: 80px; + height: 80px; + border: 4px solid gray; + -webkit-border-radius: 40px; + border-radius: 40px; + border-radius: 50%; + margin: 20px auto; + padding: 0; + position: relative; + box-sizing: content-box; } + .sweet-alert .sa-icon.sa-error { + border-color: #F27474; } + .sweet-alert .sa-icon.sa-error .sa-x-mark { + position: relative; + display: block; } + .sweet-alert .sa-icon.sa-error .sa-line { + position: absolute; + height: 5px; + width: 47px; + background-color: #F27474; + display: block; + top: 37px; + border-radius: 2px; } + .sweet-alert .sa-icon.sa-error .sa-line.sa-left { + -webkit-transform: rotate(45deg); + transform: rotate(45deg); + left: 17px; } + .sweet-alert .sa-icon.sa-error .sa-line.sa-right { + -webkit-transform: rotate(-45deg); + transform: rotate(-45deg); + right: 16px; } + .sweet-alert .sa-icon.sa-warning { + border-color: #F8BB86; } + .sweet-alert .sa-icon.sa-warning .sa-body { + position: absolute; + width: 5px; + height: 47px; + left: 50%; + top: 10px; + -webkit-border-radius: 2px; + border-radius: 2px; + margin-left: -2px; + background-color: #F8BB86; } + .sweet-alert .sa-icon.sa-warning .sa-dot { + position: absolute; + width: 7px; + height: 7px; + -webkit-border-radius: 50%; + border-radius: 50%; + margin-left: -3px; + left: 50%; + bottom: 10px; + background-color: #F8BB86; } + .sweet-alert .sa-icon.sa-info { + border-color: #C9DAE1; } + .sweet-alert .sa-icon.sa-info::before { + content: ""; + position: absolute; + width: 5px; + height: 29px; + left: 50%; + bottom: 17px; + border-radius: 2px; + margin-left: -2px; + background-color: #C9DAE1; } + .sweet-alert .sa-icon.sa-info::after { + content: ""; + position: absolute; + width: 7px; + height: 7px; + border-radius: 50%; + margin-left: -3px; + top: 19px; + background-color: #C9DAE1; + left: 50%; } + .sweet-alert .sa-icon.sa-success { + border-color: #A5DC86; } + .sweet-alert .sa-icon.sa-success::before, .sweet-alert .sa-icon.sa-success::after { + content: ''; + -webkit-border-radius: 40px; + border-radius: 40px; + border-radius: 50%; + position: absolute; + width: 60px; + height: 120px; + background: white; + -webkit-transform: rotate(45deg); + transform: rotate(45deg); } + .sweet-alert .sa-icon.sa-success::before { + -webkit-border-radius: 120px 0 0 120px; + border-radius: 120px 0 0 120px; + top: -7px; + left: -33px; + -webkit-transform: rotate(-45deg); + transform: rotate(-45deg); + -webkit-transform-origin: 60px 60px; + transform-origin: 60px 60px; } + .sweet-alert .sa-icon.sa-success::after { + -webkit-border-radius: 0 120px 120px 0; + border-radius: 0 120px 120px 0; + top: -11px; + left: 30px; + -webkit-transform: rotate(-45deg); + transform: rotate(-45deg); + -webkit-transform-origin: 0px 60px; + transform-origin: 0px 60px; } + .sweet-alert .sa-icon.sa-success .sa-placeholder { + width: 80px; + height: 80px; + border: 4px solid rgba(165, 220, 134, 0.2); + -webkit-border-radius: 40px; + border-radius: 40px; + border-radius: 50%; + box-sizing: content-box; + position: absolute; + left: -4px; + top: -4px; + z-index: 2; } + .sweet-alert .sa-icon.sa-success .sa-fix { + width: 5px; + height: 90px; + background-color: white; + position: absolute; + left: 28px; + top: 8px; + z-index: 1; + -webkit-transform: rotate(-45deg); + transform: rotate(-45deg); } + .sweet-alert .sa-icon.sa-success .sa-line { + height: 5px; + background-color: #A5DC86; + display: block; + border-radius: 2px; + position: absolute; + z-index: 2; } + .sweet-alert .sa-icon.sa-success .sa-line.sa-tip { + width: 25px; + left: 14px; + top: 46px; + -webkit-transform: rotate(45deg); + transform: rotate(45deg); } + .sweet-alert .sa-icon.sa-success .sa-line.sa-long { + width: 47px; + right: 8px; + top: 38px; + -webkit-transform: rotate(-45deg); + transform: rotate(-45deg); } + .sweet-alert .sa-icon.sa-custom { + background-size: contain; + border-radius: 0; + border: none; + background-position: center center; + background-repeat: no-repeat; } + +/* + * Animations + */ +@-webkit-keyframes showSweetAlert { + 0% { + transform: scale(0.7); + -webkit-transform: scale(0.7); } + 45% { + transform: scale(1.05); + -webkit-transform: scale(1.05); } + 80% { + transform: scale(0.95); + -webkit-transform: scale(0.95); } + 100% { + transform: scale(1); + -webkit-transform: scale(1); } } + +@keyframes showSweetAlert { + 0% { + transform: scale(0.7); + -webkit-transform: scale(0.7); } + 45% { + transform: scale(1.05); + -webkit-transform: scale(1.05); } + 80% { + transform: scale(0.95); + -webkit-transform: scale(0.95); } + 100% { + transform: scale(1); + -webkit-transform: scale(1); } } + +@-webkit-keyframes hideSweetAlert { + 0% { + transform: scale(1); + -webkit-transform: scale(1); } + 100% { + transform: scale(0.5); + -webkit-transform: scale(0.5); } } + +@keyframes hideSweetAlert { + 0% { + transform: scale(1); + -webkit-transform: scale(1); } + 100% { + transform: scale(0.5); + -webkit-transform: scale(0.5); } } + +@-webkit-keyframes slideFromTop { + 0% { + top: 0%; } + 100% { + top: 50%; } } + +@keyframes slideFromTop { + 0% { + top: 0%; } + 100% { + top: 50%; } } + +@-webkit-keyframes slideToTop { + 0% { + top: 50%; } + 100% { + top: 0%; } } + +@keyframes slideToTop { + 0% { + top: 50%; } + 100% { + top: 0%; } } + +@-webkit-keyframes slideFromBottom { + 0% { + top: 70%; } + 100% { + top: 50%; } } + +@keyframes slideFromBottom { + 0% { + top: 70%; } + 100% { + top: 50%; } } + +@-webkit-keyframes slideToBottom { + 0% { + top: 50%; } + 100% { + top: 70%; } } + +@keyframes slideToBottom { + 0% { + top: 50%; } + 100% { + top: 70%; } } + +.showSweetAlert[data-animation=pop] { + -webkit-animation: showSweetAlert 0.3s; + animation: showSweetAlert 0.3s; } + +.showSweetAlert[data-animation=none] { + -webkit-animation: none; + animation: none; } + +.showSweetAlert[data-animation=slide-from-top] { + -webkit-animation: slideFromTop 0.3s; + animation: slideFromTop 0.3s; } + +.showSweetAlert[data-animation=slide-from-bottom] { + -webkit-animation: slideFromBottom 0.3s; + animation: slideFromBottom 0.3s; } + +.hideSweetAlert[data-animation=pop] { + -webkit-animation: hideSweetAlert 0.2s; + animation: hideSweetAlert 0.2s; } + +.hideSweetAlert[data-animation=none] { + -webkit-animation: none; + animation: none; } + +.hideSweetAlert[data-animation=slide-from-top] { + -webkit-animation: slideToTop 0.4s; + animation: slideToTop 0.4s; } + +.hideSweetAlert[data-animation=slide-from-bottom] { + -webkit-animation: slideToBottom 0.3s; + animation: slideToBottom 0.3s; } + +@-webkit-keyframes animateSuccessTip { + 0% { + width: 0; + left: 1px; + top: 19px; } + 54% { + width: 0; + left: 1px; + top: 19px; } + 70% { + width: 50px; + left: -8px; + top: 37px; } + 84% { + width: 17px; + left: 21px; + top: 48px; } + 100% { + width: 25px; + left: 14px; + top: 45px; } } + +@keyframes animateSuccessTip { + 0% { + width: 0; + left: 1px; + top: 19px; } + 54% { + width: 0; + left: 1px; + top: 19px; } + 70% { + width: 50px; + left: -8px; + top: 37px; } + 84% { + width: 17px; + left: 21px; + top: 48px; } + 100% { + width: 25px; + left: 14px; + top: 45px; } } + +@-webkit-keyframes animateSuccessLong { + 0% { + width: 0; + right: 46px; + top: 54px; } + 65% { + width: 0; + right: 46px; + top: 54px; } + 84% { + width: 55px; + right: 0px; + top: 35px; } + 100% { + width: 47px; + right: 8px; + top: 38px; } } + +@keyframes animateSuccessLong { + 0% { + width: 0; + right: 46px; + top: 54px; } + 65% { + width: 0; + right: 46px; + top: 54px; } + 84% { + width: 55px; + right: 0px; + top: 35px; } + 100% { + width: 47px; + right: 8px; + top: 38px; } } + +@-webkit-keyframes rotatePlaceholder { + 0% { + transform: rotate(-45deg); + -webkit-transform: rotate(-45deg); } + 5% { + transform: rotate(-45deg); + -webkit-transform: rotate(-45deg); } + 12% { + transform: rotate(-405deg); + -webkit-transform: rotate(-405deg); } + 100% { + transform: rotate(-405deg); + -webkit-transform: rotate(-405deg); } } + +@keyframes rotatePlaceholder { + 0% { + transform: rotate(-45deg); + -webkit-transform: rotate(-45deg); } + 5% { + transform: rotate(-45deg); + -webkit-transform: rotate(-45deg); } + 12% { + transform: rotate(-405deg); + -webkit-transform: rotate(-405deg); } + 100% { + transform: rotate(-405deg); + -webkit-transform: rotate(-405deg); } } + +.animateSuccessTip { + -webkit-animation: animateSuccessTip 0.75s; + animation: animateSuccessTip 0.75s; } + +.animateSuccessLong { + -webkit-animation: animateSuccessLong 0.75s; + animation: animateSuccessLong 0.75s; } + +.sa-icon.sa-success.animate::after { + -webkit-animation: rotatePlaceholder 4.25s ease-in; + animation: rotatePlaceholder 4.25s ease-in; } + +@-webkit-keyframes animateErrorIcon { + 0% { + transform: rotateX(100deg); + -webkit-transform: rotateX(100deg); + opacity: 0; } + 100% { + transform: rotateX(0deg); + -webkit-transform: rotateX(0deg); + opacity: 1; } } + +@keyframes animateErrorIcon { + 0% { + transform: rotateX(100deg); + -webkit-transform: rotateX(100deg); + opacity: 0; } + 100% { + transform: rotateX(0deg); + -webkit-transform: rotateX(0deg); + opacity: 1; } } + +.animateErrorIcon { + -webkit-animation: animateErrorIcon 0.5s; + animation: animateErrorIcon 0.5s; } + +@-webkit-keyframes animateXMark { + 0% { + transform: scale(0.4); + -webkit-transform: scale(0.4); + margin-top: 26px; + opacity: 0; } + 50% { + transform: scale(0.4); + -webkit-transform: scale(0.4); + margin-top: 26px; + opacity: 0; } + 80% { + transform: scale(1.15); + -webkit-transform: scale(1.15); + margin-top: -6px; } + 100% { + transform: scale(1); + -webkit-transform: scale(1); + margin-top: 0; + opacity: 1; } } + +@keyframes animateXMark { + 0% { + transform: scale(0.4); + -webkit-transform: scale(0.4); + margin-top: 26px; + opacity: 0; } + 50% { + transform: scale(0.4); + -webkit-transform: scale(0.4); + margin-top: 26px; + opacity: 0; } + 80% { + transform: scale(1.15); + -webkit-transform: scale(1.15); + margin-top: -6px; } + 100% { + transform: scale(1); + -webkit-transform: scale(1); + margin-top: 0; + opacity: 1; } } + +.animateXMark { + -webkit-animation: animateXMark 0.5s; + animation: animateXMark 0.5s; } + +@-webkit-keyframes pulseWarning { + 0% { + border-color: #F8D486; } + 100% { + border-color: #F8BB86; } } + +@keyframes pulseWarning { + 0% { + border-color: #F8D486; } + 100% { + border-color: #F8BB86; } } + +.pulseWarning { + -webkit-animation: pulseWarning 0.75s infinite alternate; + animation: pulseWarning 0.75s infinite alternate; } + +@-webkit-keyframes pulseWarningIns { + 0% { + background-color: #F8D486; } + 100% { + background-color: #F8BB86; } } + +@keyframes pulseWarningIns { + 0% { + background-color: #F8D486; } + 100% { + background-color: #F8BB86; } } + +.pulseWarningIns { + -webkit-animation: pulseWarningIns 0.75s infinite alternate; + animation: pulseWarningIns 0.75s infinite alternate; } + +@-webkit-keyframes rotate-loading { + 0% { + transform: rotate(0deg); } + 100% { + transform: rotate(360deg); } } + +@keyframes rotate-loading { + 0% { + transform: rotate(0deg); } + 100% { + transform: rotate(360deg); } } + +/* Internet Explorer 9 has some special quirks that are fixed here */ +/* The icons are not animated. */ +/* This file is automatically merged into sweet-alert.min.js through Gulp */ +/* Error icon */ +.sweet-alert .sa-icon.sa-error .sa-line.sa-left { + -ms-transform: rotate(45deg) \9; } + +.sweet-alert .sa-icon.sa-error .sa-line.sa-right { + -ms-transform: rotate(-45deg) \9; } + +/* Success icon */ +.sweet-alert .sa-icon.sa-success { + border-color: transparent\9; } + +.sweet-alert .sa-icon.sa-success .sa-line.sa-tip { + -ms-transform: rotate(45deg) \9; } + +.sweet-alert .sa-icon.sa-success .sa-line.sa-long { + -ms-transform: rotate(-45deg) \9; } + +/*! + * Load Awesome v1.1.0 (http://github.danielcardoso.net/load-awesome/) + * Copyright 2015 Daniel Cardoso <@DanielCardoso> + * Licensed under MIT + */ +.la-ball-fall, +.la-ball-fall > div { + position: relative; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; } + +.la-ball-fall { + display: block; + font-size: 0; + color: #fff; } + +.la-ball-fall.la-dark { + color: #333; } + +.la-ball-fall > div { + display: inline-block; + float: none; + background-color: currentColor; + border: 0 solid currentColor; } + +.la-ball-fall { + width: 54px; + height: 18px; } + +.la-ball-fall > div { + width: 10px; + height: 10px; + margin: 4px; + border-radius: 100%; + opacity: 0; + -webkit-animation: ball-fall 1s ease-in-out infinite; + -moz-animation: ball-fall 1s ease-in-out infinite; + -o-animation: ball-fall 1s ease-in-out infinite; + animation: ball-fall 1s ease-in-out infinite; } + +.la-ball-fall > div:nth-child(1) { + -webkit-animation-delay: -200ms; + -moz-animation-delay: -200ms; + -o-animation-delay: -200ms; + animation-delay: -200ms; } + +.la-ball-fall > div:nth-child(2) { + -webkit-animation-delay: -100ms; + -moz-animation-delay: -100ms; + -o-animation-delay: -100ms; + animation-delay: -100ms; } + +.la-ball-fall > div:nth-child(3) { + -webkit-animation-delay: 0ms; + -moz-animation-delay: 0ms; + -o-animation-delay: 0ms; + animation-delay: 0ms; } + +.la-ball-fall.la-sm { + width: 26px; + height: 8px; } + +.la-ball-fall.la-sm > div { + width: 4px; + height: 4px; + margin: 2px; } + +.la-ball-fall.la-2x { + width: 108px; + height: 36px; } + +.la-ball-fall.la-2x > div { + width: 20px; + height: 20px; + margin: 8px; } + +.la-ball-fall.la-3x { + width: 162px; + height: 54px; } + +.la-ball-fall.la-3x > div { + width: 30px; + height: 30px; + margin: 12px; } + +/* + * Animation + */ +@-webkit-keyframes ball-fall { + 0% { + opacity: 0; + -webkit-transform: translateY(-145%); + transform: translateY(-145%); } + 10% { + opacity: .5; } + 20% { + opacity: 1; + -webkit-transform: translateY(0); + transform: translateY(0); } + 80% { + opacity: 1; + -webkit-transform: translateY(0); + transform: translateY(0); } + 90% { + opacity: .5; } + 100% { + opacity: 0; + -webkit-transform: translateY(145%); + transform: translateY(145%); } } + +@-moz-keyframes ball-fall { + 0% { + opacity: 0; + -moz-transform: translateY(-145%); + transform: translateY(-145%); } + 10% { + opacity: .5; } + 20% { + opacity: 1; + -moz-transform: translateY(0); + transform: translateY(0); } + 80% { + opacity: 1; + -moz-transform: translateY(0); + transform: translateY(0); } + 90% { + opacity: .5; } + 100% { + opacity: 0; + -moz-transform: translateY(145%); + transform: translateY(145%); } } + +@-o-keyframes ball-fall { + 0% { + opacity: 0; + -o-transform: translateY(-145%); + transform: translateY(-145%); } + 10% { + opacity: .5; } + 20% { + opacity: 1; + -o-transform: translateY(0); + transform: translateY(0); } + 80% { + opacity: 1; + -o-transform: translateY(0); + transform: translateY(0); } + 90% { + opacity: .5; } + 100% { + opacity: 0; + -o-transform: translateY(145%); + transform: translateY(145%); } } + +@keyframes ball-fall { + 0% { + opacity: 0; + -webkit-transform: translateY(-145%); + -moz-transform: translateY(-145%); + -o-transform: translateY(-145%); + transform: translateY(-145%); } + 10% { + opacity: .5; } + 20% { + opacity: 1; + -webkit-transform: translateY(0); + -moz-transform: translateY(0); + -o-transform: translateY(0); + transform: translateY(0); } + 80% { + opacity: 1; + -webkit-transform: translateY(0); + -moz-transform: translateY(0); + -o-transform: translateY(0); + transform: translateY(0); } + 90% { + opacity: .5; } + 100% { + opacity: 0; + -webkit-transform: translateY(145%); + -moz-transform: translateY(145%); + -o-transform: translateY(145%); + transform: translateY(145%); } } diff --git a/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java new file mode 100644 index 0000000..634ceae --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java @@ -0,0 +1,46 @@ +package com.casic.accessControl.app.domain; + +import javax.persistence.*; +import java.util.Date; + +/** + * app的版本信息 + */ +//工单 +@Entity +@Table(name = "apkVersion") +public class ApkVersion { + private String version; + private String path; + private Date ts;//时间戳 + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "version") + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + @Column(name = "path") + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + @Column(name = "ts") + public Date getTs() { + return ts; + } + + public void setTs(Date ts) { + this.ts = ts; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java new file mode 100644 index 0000000..1d0242a --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java @@ -0,0 +1,50 @@ +package com.casic.accessControl.app.dto; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.util.TimeFormat; + +/** + * Created by lenovo on 2016/4/13. + */ +public class ApkVersionDto { + private String version; + private String path; + private String ts; + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public String getTs() { + return ts; + } + + public void setTs(String ts) { + this.ts = ts; + } + + public static ApkVersionDto Convert(ApkVersion version) { + if (version == null) { + return null; + } + ApkVersionDto versionDto = new ApkVersionDto(); + versionDto.setVersion(version.getVersion()); + versionDto.setPath(version.getVersion()); + versionDto.setTs(TimeFormat.formatTimestamp(version.getTs())); + + return versionDto; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java b/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java new file mode 100644 index 0000000..28b12a7 --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java @@ -0,0 +1,27 @@ +package com.casic.accessControl.app.manager; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.core.hibernate.HibernateEntityDao; +import org.hibernate.Query; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * + */ +@Service("apkVersionManager") +public class ApkVersionManager extends HibernateEntityDao { + + public ApkVersion getLatestVersion() { + String sql = "from ApkVersion order by ts desc"; + Query query = getSession().createQuery(sql); + List list = query.list(); + if (null != list && list.isEmpty() == false) { + return list.get(0); + } + + return null; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java b/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java new file mode 100644 index 0000000..065d3cc --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java @@ -0,0 +1,66 @@ +package com.casic.accessControl.app.web; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.app.manager.ApkVersionManager; +import com.casic.accessControl.marker.domain.Marker; +import com.casic.accessControl.marker.manager.MarkerManager; +import com.casic.accessControl.task.domain.Task; +import com.casic.accessControl.task.domain.TaskDetail; +import com.casic.accessControl.task.dto.TaskDetailDto; +import com.casic.accessControl.task.dto.TaskDto; +import com.casic.accessControl.task.dto.TaskStatus; +import com.casic.accessControl.task.manager.TaskDetailManager; +import com.casic.accessControl.task.manager.TaskManager; +import com.casic.accessControl.user.domain.Company; +import com.casic.accessControl.user.domain.Role; +import com.casic.accessControl.user.domain.User; +import com.casic.accessControl.user.dto.UserDto; +import com.casic.accessControl.user.manager.RoleManager; +import com.casic.accessControl.user.manager.UserManager; +import com.casic.accessControl.util.DataTable; +import com.casic.accessControl.util.StringUtils; +import com.google.gson.Gson; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +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.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * Created by lenovo on 2016/4/13. + */ +@Controller +@RequestMapping("app") +public class ApkVersionController { + + @Resource + private ApkVersionManager apkVersionManager; + + @RequestMapping("get-latest-version") + @ResponseBody + public Map getLatestVersion(HttpServletResponse response, HttpSession session) { + Map result = new HashMap(); + try { + ApkVersion latest = apkVersionManager.getLatestVersion(); + if (null != latest) { + result.put("version", latest.getVersion()); + result.put("path", latest.getPath()); + } else { + result.put("version", "1.0.0"); + } + } catch (Exception e) { + e.printStackTrace(); + result.put("version", "1.0.0"); + } + + return result; + } + +} diff --git a/src/main/java/com/casic/accessControl/marker/domain/Marker.java b/src/main/java/com/casic/accessControl/marker/domain/Marker.java index 0575cfe..7d5b854 100644 --- a/src/main/java/com/casic/accessControl/marker/domain/Marker.java +++ b/src/main/java/com/casic/accessControl/marker/domain/Marker.java @@ -67,6 +67,10 @@ private String area; @Column(name = "line") private String line; + @Column(name = "colorType") + private String colorType; + @Column(name = "photos") + private String photos; @@ -315,4 +319,20 @@ public void setArea(String area) { this.area = area; } + + public String getColorType() { + return colorType; + } + + public void setColorType(String colorType) { + this.colorType = colorType; + } + + public String getPhotos() { + return photos; + } + + public void setPhotos(String photos) { + this.photos = photos; + } } diff --git a/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java b/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java index 506f31d..c5f8cf5 100644 --- a/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java +++ b/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java @@ -2,12 +2,12 @@ //import com.casic.accessControl.feature.domain.Feature; import com.casic.accessControl.marker.domain.Marker; +import com.casic.accessControl.util.StringUtils; +import com.casic.accessControl.util.TimeFormat; import org.apache.commons.collections.CollectionUtils; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.List; +import java.text.ParseException; +import java.util.*; /** * Created by lenovo on 2016/5/16. @@ -43,6 +43,8 @@ private Long userId; private String area; private String line; + private String colorType; + private String photos; private String btnEdit = "编辑"; private String btnDelete = "删除"; @@ -296,6 +298,23 @@ this.area = area; } + public String getColorType() { + if (StringUtils.isEmpty(colorType)) return "0"; + return colorType; + } + + public void setColorType(String colorType) { + this.colorType = colorType; + } + + public String getPhotos() { + return photos; + } + + public void setPhotos(String photos) { + this.photos = photos; + } + public String getLine() { return line; } @@ -335,6 +354,52 @@ result.setRoad(doNullChange(marker.getRoad())); result.setArea(doNullChange(marker.getArea())); result.setLine(doNullChange(marker.getLine())); + result.setColorType(marker.getColorType()); + result.setPhotos(marker.getPhotos()); + return result; + } + + public static Marker convert2Marker(MarkerDto markerDto) { + if (markerDto == null) return null; + Marker result = new Marker(); + if(markerDto.getLongitude()==null||markerDto.getLatitude()==null) return null; + if (null != markerDto.getCreateTime() && markerDto.getCreateTime().length() == 19) { + try { + result.setCreateTime(TimeFormat.parse(markerDto.getCreateTime(), "yyyy-MM-dd HH:mm:ss")); + } catch (ParseException pex) { + result.setCreateTime(Calendar.getInstance().getTime()); + } + } else { + result.setCreateTime(Calendar.getInstance().getTime()); + } + result.setDepth(doNullChange(markerDto.getDepth())); + result.setId(markerDto.getId()); + result.setLatitude(markerDto.getLatitude()); + result.setLongitude(markerDto.getLongitude()); + result.setMarkerId(markerDto.getMarkerId()); + result.setMarkerDepth(doNullChange(markerDto.getMarkerDepth())); + result.setMarkerObjectId(doNullChange(markerDto.getMarkerObjectId())); + result.setMarkerObjectType(doNullChange(markerDto.getMarkerObjectType())); + result.setOwnerComp(doNullChange(markerDto.getOwnerComp())); + result.setIsValid(markerDto.getIsValid()); + result.setMemo(doNullChange(markerDto.getMemo())); + result.setPipeDiameter(doNullChange(markerDto.getPipeDiameter())); + result.setPipeMaterial(doNullChange(markerDto.getPipeMaterial())); + result.setMarkerType(doNullChange(markerDto.getMarkerType())); + result.setCreator(doNullChange(markerDto.getCreator())); + + result.setLayStyle(doNullChange(markerDto.getLayStyle())); + result.setBelowDepth(doNullChange(markerDto.getBelowDepth())); + result.setBelowDiameter(doNullChange(markerDto.getBelowDiameter())); + result.setBelowMaterial(doNullChange(markerDto.getBelowMaterial())); + result.setBelowType(doNullChange(markerDto.getBelowType())); + result.setConstructTime(doNullChange(markerDto.getConstructTime())); + result.setRecordType(markerDto.getRecordType()); + result.setRoad(doNullChange(markerDto.getRoad())); + result.setArea(doNullChange(markerDto.getArea())); + result.setLine(doNullChange(markerDto.getLine())); + result.setColorType(markerDto.getColorType()); + result.setPhotos(markerDto.getPhotos()); return result; } diff --git a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java index dd0fa4b..ba5a1fb 100644 --- a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java +++ b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java @@ -9,10 +9,7 @@ import com.casic.accessControl.marker.domain.Marker; import com.casic.accessControl.user.domain.Company; import com.casic.accessControl.user.domain.User; -import com.casic.accessControl.util.DataTable; -import com.casic.accessControl.util.DataTableParameter; -import com.casic.accessControl.util.DataTableUtils; -import com.casic.accessControl.util.DateUtils; +import com.casic.accessControl.util.*; import com.google.gson.Gson; import jxl.*; import jxl.read.biff.BiffException; @@ -31,11 +28,15 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; +import sun.misc.BASE64Decoder; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.File; +import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.text.ParseException; @@ -183,6 +184,53 @@ } /** + * 保存标识器和图片信息 + * @param markerDto + * @param companyId + * @param fileNames + * @param fileBuffers + * @return + */ + public boolean saveMarkerAndPhotos(MarkerDto markerDto, Long companyId, String[] fileNames, String[] fileBuffers) { + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + String strDirPath = request.getSession().getServletContext().getRealPath(""); + FileOutputStream fos = null; + String month = TimeFormat.format(Calendar.getInstance().getTime(), "yyyyMM"); + String webPath = "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String toDir = strDirPath + "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String filePaths = ""; + try { + for (int i = 0; i < fileBuffers.length; i++) { + if (fileBuffers[i] != null && fileNames[i] != null) { +// filePaths += toDir+fileNames[i]+","; + filePaths += webPath + fileNames[i] + ","; + byte[] buffer = new BASE64Decoder().decodeBuffer(fileBuffers[i]); //对android传过来的图片字符串进行解码 + File destDir = new File(toDir); + if (!destDir.exists()) + destDir.mkdirs(); + File imageFile = new File(destDir, fileNames[i]); + fos = new FileOutputStream(imageFile); //保存图片 + fos.write(buffer); + fos.flush(); + fos.close(); + } + } + if (filePaths.endsWith(",")) { + filePaths = filePaths.substring(0, filePaths.length() - 1); + } + } catch (Exception e) { + return false; + } + Marker marker = MarkerDto.convert2Marker(markerDto); + marker.setIsValid(1); + marker.setCompanyId(companyId); + marker.setPhotos(filePaths); + save(marker); + return true; + + } + + /** * 新增标识器 8-9 * * @param markers @@ -582,7 +630,7 @@ "所属区域","所属线路","所属道路","建设年代","权属单位","标示对象ID", "标识器ID","标识器类型","标识器埋深","安装部门","经度", "纬度", "最后修改时间","备注","下层管种类", "下层管埋深", - "下层管直径", "下层管材料", "标识对象类别"}; + "下层管直径", "下层管材料", "标识对象类别", "标识点颜色", "图片地址"}; Label[][] labels = new Label[markerDtos.size() + 1][titleTxt.length]; for(int k=0;k saveMarkerAndPhotos(@RequestParam(value = "fileBuffer1", required = false) MultipartFile fileBuffer1, + @RequestParam(value = "fileBuffer2", required = false) MultipartFile fileBuffer2, + @RequestParam(value = "fileBuffer3", required = false) MultipartFile fileBuffer3, + @RequestParam(value = "jsonMarker", required = true) String jsonMarker) { + Map map = new HashMap(); + map.put("message", "安装无标识器信息"); + Gson gson = new Gson(); + try { + MarkerDto marker = gson.fromJson(jsonMarker, MarkerDto.class); + + if (null == marker.getMarkerId()) { + map.put("message", "无标识器ID"); + map.put("success", "false"); + return map; + } else if (markerManager.getMarkerByMarkerId(marker.getMarkerId()).size() > 0) { + map.put("message", "已安装过该标识器[" + marker.getMarkerId() + "]"); + map.put("success", "false"); + return map; + } else { + String[] fileNames = new String[3]; + String[] fileBuffers = new String[3]; + if (fileBuffer1 != null) { + fileNames[0] = marker.getMarkerId() + "_" + fileBuffer1.getOriginalFilename(); + byte[] fis = fileBuffer1.getBytes(); + fileBuffers[0] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, com.sun.org.apache.xml.internal.security.utils.Base64.BASE64DEFAULTLENGTH)); + } + if (fileBuffer2 != null) { + fileNames[1] = marker.getMarkerId() + "_" + fileBuffer2.getOriginalFilename(); + byte[] fis = fileBuffer2.getBytes(); + fileBuffers[1] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, com.sun.org.apache.xml.internal.security.utils.Base64.BASE64DEFAULTLENGTH)); + } + if (fileBuffer3 != null) { + fileNames[2] = marker.getMarkerId() + "_" + fileBuffer3.getOriginalFilename(); + byte[] fis = fileBuffer3.getBytes(); + fileBuffers[2] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, Base64.BASE64DEFAULTLENGTH)); + } + Long companyId = marker.getCompanyId(); + if (companyId == null) { + return map; + } + boolean result = markerManager.saveMarkerAndPhotos(marker, companyId, fileNames, fileBuffers); + if (!result) { + return map; + } + } + } catch (Exception e) { + return map; + } + map.put("success", "true"); + map.put("message", "保存成功"); + return map; + } + + @RequestMapping("marker-info-delete") @ResponseBody public Map delete(@RequestParam(value = "id", required = true) Long id) { @@ -144,6 +208,9 @@ map.put("message", "删除需要ID信息"); return map; } + + System.out.println(ids); + markerManager.delMarkerByIds(ids); map.put("success", true); map.put("message", "删除成功"); @@ -240,6 +307,54 @@ return map; } + /** + * 批量上传标识点,用于无信号地区标识器信息统一上传,不修改已有标识点信息 + * @param strMarkers + * @return + */ + @RequestMapping("batch-save-no-update") + @ResponseBody + public Map batchSaveOrUpdate(@RequestParam(value = "markers", required = true) String strMarkers) { + strMarkers = strMarkers.replace('\n',' '); + Map map = new HashMap(); + map.put("message", "批量导入失败,或无导入标识器信息"); + Gson gson = new Gson(); + try { + List markers = gson.fromJson(strMarkers, new TypeToken>() { + }.getType()); + if (CollectionUtils.isEmpty(markers)) {//批量导入数据不存在,直接返回 + map.put("message", "批量导入数据不存在"); + return map; + } + + Long companyId = markers.get(0).getCompanyId(); + if (companyId == null) { + map.put("message", "未找到所属公司属性"); + return map; + } + + List markerDtoForSave = new ArrayList(); + for (MarkerDto markerDto : markers) { + // 上传marker的Id不为空且数据库中不存在记录,经纬度不为空,允许保存 + if (StringUtils.isNotBlank(markerDto.getMarkerId()) && markerManager.getMarkerByMarkerId(markerDto.getMarkerId()).size() <= 0) { + if (null != markerDto.getLongitude() && null != markerDto.getLatitude()) { + markerDtoForSave.add(markerDto); + } + } + } + boolean result = markerManager.batchSave(markerDtoForSave, companyId); + if (!result) { + return map; + } + } catch (Exception e) { + e.printStackTrace(); + return map; + } + map.put("success", true); + map.put("message", "保存成功"); + return map; + } + @RequestMapping("getMarkerListByCondition") @ResponseBody @POST diff --git a/src/main/java/com/casic/accessControl/user/web/UserController.java b/src/main/java/com/casic/accessControl/user/web/UserController.java index feab678..3534a97 100644 --- a/src/main/java/com/casic/accessControl/user/web/UserController.java +++ b/src/main/java/com/casic/accessControl/user/web/UserController.java @@ -46,6 +46,7 @@ @ResponseBody public Map login(@ModelAttribute User userInfo, HttpSession session) { Map result = new HashMap(); + User user = null; try{ user = userManager.login(userInfo); diff --git a/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java b/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java new file mode 100644 index 0000000..582120f --- /dev/null +++ b/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java @@ -0,0 +1,129 @@ +package com.casic.accessControl.util; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.net.URL; +import java.net.URLConnection; +import java.util.List; +import java.util.Map; + +/** + * Created by lenovo on 2016/8/31. + */ +public class HttpRequestUtils { + + /** + * 向指定URL发送GET方法的请求 + * + * @param url + * 发送请求的URL + * @param param + * 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 + * @return URL 所代表远程资源的响应结果 + */ + public static String sendGet(String url, String param) { + String result = ""; + BufferedReader in = null; + try { + String urlNameString = url + "?" + param; + URL realUrl = new URL(urlNameString); + // 打开和URL之间的连接 + URLConnection connection = realUrl.openConnection(); + // 设置通用的请求属性 + connection.setRequestProperty("accept", "*/*"); + connection.setRequestProperty("connection", "Keep-Alive"); + connection.setRequestProperty("user-agent", + "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + // 建立实际的连接 + connection.connect(); + // 获取所有响应头字段 + Map> map = connection.getHeaderFields(); + // 遍历所有的响应头字段 + for (String key : map.keySet()) { + System.out.println(key + "--->" + map.get(key)); + } + // 定义 BufferedReader输入流来读取URL的响应 + in = new BufferedReader(new InputStreamReader( + connection.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + result += line; + } + } catch (Exception e) { + System.out.println("发送GET请求出现异常!" + e); + e.printStackTrace(); + } + // 使用finally块来关闭输入流 + finally { + try { + if (in != null) { + in.close(); + } + } catch (Exception e2) { + e2.printStackTrace(); + } + } + return result; + } + + /** + * 向指定 URL 发送POST方法的请求 + * + * @param url + * 发送请求的 URL + * @param param + * 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 + * @return 所代表远程资源的响应结果 + */ + public static String sendPost(String url, String param) { + PrintWriter out = null; + BufferedReader in = null; + String result = ""; + try { + URL realUrl = new URL(url); + // 打开和URL之间的连接 + URLConnection conn = realUrl.openConnection(); + // 设置通用的请求属性 + conn.setRequestProperty("accept", "*/*"); + conn.setRequestProperty("connection", "Keep-Alive"); + conn.setRequestProperty("user-agent", + "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + // 发送POST请求必须设置如下两行 + conn.setDoOutput(true); + conn.setDoInput(true); + // 获取URLConnection对象对应的输出流 + out = new PrintWriter(conn.getOutputStream()); + // 发送请求参数 + out.print(param); + // flush输出流的缓冲 + out.flush(); + // 定义BufferedReader输入流来读取URL的响应 + in = new BufferedReader( + new InputStreamReader(conn.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + result += line; + } + } catch (Exception e) { + System.out.println("发送 POST 请求出现异常!"+e); + e.printStackTrace(); + } + //使用finally块来关闭输出流、输入流 + finally{ + try{ + if(out!=null){ + out.close(); + } + if(in!=null){ + in.close(); + } + } + catch(IOException ex){ + ex.printStackTrace(); + } + } + return result; + } + } \ No newline at end of file diff --git a/src/main/java/com/casic/accessControl/util/TimeFormat.java b/src/main/java/com/casic/accessControl/util/TimeFormat.java new file mode 100644 index 0000000..e9168d5 --- /dev/null +++ b/src/main/java/com/casic/accessControl/util/TimeFormat.java @@ -0,0 +1,148 @@ +package com.casic.accessControl.util; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +/** + * 格式化日期工具类 + * 默认模式yyyy-MM-dd HH:mm:ss + * @author Administrator + * + */ +public class TimeFormat { + + private static final String DATE_FORMAT_STRING = "yyyy-MM-dd"; + private static final String TIME_FORMAT_STRING = "HH:mm:ss"; + private static final String TIMESTAMP_FORMAT_STRING = "yyyy-MM-dd HH:mm:ss"; + + // 默认格式化格式 + private static SimpleDateFormat defaultFormat = new SimpleDateFormat(TIMESTAMP_FORMAT_STRING); + + public static void setFormatString(String pattern) { + defaultFormat.applyPattern(pattern); + } + + /** + * 默认格式化日期 + * + * @param Date date + * @return String + */ + public static String format(Date date) { + return defaultFormat.format(date); + } + + /** + * 日期格式化 + * + * @param date + * @return + */ + public static String formatDate(Date date) { + return TimeFormat.format(date, DATE_FORMAT_STRING); + } + + /** + * 时间格式化 + * + * @param date + * @return + */ + public static String formatTime(Date date) { + return TimeFormat.format(date, TIME_FORMAT_STRING); + } + + /** + * 时间戳格式化 + * + * @param date + * @return + */ + public static String formatTimestamp(Date date) { + return TimeFormat.format(date, TIMESTAMP_FORMAT_STRING); + } + + /** + * 以指定模式格式化日期 + * + * @param Date date + * @param String pattern + * @return String + */ + public static String format(Date date, String pattern) { + SimpleDateFormat formatter = new SimpleDateFormat(pattern); + return formatter.format(date); + } + + /** + * 根据起止日期生成日期序列 + * 包括start和end的日期 + * + * @param start + * @param end + * @return + */ + public static List generateDates(String start, String end) throws ParseException { + List dates = new ArrayList(); + Calendar s = Calendar.getInstance(); + Calendar e = Calendar.getInstance(); + s.setTime(TimeFormat.parse(start, DATE_FORMAT_STRING)); + s.set(Calendar.HOUR_OF_DAY, 0); + s.set(Calendar.MINUTE, 0); + s.set(Calendar.SECOND, 0); + e.setTime(TimeFormat.parse(end, DATE_FORMAT_STRING)); + e.set(Calendar.HOUR_OF_DAY, 0); + e.set(Calendar.MINUTE, 0); + e.set(Calendar.SECOND, 0); + while (s.before(e) == true) { + dates.add(TimeFormat.formatDate(s.getTime())); + s.add(Calendar.DATE, 1); + } + + dates.add(end); + return dates; + } + + + /** + * 解析日期字符串 + * + * @param String source + * @return Date + * + * @throws ParseException + */ + public static Date parse(String source) throws ParseException { + return defaultFormat.parse(source); + } + + /** + * 以指定模式解析日期 + * + * @param String source + * @param String pattern + * @return Date + * + * @throws ParseException + */ + public static Date parse(String source, String pattern) throws ParseException { + SimpleDateFormat formatter = new SimpleDateFormat(pattern); + return formatter.parse(source); + } + + + public static Date parseDateWithoutTime(String source) throws ParseException { + SimpleDateFormat formatter = new SimpleDateFormat(DATE_FORMAT_STRING); + Calendar date = Calendar.getInstance(); + date.setTime(formatter.parse(source)); + date.set(Calendar.HOUR, 0); + date.set(Calendar.HOUR, 0); + date.set(Calendar.MINUTE, 0); + return date.getTime(); + } + +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 53c91ea..cea976f 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -15,19 +15,17 @@ # ============================================================================ # db # ============================================================================ -#db.default.driverClassName=oracle.jdbc.driver.OracleDriver -#db.default.url=jdbc:oracle:thin:@192.168.0.203:1521:SZHTDB2 -#db.default.username=scott -#db.default.password=SZHTDB2 db.default.driverClassName=com.mysql.jdbc.Driver -db.default.url=jdbc:mysql://127.0.0.1:3306/ems?useUnicode=true&characterEncoding=UTF-8 -db.default.username=emsweb -db.default.password=emsweb +db.default.url=jdbc:mysql://127.0.0.1:3306/ems_tong?useUnicode=true&characterEncoding=UTF-8 +db.default.username=root +db.default.password=root +#db.default.username=emsweb +#db.default.password=emsweb #db.default.url=jdbc:mysql://119.254.110.71:3307/ems?useUnicode=true&characterEncoding=UTF-8 #db.default.username=root #db.default.password=rootems - -# ============================================================================ +# +## ============================================================================ # log4jdbc # ============================================================================ log4jdbc.enable=true diff --git a/src/main/resources/spring/applicationContext-filter.xml b/src/main/resources/spring/applicationContext-filter.xml index a08c5fc..98ac7d6 100644 --- a/src/main/resources/spring/applicationContext-filter.xml +++ b/src/main/resources/spring/applicationContext-filter.xml @@ -35,9 +35,13 @@ /user/ill-login.do /marker/exportMarker.do /marker/batchSave-na.do + /marker/batch-save-no-update.do + /marker/save-marker-photo.do /event/save-event.do /task/get-task.do + /app/get-latest-version.do /xls/* + /apk/* diff --git a/src/main/resources/spring/applicationContext-hibernate.xml b/src/main/resources/spring/applicationContext-hibernate.xml index 5bb1a7e..dc54192 100644 --- a/src/main/resources/spring/applicationContext-hibernate.xml +++ b/src/main/resources/spring/applicationContext-hibernate.xml @@ -65,6 +65,7 @@ com.casic.accessControl.task.domain.Position com.casic.accessControl.event.domain.Event com.casic.accessControl.marker.domain.OptionItem + com.casic.accessControl.app.domain.ApkVersion diff --git a/src/main/webapp/common/layout/menu_new.jsp b/src/main/webapp/common/layout/menu_new.jsp index 3cf4b4e..cbd822e 100644 --- a/src/main/webapp/common/layout/menu_new.jsp +++ b/src/main/webapp/common/layout/menu_new.jsp @@ -20,7 +20,7 @@
                                        • - + @@ -54,7 +54,7 @@
                                        • - + diff --git a/src/main/webapp/content/ems/ems-gd.jsp b/src/main/webapp/content/ems/ems-gd.jsp new file mode 100644 index 0000000..5137b49 --- /dev/null +++ b/src/main/webapp/content/ems/ems-gd.jsp @@ -0,0 +1,604 @@ +<%@page contentType="text/html;charset=UTF-8" %> + +<%@include file="/taglibs.jsp" %> + +<%pageContext.setAttribute("currentMenu", "ems");%> + + + + + + + + + + + + + 地下管线电子标识系统 + + + + + + + + + + + + + + + + + + +<%-- + +--%> + + + + + + + + + + + + + + +<%@include file="/common/layout/header.jsp" %> + +
                                          + + + + <%@include file="/common/layout/menu_new.jsp" %> + + + +
                                          + + + +
                                          + +
                                          + + +
                                          +
                                          +
                                          +
                                          + +
                                          +
                                          + +
                                          +
                                          + +
                                          +
                                          + +
                                          +
                                          + +
                                          + +
                                          + +
                                          + +
                                          + +
                                          + +
                                          +
                                          +
                                          + + + + +
                                          +
                                          +
                                          +
                                          + + + + +
                                          +
                                          +
                                          + +
                                          + +
                                          + +<%--todo list:错误使用方法 + +--%> +
                                          + +
                                          +
                                          + +
                                          + +
                                          + +
                                          + + +
                                          + +
                                          + + 移动 + 绘制区域 + 新增标识器 + 删除标识器 + 保存标识器 + 批量导入 + 导出Excel + 清空 + +
                                          + +
                                          +
                                          + +
                                          + + + +
                                          + +
                                          + +
                                          + + + + +
                                          + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/webapp/content/task/task-gd.jsp b/src/main/webapp/content/task/task-gd.jsp new file mode 100644 index 0000000..d2d5549 --- /dev/null +++ b/src/main/webapp/content/task/task-gd.jsp @@ -0,0 +1,374 @@ +<%@page contentType="text/html;charset=UTF-8" %> + +<%@include file="/taglibs.jsp" %> + +<%pageContext.setAttribute("currentMenu", "task");%> + + + + + + + + + + + + + 地下管线电子标识系统 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +<%@include file="/common/layout/header.jsp" %> + +
                                          + + + + <%@include file="/common/layout/menu_new.jsp" %> + + + +
                                          + + + +
                                          + +
                                          + +
                                          + + 移动 + 绘制区域 + 选择多点创建工单 + 清空选择 + +
                                          + +
                                          + +
                                          + + +
                                          + +
                                          + +
                                          + +
                                          历史工单
                                          + +
                                          + +
                                          + +
                                          + <%--巡检员:--%> +
                                          +
                                          + + +
                                          +
                                          + + +
                                            +
                                          +
                                            +
                                            + +
                                            + +
                                            + +
                                            + +
                                            +
                                            + +
                                            + + + +
                                            + +
                                            + +
                                            + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/webapp/images/drop/0.png b/src/main/webapp/images/drop/0.png new file mode 100644 index 0000000..f4b966b --- /dev/null +++ b/src/main/webapp/images/drop/0.png Binary files differ diff --git a/src/main/webapp/images/drop/1.png b/src/main/webapp/images/drop/1.png new file mode 100644 index 0000000..9284b64 --- /dev/null +++ b/src/main/webapp/images/drop/1.png Binary files differ diff --git a/src/main/webapp/images/drop/2.png b/src/main/webapp/images/drop/2.png new file mode 100644 index 0000000..b5425db --- /dev/null +++ b/src/main/webapp/images/drop/2.png Binary files differ diff --git a/src/main/webapp/images/drop/3.png b/src/main/webapp/images/drop/3.png new file mode 100644 index 0000000..dd09655 --- /dev/null +++ b/src/main/webapp/images/drop/3.png Binary files differ diff --git a/src/main/webapp/images/drop/4.png b/src/main/webapp/images/drop/4.png new file mode 100644 index 0000000..50cf1f7 --- /dev/null +++ b/src/main/webapp/images/drop/4.png Binary files differ diff --git a/src/main/webapp/images/drop/5.png b/src/main/webapp/images/drop/5.png new file mode 100644 index 0000000..a2029bd --- /dev/null +++ b/src/main/webapp/images/drop/5.png Binary files differ diff --git a/src/main/webapp/images/drop/6.png b/src/main/webapp/images/drop/6.png new file mode 100644 index 0000000..b53248a --- /dev/null +++ b/src/main/webapp/images/drop/6.png Binary files differ diff --git a/src/main/webapp/images/ems/point.png b/src/main/webapp/images/ems/point.png new file mode 100644 index 0000000..a814351 --- /dev/null +++ b/src/main/webapp/images/ems/point.png Binary files differ diff --git a/src/main/webapp/images/ems/rect.png b/src/main/webapp/images/ems/rect.png new file mode 100644 index 0000000..99d0c9e --- /dev/null +++ b/src/main/webapp/images/ems/rect.png Binary files differ diff --git a/src/main/webapp/images/events/red_icon.png b/src/main/webapp/images/events/red_icon.png new file mode 100644 index 0000000..78c26e4 --- /dev/null +++ b/src/main/webapp/images/events/red_icon.png Binary files differ diff --git a/src/main/webapp/images/point-task.png b/src/main/webapp/images/point-task.png new file mode 100644 index 0000000..b2e22c6 --- /dev/null +++ b/src/main/webapp/images/point-task.png Binary files differ diff --git a/src/main/webapp/images/point.png b/src/main/webapp/images/point.png new file mode 100644 index 0000000..4b887dc --- /dev/null +++ b/src/main/webapp/images/point.png Binary files differ diff --git a/src/main/webapp/images/tasks/point.png b/src/main/webapp/images/tasks/point.png new file mode 100644 index 0000000..a814351 --- /dev/null +++ b/src/main/webapp/images/tasks/point.png Binary files differ diff --git a/src/main/webapp/images/tasks/rect.png b/src/main/webapp/images/tasks/rect.png new file mode 100644 index 0000000..99d0c9e --- /dev/null +++ b/src/main/webapp/images/tasks/rect.png Binary files differ diff --git a/src/main/webapp/s/app/ems/EMSBean.js b/src/main/webapp/s/app/ems/EMSBean.js index ca6914b..a3b1dca 100644 --- a/src/main/webapp/s/app/ems/EMSBean.js +++ b/src/main/webapp/s/app/ems/EMSBean.js @@ -1,5 +1,6 @@ EMSBean = function (markerObjectType,pipeMaterial,pipeDiameter, layStyle, depth, belowType, belowDepth, belowDiameter, belowMaterial, road, - constructTime, ownerComp, markerObjectId, markerId, markerType, markerDepth, creator, createTime, memo, lat, long, recordType,id,line,area) { + constructTime, ownerComp, markerObjectId, markerId, markerType, markerDepth, creator, createTime, memo, lat, long, + recordType,id,line,area, colorType) { this.markerObjectType = markerObjectType; this.pipeMaterial = pipeMaterial; @@ -26,5 +27,5 @@ this.id = id; this.line=line; this.area =area; - + this.colorType = colorType; }; diff --git a/src/main/webapp/s/app/ems/ems-gd.js b/src/main/webapp/s/app/ems/ems-gd.js new file mode 100644 index 0000000..8875ae8 --- /dev/null +++ b/src/main/webapp/s/app/ems/ems-gd.js @@ -0,0 +1,627 @@ +/** + * Created by lenovo on 2016/4/13. + */ +//定义全局变量,缓存组织结构 + +var EmsGd = function () { + var isSaveStatus = false; + var map = null; + var mouseTool = null; + var drawOverlays = new Array(); + var readyToUploadMarkers = new Array(); + var vectorMarkers = []; + var markerData = []; + var hadRequest = false; + + var blueIcon = new AMap.Icon({ + size: new AMap.Size(25, 34), + image: $('#context').val() + '/images/drop/0.png' + }); + + var orangeIcon = new AMap.Icon({ + size: new AMap.Size(25, 34), + image: $('#context').val() + '/images/drop/1.png' + }); + + var redIcon = new AMap.Icon({ + size: new AMap.Size(25, 34), + image: $('#context').val() + '/images/drop/2.png' + }); + + var blackIcon = new AMap.Icon({ + size: new AMap.Size(25, 34), + image: $('#context').val() + '/images/drop/3.png' + }); + + var pinkIcon = new AMap.Icon({ + size: new AMap.Size(25, 34), + image: $('#context').val() + '/images/drop/4.png' + }); + + var yellowIcon = new AMap.Icon({ + size: new AMap.Size(25, 34), + image: $('#context').val() + '/images/drop/5.png' + }); + + var greenIcon = new AMap.Icon({ + size: new AMap.Size(25, 34), + image: $('#context').val() + '/images/drop/6.png' + }); + + var handleDatePickers = function () { + + if (jQuery().datepicker) { + $('.date-picker').datepicker({ + rtl: App.isRTL() + }); + } + } + + function requestMarkers() { + if (markerData.length == 0&!hadRequest) { + hadRequest = true; + $.ajax({ + type: "get", + url: $('#context').val() + "/marker/all-point-list.do", + dataType: "json", +// async:false, + cache: false, + success: function (r) { + if (r.data) {//请求成功,将获取到的数据加载到地图上 + //1.解析返回的结果,.设置全局变量data的值 + markerData = [];//清空原来的数据 + for (var t = 0; t < r.data.length; t++) { + var markerDto = r.data[t]; + var emsBean = new EMSBean(markerDto.markerObjectType, markerDto.pipeMaterial, markerDto.pipeDiameter, markerDto.layStyle, + markerDto.depth, markerDto.belowType, markerDto.belowDepth, markerDto.belowDiameter, + markerDto.belowMaterial, markerDto.road, markerDto.constructTime, markerDto.ownerComp, + markerDto.markerObjectId, markerDto.markerId, markerDto.markerType, markerDto.markerDepth, + markerDto.creator, markerDto.createTime, markerDto.memo, markerDto.latitude, markerDto.longitude, + markerDto.recordType, markerDto.id,markerDto.line,markerDto.area,markerDto.colorType); + markerData[t] = emsBean; + } + //2.增加marker + EmsGd.addMarker(markerData); + } + hadRequest = false; + map.off("complete", requestMarkers()); + }, + error: function (d) {//请求出错 + hadRequest = false; + map.off("complete", requestMarkers()); + } + }); + } else if(!hadRequest){ + EmsGd.addMarker(markerData); + } + + } + + return { + + //添加标识器 + emsAddCallBack: function () { + $('#addModal').modal('show'); + }, + + //删除标识器 + emsDelCallBack: function () { + //绘制矩形区域: + if (drawOverlays.length == 0) { + swal("请先绘制区域", "", "warning"); + return; + } + + var pointArray = new Array(); + var readyToDel = ""; + for (var i = 0; i < drawOverlays.length; i++) { + var layer = drawOverlays[i]; + try { + // 生成判断是否在多边形内的数据格式 + var path = []; + for (var k = 0; k < layer.He.path.length; k++) { + var pos = []; + pos.push(layer.He.path[k].lng, layer.He.path[k].lat); + path.push(pos); + } + for (var j = 0; j < markerData.length; j++) { + var emsBean = markerData[j]; + var point = new AMap.LngLat(emsBean.longitude, emsBean.latitude); + var isPointInRing = AMap.GeometryUtil.isPointInRing(point, path); + if (isPointInRing) { + pointArray.push(point); + readyToDel = readyToDel + emsBean.id + ","; + } + } + } catch (e) { + swal("脚本异常", e.message, "error"); + } + if (pointArray.length <= 0) { + swal("选择区域没有要删除的点", "", "warning"); + for (var i in drawOverlays) { + map.remove(drawOverlays[i]); + } + return; + } + + swal({ + title: "是否确认删除?", + text: "删除是不可恢复的", + type: "warning", + showCancelButton: true, + confirmButtonText: "确认", + cancelButtonText: "取消", + closeOnConfirm: false + }, function() { + $.ajax({ + type: "get", + url: $('#context').val() + "/marker/delMarkerByIds.do", + dataType: "json", + cache: false, + data: { + "ids": readyToDel + }, + success: function (r) { + if (r.success) {//请求成功 + swal({ + title: "删除标识器成功", + text: "", + type: "success", + confirmButtonText: "确认", + closeOnConfirm: false + }, function() { + location.href = $('#context').val() + "/content/ems/ems-gd.jsp"; + }); + } + }, + error: function (d) {//请求出错 + swal("请求异常", d.responseText, "error"); + } + }); + }); + } + }, + + //保存标识器 + emsSaveCallBack: function () { + + if (readyToUploadMarkers.length == 0) { + return; + } + if (isSaveStatus) { + swal("保存过于频繁", "请稍后操作", "warning"); + return; + } + isSaveStatus = true; + //TODO LIST:上传 + var uploadMaker = new Array(); + for (var i = 0; i < readyToUploadMarkers.length; i++) { + var emsBean = readyToUploadMarkers[i].Tag; + + if (!emsBean.depth) { + emsBean.depth = 0; + } + uploadMaker.push(emsBean); + } + $.ajax({ + type: "get", + url: $('#context').val() + "/marker/batchSave.do", + dataType: "json", + cache: false, + data: { + markers: JSON.stringify(uploadMaker) + }, + success: function (r) { + if (r.success) {//请求成功 + swal({ + title: "保存标识器成功", + text: "", + type: "success", + confirmButtonText: "确认", + closeOnConfirm: false + }, function() { + location.href = $('#context').val() + "/content/ems/ems-gd.jsp"; + }); + } + }, + error: function (d) {//请求出错 + swal("请求出错", d.responseText, "error"); + isSaveStatus = false; + } + }); + }, + + emsUploadCallBack: function () { + // map.zoomTo(map.getZoom() + 2); + //TODO LIST:弹出对应的对话框 + $('#uploadModal').modal('show'); + }, + + emsExportCallBack: function () { + //TODO LIST:选择导出的文件 +// map.zoomTo(map.getZoom() + 2); + location.href = $('#context').val() + "/marker/export.do"; + + }, + + // 清除地图上所有后添加的标记点 + clearOverlays: function () { + mouseTool.close(true)//关闭,并清除覆盖物 + + for (var i = 0; i < drawOverlays.length; i++) { + map.remove(drawOverlays[i]); + } + for (var i = 0; i < readyToUploadMarkers.length; i++) { + map.remove(readyToUploadMarkers[i]); + } + for (var i = 0; i < vectorMarkers.length; i++) { + map.remove(vectorMarkers[i]); + } + + drawOverlays = []; + readyToUploadMarkers = []; + vectorMarkers = []; + }, + + initMap: function () { + + // 创建地图实例 + map = new AMap.Map("container", { + zoom: 13, + resizeEnable: true, + zooms: [4,18],//设置地图级别范围 + }); + + //声明全局变量 + if (!markerData || markerData.length == 0) { + markerData = new Array(); + } + + // 鼠标操作工具栏 + mouseTool = new AMap.MouseTool(map); + mouseTool.on('draw',function(e){ + drawOverlays.push(e.obj); + }) + + //加载完毕请求标识点信息 + map.on("complete", requestMarkers); + }, + + // 绘制区域矩形框 + drawRect: function () { + mouseTool.rectangle(); + }, + + //取消绘制区域矩形框 + moveMap: function () { + mouseTool.close(true)//关闭,并清除覆盖物 + }, + + initForm: function () { + handleDatePickers(); + $("#selectObjectType").chosen(); + $("#resetEms").live("click", function (e) { + $("#markerObjectType").val(""); + $("#pipeDiameter").val(""); + $("#pipeMaterial").val(""); + $("#belowPipeType").val(""); + $("#belowPipeDepth").val(""); + $("#belowPipeDiameter").val(""); + $("#belowPipeMaterial").val(""); + $("#pipeDepth").val(""); + $("#layStyle").val(""); + $("#line").val(""); + $("#area").val(""); + $("#road").val(""); + $("#constructTime").val(""); + $("#ownerComp").val(""); + $("#markerObjectId").val(""); + $("#markerId").val(""); + $("#markerType").val(""); + $("#markerDepth").val(""); + $("#creator").val(""); + $("#memo").val(""); + + }); + + $('#localize').click(function (e) { + $('#addModal').modal('hide'); + + //注册地图点击事件 + function showInfo(e) { + map.off("click", showInfo); + var lng = e.lnglat.lng; + var lat = e.lnglat.lat; + //TODO LIST:获取填写表单的信息 所属区域也需要保存的 + var selectObjectType = $("#selectObjectType").val();//判断是哪个类别 + var markerObjectType = $("#markerObjectType").val(); + var pipeDiameter = $("#pipeDiameter").val(); + var pipeMaterial = $("#pipeMaterial").val(); + var belowPipeType = $("#belowPipeType").val(); + var belowPipeDepth = $("#belowPipeDepth").val(); + var belowPipeDiameter = $("#belowPipeDiameter").val(); + var belowPipeMaterial = $("#belowPipeMaterial").val(); + var pipeDepth = $("#pipeDepth").val(); + var layStyle = $("#layStyle").val(); + var road = $("#road").val(); + var constructTime = $("#constructTime").val(); + var ownerComp = $("#ownerComp").val(); + var markerObjectId = $("#markerObjectId").val(); + var markerId = $("#markerId").val(); + var markerType = $("#markerType").val(); + var markerDepth = $("#markerDepth").val(); + var creator = $("#creator").val(); + var memo = $("#memo").val(); + var line = $("#line").val(); + var area = $("#area").val(); + var emsBean = new EMSBean(markerObjectType, pipeMaterial, pipeDiameter, layStyle, pipeDepth, belowPipeType, belowPipeDepth, belowPipeDiameter, belowPipeMaterial, + road, constructTime, ownerComp, markerObjectId, markerId, markerType, markerDepth, creator, null, memo, lat, lng, selectObjectType,null,line,area); + var marker = new AMap.Marker({ + position: [lng, lat], + draggable: true + }); + + marker.on("click", attribute); + marker.Tag = emsBean; + map.add(marker); //增加点 + readyToUploadMarkers.push(marker); + function attribute() { + var emsBean2 = marker.Tag; + var searchInfoWindow = null; + var msg = ""; + var height = 0; + var titleName =""; + if (emsBean.recordType == 1) { + titleName = "
                                            管线
                                            "; + msg = msg + "管线种类:" + emsBean2.markerObjectType + "
                                            " + + "管线直径(mm):" + emsBean2.pipeDiameter + "
                                            " + + "管线材质:" + emsBean2.pipeMaterial + "
                                            " + + "埋设方式:" + emsBean2.layStyle + "
                                            " + + "管线埋深(mm):" + emsBean2.depth + "
                                            "; + height = 100; + } else if (emsBean.recordType == 2) { + titleName = "
                                            管线附属物
                                            "; + msg = msg + "附属物名称:" + emsBean2.markerObjectType + "
                                            " + + "井深(mm):" + emsBean2.depth + "
                                            "; + height = 40; + } else if (emsBean.recordType == 3) { + titleName = "
                                            管线特征管点
                                            "; + msg = msg + "管点特征:" + emsBean2.markerObjectType + "
                                            " + + "特征点埋深(mm):" + emsBean2.depth + "
                                            "; + height = 40; + } else { + titleName = "
                                            交叉穿越点
                                            "; + msg = msg + "上层管种类:" + emsBean2.markerObjectType + "
                                            " + + "上层管埋深(mm):" + emsBean2.depth + "
                                            " + + "上层管直径(mm):" + emsBean2.pipeDiameter + "
                                            " + + "上层管材料:" + emsBean2.pipeMaterial + "
                                            " + + "下层管种类:" + emsBean2.belowType + "
                                            " + + "下层管埋深(mm):" + emsBean2.belowDepth + "
                                            "+ + "下层管直径(mm):" + emsBean2.belowDiameter + "
                                            " + + "下层管材料:" + emsBean2.belowMaterial + "
                                            " ; + height = 160; + } + height = height +225; + msg = msg + "所属区域:" + emsBean2.area + "
                                            " + + "所属线路:" + emsBean2.line + "
                                            " + + "所属道路:" + emsBean2.road + "
                                            " + + "建设年代:" + emsBean2.constructTime + "
                                            " + + "权属单位:" + emsBean2.ownerComp + "
                                            " + + "标识器ID:" + emsBean2.markerId + "
                                            " + + "标识器类型:" + emsBean2.markerType + "
                                            " + + "标识器埋深(mm):" + emsBean2.markerDepth + "
                                            " + + "安装部门:" + emsBean2.creator + "
                                            " + + "最后修改时间:"+emsBean2.createTime + "
                                            " + + "备注:" + emsBean2.memo + "
                                            "; + var imgUrl = $('#context').val() + "/images/ems.jpg"; + var content = titleName + '
                                            ' + + '' + msg + + '
                                            '; + + var infowindow = new AMap.AdvancedInfoWindow({ + content: content, + width: 290, //宽度 + height: height, //高度 + panel: "panel", //检索结果面板 + enableAutoPan: true //自动平移 + }); + + infowindow.open(map, [e.lnglat.lng, e.lnglat.lat]); + } + + } + map.on("click", showInfo); + }); + + $("#searchMarker").click(function (e) { + var Marker = {}; + if (vectorMarkers.length != 0) { + for (var i = 0; i < vectorMarkers.length; i++) { + map.remove(vectorMarkers[i]); + } + } + vectorMarkers = []; + Marker.road = $("#roadCondition").val(); + Marker.memo = $("#memoCondition").val(); + Marker.area = $("#select_area").val(); + Marker.line = $("#select_line").val(); + Marker.ownerComp = $("#company").val(); + Marker.creator = $("#department").val(); + Marker.sDate = $("#txt_begin_day").val(); + Marker.eDate = $("#txt_end_day").val(); + //请求后台的id列表,然后遍历marker列表,修改marker的颜色 + $.ajax({ + type: "POST", + url: $('#context').val() + "/marker/getMarkerListByCondition.do", + data: {"strMarkerDto": JSON.stringify(Marker)}, + dataType: "json", + success: function (r) { + if (r.data) { + var pointArray = new Array(); + if (r.data.length > 1000) { + swal("有超过一千个点符合筛选条件", "会造成浏览器卡顿,请重新选择", "warning"); + } else { + if (r.data.length == 0) { + swal("没有搜到符合条件的标识器", "请重新选择", "warning"); + return; + } + for (var a in r.data) {//遍历列表,添加marker + var vectorMarker = new AMap.Marker({ + position: [r.data[a].longitude,r.data[a].latitude], + size: new AMap.Size(30, 30), + icon: $('#context').val() + '/images/point.png' + }); + vectorMarkers.push(vectorMarker); + map.add(vectorMarker); + } + map.setFitView(vectorMarkers); + } + + } + }, + error: function (request) { + //提示错误信息 + swal("脚本异常", r.message, "error"); + } + }); + }); + + //控制不同种类对象的标签信息显示 + $("#selectObjectType").die().live("change", function (e) { + var type = $("#selectObjectType").val(); + OptionItemProcess.initPipeTypeList(type); + if (type == 1) {//管线 + $("#pipeTypeLabel").text("管线种类"); + $(".up-pipe").show(); + $("#pipeDiameterLabel").text("管线直径"); + $("#pipeMaterialLabel").text("管线材质"); + $(".below").addClass("hidden"); + $("#pipeDepthLabel").text("管线埋深"); + $(".pipeOnly").show(); + } else if (type == 2) {//管线附属物 + $("#pipeTypeLabel").text("附属物名称"); + $(".up-pipe").hide(); + $(".below").addClass("hidden"); + $("#pipeDepthLabel").text("井深"); + $(".pipeOnly").hide(); + } else if (type == 3) {//管线特征点 + $("#pipeTypeLabel").text("管点特征"); + $(".up-pipe").hide(); + $(".below").addClass("hidden"); + $("#pipeDepthLabel").text("特征点埋深"); + $(".pipeOnly").hide(); + } else {//交叉穿越点 + $("#pipeTypeLabel").text("上层管种类"); + $(".up-pipe").show(); + $("#pipeDiameterLabel").text("上层管直径"); + $("#pipeMaterialLabel").text("上层管材料"); + $(".below").removeClass("hidden"); + $("#pipeDepthLabel").text("上层管埋深"); + $(".pipeOnly").hide(); + } + }); + + OptionItemProcess.initPipeTypeList($("#selectObjectType").val()); + OptionItemProcess.initBelowPipeTypeList(); + OptionItemProcess.initAreaList(); + OptionItemProcess.initLayStyleList(); + OptionItemProcess.initMaterialList(); + }, + + initSelect: function () { + $("#selectObjectType").chosen(); + }, + + addMarker: function (data) { + for (var i = 0; i < data.length; i++) { + var icon = blueIcon; + var color = data[i].colorType; + if (color == "1") { + icon = orangeIcon; + } else if (color == "2") { + icon = redIcon; + } else if (color == "3") { + icon = blackIcon; + } else if (color == "4") { + icon = pinkIcon; + } else if (color == "5") { + icon = yellowIcon; + } else if (color == "6") { + icon = greenIcon; + } + + var marker = new AMap.Marker({ + position: [data[i].longitude, data[i].latitude], + icon: icon + }); + marker.Tag = data[i]; + + marker.on("click", function (e) { + + var emsBean = e.target.Tag; + var msg = ""; + var height = 0; + var titleName =""; + if (emsBean.recordType == 1) { + titleName = "
                                            管线
                                            "; + msg = msg + "管线种类:" + emsBean.markerObjectType + "
                                            " + + "管线直径(mm):" + emsBean.pipeDiameter + "
                                            " + + "管线材质:" + emsBean.pipeMaterial + "
                                            " + + "埋设方式:" + emsBean.layStyle + "
                                            " + + "管线埋深(mm):" + emsBean.depth + "
                                            "; + height = 100; + } else if (emsBean.recordType == 2) { + titleName = "
                                            管线附属物
                                            "; + msg = msg + "附属物名称:" + emsBean.markerObjectType + "
                                            " + + "井深(mm):" + emsBean.depth + "
                                            "; + height = 40; + } else if (emsBean.recordType == 3) { + titleName = "
                                            管线特征管点
                                            "; + msg = msg + "管点特征:" + emsBean.markerObjectType + "
                                            " + + "特征点埋深(mm):" + emsBean.depth + "
                                            "; + height = 40; + } else { + titleName = "
                                            交叉穿越点
                                            "; + msg = msg + "上层管种类:" + emsBean.markerObjectType + "
                                            " + + "上层管埋深(mm):" + emsBean.depth + "
                                            " + + "上层管直径(mm):" + emsBean.pipeDiameter + "
                                            " + + "上层管材料:" + emsBean.pipeMaterial + "
                                            " + + "下层管种类:" + emsBean.belowType + "
                                            " + + "下层管埋深(mm):" + emsBean.belowDepth + "
                                            "+ + "下层管直径(mm):" + emsBean.belowDiameter + "
                                            " + + "下层管材料:" + emsBean.belowMaterial + "
                                            " ; + height = 160; + } + height = height +225; + msg = msg + "所属区域:" + emsBean.area + "
                                            " + + "所属线路:" + emsBean.line + "
                                            " + + "所属道路:" + emsBean.road + "
                                            " + + "建设年代:" + emsBean.constructTime + "
                                            " + + "权属单位:" + emsBean.ownerComp + "
                                            " + + "标识器ID:" + emsBean.markerId + "
                                            " + + "标识器类型:" + emsBean.markerType + "
                                            " + + "标识器埋深(mm):" + emsBean.markerDepth + "
                                            " + + "安装部门:" + emsBean.creator + "
                                            " + + "最后修改时间:"+emsBean.createTime + "
                                            " + + "备注:" + emsBean.memo + "
                                            "; + var imgUrl = $('#context').val() + "/images/ems.jpg"; + var content = titleName + '
                                            ' + + '' + msg + + '
                                            '; + + var infowindow = new AMap.AdvancedInfoWindow({ + content: content, + width: 290, //宽度 + height: height, //高度 + panel: "panel", //检索结果面板 + enableAutoPan: true //自动平移 + }); + + infowindow.open(map, [e.lnglat.lng, e.lnglat.lat]); + }); + + map.add(marker); + } + } + }; +}(); \ No newline at end of file diff --git a/src/main/webapp/s/app/task/task-gd.js b/src/main/webapp/s/app/task/task-gd.js new file mode 100644 index 0000000..abf4da0 --- /dev/null +++ b/src/main/webapp/s/app/task/task-gd.js @@ -0,0 +1,689 @@ +/** + * Created by lenovo on 2016/4/13. + */ +//定义全局变量,缓存组织结构 + +var TaskGd = function () { + + var map = null; + var mouseTool = null; + var taskMarkers = ""; + var drawOverlays = new Array(); + var drawTaskOverlays = new Array(); + var drawEventOverlays = []; + var taskLists; + var taskDetailLists = new Array(); + var eventBeanList = []; + var viewPoints = []; + var markerData = []; + var hadRequest = false; + + var blueIcon = new AMap.Icon({ + size: new AMap.Size(25, 34), + image: $('#context').val() + '/images/drop/0.png' + }); + + var orangeIcon = new AMap.Icon({ + size: new AMap.Size(25, 34), + image: $('#context').val() + '/images/drop/1.png' + }); + + var redIcon = new AMap.Icon({ + size: new AMap.Size(25, 34), + image: $('#context').val() + '/images/drop/2.png' + }); + + var blackIcon = new AMap.Icon({ + size: new AMap.Size(25, 34), + image: $('#context').val() + '/images/drop/3.png' + }); + + var pinkIcon = new AMap.Icon({ + size: new AMap.Size(25, 34), + image: $('#context').val() + '/images/drop/4.png' + }); + + var yellowIcon = new AMap.Icon({ + size: new AMap.Size(25, 34), + image: $('#context').val() + '/images/drop/5.png' + }); + + var greenIcon = new AMap.Icon({ + size: new AMap.Size(25, 34), + image: $('#context').val() + '/images/drop/6.png' + }); + + // 历史工单列表属性 + var options = { + valueNames: [ 'id', 'patrolerName', 'status', 'deployDate', 'beginDate', 'endDate', 'description', {attr: 'src', name: 'image'} ], + item: '
                                          • ' + + '

                                            ' + + '

                                            ' + + '

                                            ' + + '

                                            ' + + '

                                            ' + + '

                                            ' + + '' + + '
                                            ' + + '
                                            ' + + '
                                          • ', + page: 3, + plugins: [ ListPagination({}) ] + }; + + // 清除所有绘制的区域图层 + function clearAll() { + for (var i = 0; i < drawOverlays.length; i++) { + map.remove(drawOverlays[i]); + } + drawOverlays.length = 0; + } + + // 清除工单任务绘制的标识器点 + function clearAllTaskPoint() { + for (var i = 0; i < drawTaskOverlays.length; i++) { + map.remove(drawTaskOverlays[i]); + } + drawTaskOverlays.length = 0; + taskDetailLists.length = 0; + } + + // 清除工单任务绘制的事件点 + function clearAllEventPoint() { + for (var i = 0; i < drawEventOverlays.length; i++) { + map.remove(drawEventOverlays[i]); + } +// drawEventOverlays.length = 0; + drawEventOverlays = []; + eventBeanList = []; + } + + // 查询巡检任务列表 + function getTaskInfo(patroler) { + taskLists.clear(); + $.ajax({ + type: "get", + url: $('#context').val() + "/task/get-task.do", + dataType: "json", + cache: false, + data: { + + }, + success: function (r) { + if (r.success) {//请求成功 + for (var data in r.data) { + var icon = $('#context').val() + "/images/accidents/worker.png"; + var id = r.data[data].id; + var patrolerName = r.data[data].patrolerName; + if (patroler && patrolerName != patroler) { + continue; + } + var description = r.data[data].description; + var deployDate = r.data[data].deployDate; + var beginDate = r.data[data].beginDate; + var endDate = r.data[data].endDate; + var status = r.data[data].status; + var creatorName = r.data[data].creatorName; + var task = new TaskBean(id, icon, patrolerName, description, deployDate, beginDate, endDate, status, creatorName); + + task.patrolerName = "巡检员:" + task.patrolerName; + task.description = "任务描述:" + task.description; + task.deployDate = "下发时间:" + task.deployDate; + task.beginDate = task.beginDate == null ? "开始时间:" : "开始时间:" + task.beginDate; + task.endDate = task.endDate == null ? "完成时间:" : "完成时间:" + task.endDate; + task.status = "任务状态:" + task.status; + taskLists.add(task); + } + } else { + swal("后台数据请求异常", r.message, "error"); + } + }, + error: function (d) {//请求出错 + swal("后台数据请求出错", d.responseText, "error"); + } + }); + } + + // 展示事件信息 + function showEventInfo(e) { + var p = e.target; + var imgName = p.Tag.imageName; + var images = imgName.split(",");//图片路径数组 +// alert(images[0]); + var msg2 = "事件描述:" + p.Tag.description + "
                                            " + + "上传时间:" + p.Tag.createTime + "
                                            "; + $("#eventImg").children().remove();//avatar1.jpg + var imageDivs="
                                            "; +// var imageDivs =""; + var width = 100/images.length;//动态展示 + $("#viewHelper").children().remove(); + for(var i =0;i" + + "
                                            " + + "
                                            " + +// "
                                            "+ +// ""+ +// ""+ +// " "+ +// ""+ +// "
                                            " + + "
                                            " + +// imageDivs +=""; + } + imageDivs+="" + $(".fancybox-close").die().live("click",function(){ + $('#eventModal').modal('show').css({width: "300px"}); + }); + $(".zoom-icon").die().live("click",function(){ + $('#eventModal').modal('hide'); + }); +// alert(eval(imageDivs)) + $("#eventImg").append(imageDivs) + $("#eventDescription").html(msg2); + $('#eventModal').modal('show').css({width: "300px"}); +// alert("showEventInfo:"+images); +// eventImgPage(images.length, 1, images); + + } + + // 获取标识器点 + function requestMarkers() { + if (markerData.length == 0&&!hadRequest) { + hadRequest = true; + $.ajax({ + type: "get", + url: $('#context').val() + "/marker/all-point-list.do", + dataType: "json", + cache: false, + success: function (r) { + if (r.data) {//请求成功,将获取到的数据加载到地图上 + //1.解析返回的结果,.设置全局变量data的值 + markerData = [];//清空原来的数据 + for (var t = 0; t < r.data.length; t++) { + var markerDto = r.data[t]; + var emsBean = new EMSBean(markerDto.markerObjectType, markerDto.pipeMaterial, markerDto.pipeDiameter, markerDto.layStyle, + markerDto.depth, markerDto.belowType, markerDto.belowDepth, markerDto.belowDiameter, + markerDto.belowMaterial, markerDto.road, markerDto.constructTime, markerDto.ownerComp, + markerDto.markerObjectId, markerDto.markerId, markerDto.markerType, markerDto.markerDepth, + markerDto.creator, markerDto.createTime, markerDto.memo, markerDto.latitude, markerDto.longitude, + markerDto.recordType, markerDto.id,markerDto.line,markerDto.area, markerDto.colorType); + markerData[t] = emsBean; + } + //2.增加marker + TaskGd.addMarker(markerData); + } + hadRequest = false; + map.off("complete", requestMarkers()); + + }, + error: function (d) {//请求出错 + hadRequest = false; + map.off("complete", requestMarkers()); + } + }); + } else if(!hadRequest){ + TaskGd.addMarker(markerData); + } + + } + return { + + //添加工单 + selectMarkerCallBack: function () { + //绘制矩形区域: + taskMarkers = ""; + if (drawOverlays.length == 0) { + swal("请先绘制区域", "", "warning"); + return; + } + for (var i = 0; i < drawOverlays.length; i++) { + var layer = drawOverlays[i]; + try { + // 生成判断是否在多边形内的数据格式 + var path = []; + for (var k = 0; k < layer.He.path.length; k++) { + var pos = []; + pos.push(layer.He.path[k].lng, layer.He.path[k].lat); + path.push(pos); + } + + for (var j = 0; j < markerData.length; j++) { + var emsBean = markerData[j]; + var point = new AMap.LngLat(emsBean.longitude, emsBean.latitude); + var isPointInRing = AMap.GeometryUtil.isPointInRing(point, path); + if (isPointInRing) { + taskMarkers = taskMarkers + emsBean.id + ","; + } + } + } catch (e) { + swal("脚本异常", e.message, "error"); + } + } + if (taskMarkers == "") { + swal("请选择标识器点!", "", "error"); + return; + } + + $('#addTaskModal2').modal('show'); + clearAll(); + }, + + //清除 + clearCallBack: function () { + taskMarkers = ""; + clearAll(); + }, + + //上传工单 + uploadTaskCallBack: function (patrolerId, description) { + $.ajax({ + type: "get", + url: $('#context').val() + "/task/task-Save.do", + dataType: "json", + cache: false, + data: { + markers: taskMarkers, + patrolerId: patrolerId, + description: description + }, + success: function (r) { + if (r.success) {//请求成功 + swal({ + title: "请求成功", + text: r.message, + type: "success", + confirmButtonText: "确认" + }, function() { + TaskGd.updateList(); + }); + } else { + swal("请求失败", r.message, "error"); + } + }, + error: function (d) {//请求出错 + swal("请求失败", d.message, "error"); + } + }); + }, + + // 初始化地图 + initMap: function () { + + map = new AMap.Map("container", { + zoom: 13, + resizeEnable: true, + zooms: [4,18],//设置地图级别范围 + }); + + //声明全局变量 + if (!markerData || markerData.length == 0) { + markerData = new Array(); + } + + // 鼠标操作工具栏 + mouseTool = new AMap.MouseTool(map); + mouseTool.on('draw',function(e){ + drawOverlays.push(e.obj); + }); + + //加载完毕请求标识点信息 + map.on("complete", requestMarkers); + }, + + initList: function () { + taskLists = new List('worksheets', options); + TaskGd.updateList(); + //$('.sort').click(); + $('#btnSort').trigger("click"); + $('#btnSort').trigger("click"); + + $('#btnSort').css("padding", 0); + $('#btnSort').css("padding-left", 10); + $('#btnSort').css("padding-right", 15); + $('#btnSort').css("margin-bottom", 10); + + TaskGd.bindClickEvent(); + + $('#selectPatroler3').live('change', function (e) {//下拉列表更改的时候查询数据,更新列表,待优化为查询条件在后台利用 + TaskGd.updateList($("#selectPatroler3").val()); + }); + }, + + // 绑定任务列表单击事件 + bindClickEvent: function () { + $('#worksheets ul li').live('click', function (e) { + viewPoints = []; + if (null == this.getElementsByClassName("id")[0]) { + return; + } + clearAllTaskPoint(); + clearAllEventPoint(); + var taskId = this.getElementsByClassName("id")[0].innerHTML; + var i = 0; + //请求任务 + $.ajax({ + type: "get", + url: $('#context').val() + "/task/get-task-markers.do", + dataType: "json", + async:false, + cache: false, + data: { + taskId: taskId + }, + success: function (r) { + if (r.success) {//请求成功 + for (var data in r.data) { + var id = r.data[data].id; + var markerName = r.data[data].markerIdReal; + var latitude = r.data[data].latitude; + var longitude = r.data[data].longitude; + var finishTime = r.data[data].finishTime == null ? "" : r.data[data].finishTime; + var description = r.data[data].description == null ? "" : r.data[data].description; + var status = r.data[data].isChecked; + var icon = ""; + var isChecked = ""; + if (status == 0) { + icon = $('#context').val() + "/images/point-task.png"; + isChecked = "未巡检"; + } + else { + icon = $('#context').val() + "/images/point.png"; + isChecked = "已巡检"; + } + + var taskDetailBean = new TaskDetailBean(id, icon, markerName, latitude, longitude, isChecked, finishTime, description); + taskDetailLists.push(taskDetailBean); + + } + TaskGd.addTaskDetailMarker(taskDetailLists); + } + else { + alert(r.message); + } + }, + error: function (d) {//请求出错 + alert(d.message); + } + }); + + //请求该任务上报的事件 + $.ajax({ + type: "get", + url: $('#context').val() + "/event/get-event-list.do", + dataType: "json", + cache: false, + async:false, + data: { + taskId: taskId + }, + success: function (r) { + if (r.success) {//请求成功 + for (var data in r.data) { + var id = r.data[data].id; + var imageName = r.data[data].imageName; + var latitude = r.data[data].latitude; + var longitude = r.data[data].longitude; + var createTime = r.data[data].createTime == null ? "" : r.data[data].createTime; + var description = r.data[data].description == null ? "" : r.data[data].description; + var status = r.data[data].status; + var eventBean = new EventBean(id, imageName, latitude, longitude, description, status, createTime); + + eventBeanList.push(eventBean); + + } + TaskGd.addEventMarker(eventBeanList); + } + else { + alert(r.message); + } + }, + error: function (d) {//请求出错 + alert(d.message); + } + }); + + map.setFitView(viewPoints); + + }); + + }, + + /* + * 增加报警信息到列表 + * */ + updateList: function (patroler) { + getTaskInfo(patroler); + }, + + // 初始化表单操作 + initForm: function () { + $("#saveTask2").click(function (e) { + //alert(taskMarkers); + var patrolerId = $("#selectPatroler2").val(); + var description = $("#description2").val(); + TaskGd.uploadTaskCallBack(patrolerId, description); + $('#addTaskModal2').modal('hide'); + $("#description2").val(""); + }); + }, + + //获取巡检员列表 + initPatrolerArray: function () { + + $.ajax({ + type: "POST", + url: $('#context').val() + "/user/get-patroler.do", + data: {}, + dataType: "json", + success: function (r) { + //获取面的列表,将下拉列表初始化 + if (r.data) { + for (var user in r.data) { + //alert(r.data[user].id+":"+r.data[user].userName); + $("#selectPatroler").append(" "); + $("#selectPatroler2").append(" "); + $("#selectPatroler3").append(" "); + } + $("#selectPatroler").chosen(); + $("#selectPatroler2").chosen(); + $("#selectPatroler3").chosen(); + } + }, + error: function (d) { + //提示错误信息 + swal("请求巡检员列表出错", d.responseText, "error"); + } + }); + + }, + + // 绘制区域矩形框 + drawRect: function () { + mouseTool.rectangle(); + }, + + //取消绘制区域矩形框 + moveMap: function () { + mouseTool.close(true)//关闭,并清除覆盖物 + }, + + //初始化下拉列表框 + initSelect: function () { + TaskGd.initPatrolerArray(); + }, + + // 显示标识器点 + addMarker: function (data) { + for (var i = 0; i < data.length; i++) { + var icon = blueIcon; + var color = data[i].colorType; + if (color == "1") { + icon = orangeIcon; + } else if (color == "2") { + icon = redIcon; + } else if (color == "3") { + icon = blackIcon; + } else if (color == "4") { + icon = pinkIcon; + } else if (color == "5") { + icon = yellowIcon; + } else if (color == "6") { + icon = greenIcon; + } + + var marker = new AMap.Marker({ + position: [data[i].longitude, data[i].latitude], + icon: icon + }); + marker.Tag = data[i]; + + marker.on("click", function (e) { + + var emsBean = e.target.Tag; + var msg = ""; + var height = 0; + var titleName =""; + if (emsBean.recordType == 1) { + titleName = "
                                            管线
                                            "; + msg = msg + "管线种类:" + emsBean.markerObjectType + "
                                            " + + "管线直径(mm):" + emsBean.pipeDiameter + "
                                            " + + "管线材质:" + emsBean.pipeMaterial + "
                                            " + + "埋设方式:" + emsBean.layStyle + "
                                            " + + "管线埋深(mm):" + emsBean.depth + "
                                            "; + height = 100; + } else if (emsBean.recordType == 2) { + titleName = "
                                            管线附属物
                                            "; + msg = msg + "附属物名称:" + emsBean.markerObjectType + "
                                            " + + "井深(mm):" + emsBean.depth + "
                                            "; + height = 40; + } else if (emsBean.recordType == 3) { + titleName = "
                                            管线特征管点
                                            "; + msg = msg + "管点特征:" + emsBean.markerObjectType + "
                                            " + + "特征点埋深(mm):" + emsBean.depth + "
                                            "; + height = 40; + } else { + titleName = "
                                            交叉穿越点
                                            "; + msg = msg + "上层管种类:" + emsBean.markerObjectType + "
                                            " + + "上层管埋深(mm):" + emsBean.depth + "
                                            " + + "上层管直径(mm):" + emsBean.pipeDiameter + "
                                            " + + "上层管材料:" + emsBean.pipeMaterial + "
                                            " + + "下层管种类:" + emsBean.belowType + "
                                            " + + "下层管埋深(mm):" + emsBean.belowDepth + "
                                            "+ + "下层管直径(mm):" + emsBean.belowDiameter + "
                                            " + + "下层管材料:" + emsBean.belowMaterial + "
                                            " ; + height = 160; + } + height = height +225; + msg = msg + "所属区域:" + emsBean.area + "
                                            " + + "所属线路:" + emsBean.line + "
                                            " + + "所属道路:" + emsBean.road + "
                                            " + + "建设年代:" + emsBean.constructTime + "
                                            " + + "权属单位:" + emsBean.ownerComp + "
                                            " + + "标识器ID:" + emsBean.markerId + "
                                            " + + "标识器类型:" + emsBean.markerType + "
                                            " + + "标识器埋深(mm):" + emsBean.markerDepth + "
                                            " + + "安装部门:" + emsBean.creator + "
                                            " + + "最后修改时间:"+emsBean.createTime + "
                                            " + + "备注:" + emsBean.memo + "
                                            "; + var imgUrl = $('#context').val() + "/images/ems.jpg"; + var content = titleName + '
                                            ' + + '' + msg + + '
                                            '; + + var infowindow = new AMap.AdvancedInfoWindow({ + content: content, + width: 290, //宽度 + height: height, //高度 + panel: "panel", //检索结果面板 + enableAutoPan: true //自动平移 + }); + + infowindow.open(map, [e.lnglat.lng, e.lnglat.lat]); + }); + + map.add(marker); + } + }, + + //增加事件图片的marker + addEventMarker: function () { + console.log(eventBeanList); + for (var i = 0; i < eventBeanList.length; i++) { + var eventMarker = new AMap.Marker({ + position: [eventBeanList[i].longitude, eventBeanList[i].latitude], + size: new AMap.Size(30, 30), + icon: new AMap.Icon({ + size: new AMap.Size(38, 38), + image: $('#context').val() + "/images/events/red_icon.png" + }) + }); + + var msg = "事件描述:" + eventBeanList[i].description + "\r\n" + + "上传时间:" + eventBeanList[i].createTime + "\r\n"; + eventMarker.setTitle(msg); + eventMarker.Tag = eventBeanList[i]; + viewPoints.push(eventMarker); + eventMarker.on("click", showEventInfo); + map.add(eventMarker); // 将标注添加到地图中 + drawEventOverlays.push(eventMarker); + } + }, + + // 点击任务列表绘制任务对应的标识器点 + addTaskDetailMarker: function (data) { + for (var i = 0; i < data.length; i++) { + var msg = "标识器名称:" + data[i].markerName + "\r\n" + + "巡检状态:" + data[i].isChecked + "\r\n" + + "巡检时间:" + data[i].finishTime + "\r\n" + + "描述:" + data[i].description + "\r\n"; + + var marker = new AMap.Marker({ + position: [data[i].longitude, data[i].latitude], + size: new AMap.Size(30, 30), + icon: data[i].icon + }); + + marker.setTitle(msg); + + viewPoints.push(marker); + drawTaskOverlays.push(marker); + map.add(marker); // 将标注添加到地图中 + } + } + }; +}(); + +TaskBean = function (id, icon, patrolerName, description, deployDate, beginDate, endDate, status, creatorName) { + this.id = id; + this.image = icon; + this.patrolerName = patrolerName; + this.description = description; + this.deployDate = deployDate; + this.beginDate = beginDate; + this.endDate = endDate; + this.status = status; + this.creatorName = creatorName; +}; + +TaskDetailBean = function (id, icon, markerName, latitude, longitude, isChecked, finishTime, description) { + this.id = id; + this.icon = icon; + this.markerName = markerName; + this.latitude = latitude; + this.longitude = longitude; + this.isChecked = isChecked; + this.finishTime = finishTime; + this.description = description; +}; + +EventBean = function (id, imageName, latitude, longitude, description, status, createTime) { + this.id = id; + this.imageName = imageName; + this.latitude = latitude; + this.longitude = longitude; + this.description = description; + this.status = status; + this.createTime = createTime; +} \ No newline at end of file diff --git a/src/main/webapp/s/media/css/sweetalert.css b/src/main/webapp/s/media/css/sweetalert.css new file mode 100644 index 0000000..f2af7e3 --- /dev/null +++ b/src/main/webapp/s/media/css/sweetalert.css @@ -0,0 +1,935 @@ +body.stop-scrolling { + height: 100%; + overflow: hidden; } + +.sweet-overlay { + background-color: black; + /* IE8 */ + -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=40)"; + /* IE8 */ + background-color: rgba(0, 0, 0, 0.4); + position: fixed; + left: 0; + right: 0; + top: 0; + bottom: 0; + display: none; + z-index: 10000; } + +.sweet-alert { + background-color: white; + font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif; + width: 478px; + padding: 17px; + border-radius: 5px; + text-align: center; + position: fixed; + left: 50%; + top: 50%; + margin-left: -256px; + margin-top: -200px; + overflow: hidden; + display: none; + z-index: 99999; } + @media all and (max-width: 540px) { + .sweet-alert { + width: auto; + margin-left: 0; + margin-right: 0; + left: 15px; + right: 15px; } } + .sweet-alert h2 { + color: #575757; + font-size: 30px; + text-align: center; + font-weight: 600; + text-transform: none; + position: relative; + margin: 25px 0; + padding: 0; + line-height: 40px; + display: block; } + .sweet-alert p { + color: #797979; + font-size: 16px; + text-align: center; + font-weight: 300; + position: relative; + text-align: inherit; + float: none; + margin: 0; + padding: 0; + line-height: normal; } + .sweet-alert fieldset { + border: none; + position: relative; } + .sweet-alert .sa-error-container { + background-color: #f1f1f1; + margin-left: -17px; + margin-right: -17px; + overflow: hidden; + padding: 0 10px; + max-height: 0; + webkit-transition: padding 0.15s, max-height 0.15s; + transition: padding 0.15s, max-height 0.15s; } + .sweet-alert .sa-error-container.show { + padding: 10px 0; + max-height: 100px; + webkit-transition: padding 0.2s, max-height 0.2s; + transition: padding 0.25s, max-height 0.25s; } + .sweet-alert .sa-error-container .icon { + display: inline-block; + width: 24px; + height: 24px; + border-radius: 50%; + background-color: #ea7d7d; + color: white; + line-height: 24px; + text-align: center; + margin-right: 3px; } + .sweet-alert .sa-error-container p { + display: inline-block; } + .sweet-alert .sa-input-error { + position: absolute; + top: 29px; + right: 26px; + width: 20px; + height: 20px; + opacity: 0; + -webkit-transform: scale(0.5); + transform: scale(0.5); + -webkit-transform-origin: 50% 50%; + transform-origin: 50% 50%; + -webkit-transition: all 0.1s; + transition: all 0.1s; } + .sweet-alert .sa-input-error::before, .sweet-alert .sa-input-error::after { + content: ""; + width: 20px; + height: 6px; + background-color: #f06e57; + border-radius: 3px; + position: absolute; + top: 50%; + margin-top: -4px; + left: 50%; + margin-left: -9px; } + .sweet-alert .sa-input-error::before { + -webkit-transform: rotate(-45deg); + transform: rotate(-45deg); } + .sweet-alert .sa-input-error::after { + -webkit-transform: rotate(45deg); + transform: rotate(45deg); } + .sweet-alert .sa-input-error.show { + opacity: 1; + -webkit-transform: scale(1); + transform: scale(1); } + .sweet-alert input { + width: 100%; + box-sizing: border-box; + border-radius: 3px; + border: 1px solid #d7d7d7; + height: 43px; + margin-top: 10px; + margin-bottom: 17px; + font-size: 18px; + box-shadow: inset 0px 1px 1px rgba(0, 0, 0, 0.06); + padding: 0 12px; + display: none; + -webkit-transition: all 0.3s; + transition: all 0.3s; } + .sweet-alert input:focus { + outline: none; + box-shadow: 0px 0px 3px #c4e6f5; + border: 1px solid #b4dbed; } + .sweet-alert input:focus::-moz-placeholder { + transition: opacity 0.3s 0.03s ease; + opacity: 0.5; } + .sweet-alert input:focus:-ms-input-placeholder { + transition: opacity 0.3s 0.03s ease; + opacity: 0.5; } + .sweet-alert input:focus::-webkit-input-placeholder { + transition: opacity 0.3s 0.03s ease; + opacity: 0.5; } + .sweet-alert input::-moz-placeholder { + color: #bdbdbd; } + .sweet-alert input::-ms-clear { + display: none; } + .sweet-alert input:-ms-input-placeholder { + color: #bdbdbd; } + .sweet-alert input::-webkit-input-placeholder { + color: #bdbdbd; } + .sweet-alert.show-input input { + display: block; } + .sweet-alert .sa-confirm-button-container { + display: inline-block; + position: relative; } + .sweet-alert .la-ball-fall { + position: absolute; + left: 50%; + top: 50%; + margin-left: -27px; + margin-top: 4px; + opacity: 0; + visibility: hidden; } + .sweet-alert button { + background-color: #8CD4F5; + color: white; + border: none; + box-shadow: none; + font-size: 17px; + font-weight: 500; + -webkit-border-radius: 4px; + border-radius: 5px; + padding: 10px 32px; + margin: 26px 5px 0 5px; + cursor: pointer; } + .sweet-alert button:focus { + outline: none; + box-shadow: 0 0 2px rgba(128, 179, 235, 0.5), inset 0 0 0 1px rgba(0, 0, 0, 0.05); } + .sweet-alert button:hover { + background-color: #7ecff4; } + .sweet-alert button:active { + background-color: #5dc2f1; } + .sweet-alert button.cancel { + background-color: #C1C1C1; } + .sweet-alert button.cancel:hover { + background-color: #b9b9b9; } + .sweet-alert button.cancel:active { + background-color: #a8a8a8; } + .sweet-alert button.cancel:focus { + box-shadow: rgba(197, 205, 211, 0.8) 0px 0px 2px, rgba(0, 0, 0, 0.0470588) 0px 0px 0px 1px inset !important; } + .sweet-alert button[disabled] { + opacity: .6; + cursor: default; } + .sweet-alert button.confirm[disabled] { + color: transparent; } + .sweet-alert button.confirm[disabled] ~ .la-ball-fall { + opacity: 1; + visibility: visible; + transition-delay: 0s; } + .sweet-alert button::-moz-focus-inner { + border: 0; } + .sweet-alert[data-has-cancel-button=false] button { + box-shadow: none !important; } + .sweet-alert[data-has-confirm-button=false][data-has-cancel-button=false] { + padding-bottom: 40px; } + .sweet-alert .sa-icon { + width: 80px; + height: 80px; + border: 4px solid gray; + -webkit-border-radius: 40px; + border-radius: 40px; + border-radius: 50%; + margin: 20px auto; + padding: 0; + position: relative; + box-sizing: content-box; } + .sweet-alert .sa-icon.sa-error { + border-color: #F27474; } + .sweet-alert .sa-icon.sa-error .sa-x-mark { + position: relative; + display: block; } + .sweet-alert .sa-icon.sa-error .sa-line { + position: absolute; + height: 5px; + width: 47px; + background-color: #F27474; + display: block; + top: 37px; + border-radius: 2px; } + .sweet-alert .sa-icon.sa-error .sa-line.sa-left { + -webkit-transform: rotate(45deg); + transform: rotate(45deg); + left: 17px; } + .sweet-alert .sa-icon.sa-error .sa-line.sa-right { + -webkit-transform: rotate(-45deg); + transform: rotate(-45deg); + right: 16px; } + .sweet-alert .sa-icon.sa-warning { + border-color: #F8BB86; } + .sweet-alert .sa-icon.sa-warning .sa-body { + position: absolute; + width: 5px; + height: 47px; + left: 50%; + top: 10px; + -webkit-border-radius: 2px; + border-radius: 2px; + margin-left: -2px; + background-color: #F8BB86; } + .sweet-alert .sa-icon.sa-warning .sa-dot { + position: absolute; + width: 7px; + height: 7px; + -webkit-border-radius: 50%; + border-radius: 50%; + margin-left: -3px; + left: 50%; + bottom: 10px; + background-color: #F8BB86; } + .sweet-alert .sa-icon.sa-info { + border-color: #C9DAE1; } + .sweet-alert .sa-icon.sa-info::before { + content: ""; + position: absolute; + width: 5px; + height: 29px; + left: 50%; + bottom: 17px; + border-radius: 2px; + margin-left: -2px; + background-color: #C9DAE1; } + .sweet-alert .sa-icon.sa-info::after { + content: ""; + position: absolute; + width: 7px; + height: 7px; + border-radius: 50%; + margin-left: -3px; + top: 19px; + background-color: #C9DAE1; + left: 50%; } + .sweet-alert .sa-icon.sa-success { + border-color: #A5DC86; } + .sweet-alert .sa-icon.sa-success::before, .sweet-alert .sa-icon.sa-success::after { + content: ''; + -webkit-border-radius: 40px; + border-radius: 40px; + border-radius: 50%; + position: absolute; + width: 60px; + height: 120px; + background: white; + -webkit-transform: rotate(45deg); + transform: rotate(45deg); } + .sweet-alert .sa-icon.sa-success::before { + -webkit-border-radius: 120px 0 0 120px; + border-radius: 120px 0 0 120px; + top: -7px; + left: -33px; + -webkit-transform: rotate(-45deg); + transform: rotate(-45deg); + -webkit-transform-origin: 60px 60px; + transform-origin: 60px 60px; } + .sweet-alert .sa-icon.sa-success::after { + -webkit-border-radius: 0 120px 120px 0; + border-radius: 0 120px 120px 0; + top: -11px; + left: 30px; + -webkit-transform: rotate(-45deg); + transform: rotate(-45deg); + -webkit-transform-origin: 0px 60px; + transform-origin: 0px 60px; } + .sweet-alert .sa-icon.sa-success .sa-placeholder { + width: 80px; + height: 80px; + border: 4px solid rgba(165, 220, 134, 0.2); + -webkit-border-radius: 40px; + border-radius: 40px; + border-radius: 50%; + box-sizing: content-box; + position: absolute; + left: -4px; + top: -4px; + z-index: 2; } + .sweet-alert .sa-icon.sa-success .sa-fix { + width: 5px; + height: 90px; + background-color: white; + position: absolute; + left: 28px; + top: 8px; + z-index: 1; + -webkit-transform: rotate(-45deg); + transform: rotate(-45deg); } + .sweet-alert .sa-icon.sa-success .sa-line { + height: 5px; + background-color: #A5DC86; + display: block; + border-radius: 2px; + position: absolute; + z-index: 2; } + .sweet-alert .sa-icon.sa-success .sa-line.sa-tip { + width: 25px; + left: 14px; + top: 46px; + -webkit-transform: rotate(45deg); + transform: rotate(45deg); } + .sweet-alert .sa-icon.sa-success .sa-line.sa-long { + width: 47px; + right: 8px; + top: 38px; + -webkit-transform: rotate(-45deg); + transform: rotate(-45deg); } + .sweet-alert .sa-icon.sa-custom { + background-size: contain; + border-radius: 0; + border: none; + background-position: center center; + background-repeat: no-repeat; } + +/* + * Animations + */ +@-webkit-keyframes showSweetAlert { + 0% { + transform: scale(0.7); + -webkit-transform: scale(0.7); } + 45% { + transform: scale(1.05); + -webkit-transform: scale(1.05); } + 80% { + transform: scale(0.95); + -webkit-transform: scale(0.95); } + 100% { + transform: scale(1); + -webkit-transform: scale(1); } } + +@keyframes showSweetAlert { + 0% { + transform: scale(0.7); + -webkit-transform: scale(0.7); } + 45% { + transform: scale(1.05); + -webkit-transform: scale(1.05); } + 80% { + transform: scale(0.95); + -webkit-transform: scale(0.95); } + 100% { + transform: scale(1); + -webkit-transform: scale(1); } } + +@-webkit-keyframes hideSweetAlert { + 0% { + transform: scale(1); + -webkit-transform: scale(1); } + 100% { + transform: scale(0.5); + -webkit-transform: scale(0.5); } } + +@keyframes hideSweetAlert { + 0% { + transform: scale(1); + -webkit-transform: scale(1); } + 100% { + transform: scale(0.5); + -webkit-transform: scale(0.5); } } + +@-webkit-keyframes slideFromTop { + 0% { + top: 0%; } + 100% { + top: 50%; } } + +@keyframes slideFromTop { + 0% { + top: 0%; } + 100% { + top: 50%; } } + +@-webkit-keyframes slideToTop { + 0% { + top: 50%; } + 100% { + top: 0%; } } + +@keyframes slideToTop { + 0% { + top: 50%; } + 100% { + top: 0%; } } + +@-webkit-keyframes slideFromBottom { + 0% { + top: 70%; } + 100% { + top: 50%; } } + +@keyframes slideFromBottom { + 0% { + top: 70%; } + 100% { + top: 50%; } } + +@-webkit-keyframes slideToBottom { + 0% { + top: 50%; } + 100% { + top: 70%; } } + +@keyframes slideToBottom { + 0% { + top: 50%; } + 100% { + top: 70%; } } + +.showSweetAlert[data-animation=pop] { + -webkit-animation: showSweetAlert 0.3s; + animation: showSweetAlert 0.3s; } + +.showSweetAlert[data-animation=none] { + -webkit-animation: none; + animation: none; } + +.showSweetAlert[data-animation=slide-from-top] { + -webkit-animation: slideFromTop 0.3s; + animation: slideFromTop 0.3s; } + +.showSweetAlert[data-animation=slide-from-bottom] { + -webkit-animation: slideFromBottom 0.3s; + animation: slideFromBottom 0.3s; } + +.hideSweetAlert[data-animation=pop] { + -webkit-animation: hideSweetAlert 0.2s; + animation: hideSweetAlert 0.2s; } + +.hideSweetAlert[data-animation=none] { + -webkit-animation: none; + animation: none; } + +.hideSweetAlert[data-animation=slide-from-top] { + -webkit-animation: slideToTop 0.4s; + animation: slideToTop 0.4s; } + +.hideSweetAlert[data-animation=slide-from-bottom] { + -webkit-animation: slideToBottom 0.3s; + animation: slideToBottom 0.3s; } + +@-webkit-keyframes animateSuccessTip { + 0% { + width: 0; + left: 1px; + top: 19px; } + 54% { + width: 0; + left: 1px; + top: 19px; } + 70% { + width: 50px; + left: -8px; + top: 37px; } + 84% { + width: 17px; + left: 21px; + top: 48px; } + 100% { + width: 25px; + left: 14px; + top: 45px; } } + +@keyframes animateSuccessTip { + 0% { + width: 0; + left: 1px; + top: 19px; } + 54% { + width: 0; + left: 1px; + top: 19px; } + 70% { + width: 50px; + left: -8px; + top: 37px; } + 84% { + width: 17px; + left: 21px; + top: 48px; } + 100% { + width: 25px; + left: 14px; + top: 45px; } } + +@-webkit-keyframes animateSuccessLong { + 0% { + width: 0; + right: 46px; + top: 54px; } + 65% { + width: 0; + right: 46px; + top: 54px; } + 84% { + width: 55px; + right: 0px; + top: 35px; } + 100% { + width: 47px; + right: 8px; + top: 38px; } } + +@keyframes animateSuccessLong { + 0% { + width: 0; + right: 46px; + top: 54px; } + 65% { + width: 0; + right: 46px; + top: 54px; } + 84% { + width: 55px; + right: 0px; + top: 35px; } + 100% { + width: 47px; + right: 8px; + top: 38px; } } + +@-webkit-keyframes rotatePlaceholder { + 0% { + transform: rotate(-45deg); + -webkit-transform: rotate(-45deg); } + 5% { + transform: rotate(-45deg); + -webkit-transform: rotate(-45deg); } + 12% { + transform: rotate(-405deg); + -webkit-transform: rotate(-405deg); } + 100% { + transform: rotate(-405deg); + -webkit-transform: rotate(-405deg); } } + +@keyframes rotatePlaceholder { + 0% { + transform: rotate(-45deg); + -webkit-transform: rotate(-45deg); } + 5% { + transform: rotate(-45deg); + -webkit-transform: rotate(-45deg); } + 12% { + transform: rotate(-405deg); + -webkit-transform: rotate(-405deg); } + 100% { + transform: rotate(-405deg); + -webkit-transform: rotate(-405deg); } } + +.animateSuccessTip { + -webkit-animation: animateSuccessTip 0.75s; + animation: animateSuccessTip 0.75s; } + +.animateSuccessLong { + -webkit-animation: animateSuccessLong 0.75s; + animation: animateSuccessLong 0.75s; } + +.sa-icon.sa-success.animate::after { + -webkit-animation: rotatePlaceholder 4.25s ease-in; + animation: rotatePlaceholder 4.25s ease-in; } + +@-webkit-keyframes animateErrorIcon { + 0% { + transform: rotateX(100deg); + -webkit-transform: rotateX(100deg); + opacity: 0; } + 100% { + transform: rotateX(0deg); + -webkit-transform: rotateX(0deg); + opacity: 1; } } + +@keyframes animateErrorIcon { + 0% { + transform: rotateX(100deg); + -webkit-transform: rotateX(100deg); + opacity: 0; } + 100% { + transform: rotateX(0deg); + -webkit-transform: rotateX(0deg); + opacity: 1; } } + +.animateErrorIcon { + -webkit-animation: animateErrorIcon 0.5s; + animation: animateErrorIcon 0.5s; } + +@-webkit-keyframes animateXMark { + 0% { + transform: scale(0.4); + -webkit-transform: scale(0.4); + margin-top: 26px; + opacity: 0; } + 50% { + transform: scale(0.4); + -webkit-transform: scale(0.4); + margin-top: 26px; + opacity: 0; } + 80% { + transform: scale(1.15); + -webkit-transform: scale(1.15); + margin-top: -6px; } + 100% { + transform: scale(1); + -webkit-transform: scale(1); + margin-top: 0; + opacity: 1; } } + +@keyframes animateXMark { + 0% { + transform: scale(0.4); + -webkit-transform: scale(0.4); + margin-top: 26px; + opacity: 0; } + 50% { + transform: scale(0.4); + -webkit-transform: scale(0.4); + margin-top: 26px; + opacity: 0; } + 80% { + transform: scale(1.15); + -webkit-transform: scale(1.15); + margin-top: -6px; } + 100% { + transform: scale(1); + -webkit-transform: scale(1); + margin-top: 0; + opacity: 1; } } + +.animateXMark { + -webkit-animation: animateXMark 0.5s; + animation: animateXMark 0.5s; } + +@-webkit-keyframes pulseWarning { + 0% { + border-color: #F8D486; } + 100% { + border-color: #F8BB86; } } + +@keyframes pulseWarning { + 0% { + border-color: #F8D486; } + 100% { + border-color: #F8BB86; } } + +.pulseWarning { + -webkit-animation: pulseWarning 0.75s infinite alternate; + animation: pulseWarning 0.75s infinite alternate; } + +@-webkit-keyframes pulseWarningIns { + 0% { + background-color: #F8D486; } + 100% { + background-color: #F8BB86; } } + +@keyframes pulseWarningIns { + 0% { + background-color: #F8D486; } + 100% { + background-color: #F8BB86; } } + +.pulseWarningIns { + -webkit-animation: pulseWarningIns 0.75s infinite alternate; + animation: pulseWarningIns 0.75s infinite alternate; } + +@-webkit-keyframes rotate-loading { + 0% { + transform: rotate(0deg); } + 100% { + transform: rotate(360deg); } } + +@keyframes rotate-loading { + 0% { + transform: rotate(0deg); } + 100% { + transform: rotate(360deg); } } + +/* Internet Explorer 9 has some special quirks that are fixed here */ +/* The icons are not animated. */ +/* This file is automatically merged into sweet-alert.min.js through Gulp */ +/* Error icon */ +.sweet-alert .sa-icon.sa-error .sa-line.sa-left { + -ms-transform: rotate(45deg) \9; } + +.sweet-alert .sa-icon.sa-error .sa-line.sa-right { + -ms-transform: rotate(-45deg) \9; } + +/* Success icon */ +.sweet-alert .sa-icon.sa-success { + border-color: transparent\9; } + +.sweet-alert .sa-icon.sa-success .sa-line.sa-tip { + -ms-transform: rotate(45deg) \9; } + +.sweet-alert .sa-icon.sa-success .sa-line.sa-long { + -ms-transform: rotate(-45deg) \9; } + +/*! + * Load Awesome v1.1.0 (http://github.danielcardoso.net/load-awesome/) + * Copyright 2015 Daniel Cardoso <@DanielCardoso> + * Licensed under MIT + */ +.la-ball-fall, +.la-ball-fall > div { + position: relative; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; } + +.la-ball-fall { + display: block; + font-size: 0; + color: #fff; } + +.la-ball-fall.la-dark { + color: #333; } + +.la-ball-fall > div { + display: inline-block; + float: none; + background-color: currentColor; + border: 0 solid currentColor; } + +.la-ball-fall { + width: 54px; + height: 18px; } + +.la-ball-fall > div { + width: 10px; + height: 10px; + margin: 4px; + border-radius: 100%; + opacity: 0; + -webkit-animation: ball-fall 1s ease-in-out infinite; + -moz-animation: ball-fall 1s ease-in-out infinite; + -o-animation: ball-fall 1s ease-in-out infinite; + animation: ball-fall 1s ease-in-out infinite; } + +.la-ball-fall > div:nth-child(1) { + -webkit-animation-delay: -200ms; + -moz-animation-delay: -200ms; + -o-animation-delay: -200ms; + animation-delay: -200ms; } + +.la-ball-fall > div:nth-child(2) { + -webkit-animation-delay: -100ms; + -moz-animation-delay: -100ms; + -o-animation-delay: -100ms; + animation-delay: -100ms; } + +.la-ball-fall > div:nth-child(3) { + -webkit-animation-delay: 0ms; + -moz-animation-delay: 0ms; + -o-animation-delay: 0ms; + animation-delay: 0ms; } + +.la-ball-fall.la-sm { + width: 26px; + height: 8px; } + +.la-ball-fall.la-sm > div { + width: 4px; + height: 4px; + margin: 2px; } + +.la-ball-fall.la-2x { + width: 108px; + height: 36px; } + +.la-ball-fall.la-2x > div { + width: 20px; + height: 20px; + margin: 8px; } + +.la-ball-fall.la-3x { + width: 162px; + height: 54px; } + +.la-ball-fall.la-3x > div { + width: 30px; + height: 30px; + margin: 12px; } + +/* + * Animation + */ +@-webkit-keyframes ball-fall { + 0% { + opacity: 0; + -webkit-transform: translateY(-145%); + transform: translateY(-145%); } + 10% { + opacity: .5; } + 20% { + opacity: 1; + -webkit-transform: translateY(0); + transform: translateY(0); } + 80% { + opacity: 1; + -webkit-transform: translateY(0); + transform: translateY(0); } + 90% { + opacity: .5; } + 100% { + opacity: 0; + -webkit-transform: translateY(145%); + transform: translateY(145%); } } + +@-moz-keyframes ball-fall { + 0% { + opacity: 0; + -moz-transform: translateY(-145%); + transform: translateY(-145%); } + 10% { + opacity: .5; } + 20% { + opacity: 1; + -moz-transform: translateY(0); + transform: translateY(0); } + 80% { + opacity: 1; + -moz-transform: translateY(0); + transform: translateY(0); } + 90% { + opacity: .5; } + 100% { + opacity: 0; + -moz-transform: translateY(145%); + transform: translateY(145%); } } + +@-o-keyframes ball-fall { + 0% { + opacity: 0; + -o-transform: translateY(-145%); + transform: translateY(-145%); } + 10% { + opacity: .5; } + 20% { + opacity: 1; + -o-transform: translateY(0); + transform: translateY(0); } + 80% { + opacity: 1; + -o-transform: translateY(0); + transform: translateY(0); } + 90% { + opacity: .5; } + 100% { + opacity: 0; + -o-transform: translateY(145%); + transform: translateY(145%); } } + +@keyframes ball-fall { + 0% { + opacity: 0; + -webkit-transform: translateY(-145%); + -moz-transform: translateY(-145%); + -o-transform: translateY(-145%); + transform: translateY(-145%); } + 10% { + opacity: .5; } + 20% { + opacity: 1; + -webkit-transform: translateY(0); + -moz-transform: translateY(0); + -o-transform: translateY(0); + transform: translateY(0); } + 80% { + opacity: 1; + -webkit-transform: translateY(0); + -moz-transform: translateY(0); + -o-transform: translateY(0); + transform: translateY(0); } + 90% { + opacity: .5; } + 100% { + opacity: 0; + -webkit-transform: translateY(145%); + -moz-transform: translateY(145%); + -o-transform: translateY(145%); + transform: translateY(145%); } } diff --git a/src/main/webapp/s/media/js/login.js b/src/main/webapp/s/media/js/login.js index 0fffb30..3e93c60 100644 --- a/src/main/webapp/s/media/js/login.js +++ b/src/main/webapp/s/media/js/login.js @@ -89,7 +89,7 @@ if (jData.success == true) { - window.location.href = $('#context').val()+"/content/ems/ems.jsp"; + window.location.href = $('#context').val()+"/content/ems/ems-gd.jsp"; } else { diff --git a/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java new file mode 100644 index 0000000..634ceae --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/domain/ApkVersion.java @@ -0,0 +1,46 @@ +package com.casic.accessControl.app.domain; + +import javax.persistence.*; +import java.util.Date; + +/** + * app的版本信息 + */ +//工单 +@Entity +@Table(name = "apkVersion") +public class ApkVersion { + private String version; + private String path; + private Date ts;//时间戳 + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "version") + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + @Column(name = "path") + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + @Column(name = "ts") + public Date getTs() { + return ts; + } + + public void setTs(Date ts) { + this.ts = ts; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java new file mode 100644 index 0000000..1d0242a --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/dto/ApkVersionDto.java @@ -0,0 +1,50 @@ +package com.casic.accessControl.app.dto; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.util.TimeFormat; + +/** + * Created by lenovo on 2016/4/13. + */ +public class ApkVersionDto { + private String version; + private String path; + private String ts; + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public String getTs() { + return ts; + } + + public void setTs(String ts) { + this.ts = ts; + } + + public static ApkVersionDto Convert(ApkVersion version) { + if (version == null) { + return null; + } + ApkVersionDto versionDto = new ApkVersionDto(); + versionDto.setVersion(version.getVersion()); + versionDto.setPath(version.getVersion()); + versionDto.setTs(TimeFormat.formatTimestamp(version.getTs())); + + return versionDto; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java b/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java new file mode 100644 index 0000000..28b12a7 --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/manager/ApkVersionManager.java @@ -0,0 +1,27 @@ +package com.casic.accessControl.app.manager; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.core.hibernate.HibernateEntityDao; +import org.hibernate.Query; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * + */ +@Service("apkVersionManager") +public class ApkVersionManager extends HibernateEntityDao { + + public ApkVersion getLatestVersion() { + String sql = "from ApkVersion order by ts desc"; + Query query = getSession().createQuery(sql); + List list = query.list(); + if (null != list && list.isEmpty() == false) { + return list.get(0); + } + + return null; + } + +} diff --git a/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java b/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java new file mode 100644 index 0000000..065d3cc --- /dev/null +++ b/src/main/java/com/casic/accessControl/app/web/ApkVersionController.java @@ -0,0 +1,66 @@ +package com.casic.accessControl.app.web; + +import com.casic.accessControl.app.domain.ApkVersion; +import com.casic.accessControl.app.manager.ApkVersionManager; +import com.casic.accessControl.marker.domain.Marker; +import com.casic.accessControl.marker.manager.MarkerManager; +import com.casic.accessControl.task.domain.Task; +import com.casic.accessControl.task.domain.TaskDetail; +import com.casic.accessControl.task.dto.TaskDetailDto; +import com.casic.accessControl.task.dto.TaskDto; +import com.casic.accessControl.task.dto.TaskStatus; +import com.casic.accessControl.task.manager.TaskDetailManager; +import com.casic.accessControl.task.manager.TaskManager; +import com.casic.accessControl.user.domain.Company; +import com.casic.accessControl.user.domain.Role; +import com.casic.accessControl.user.domain.User; +import com.casic.accessControl.user.dto.UserDto; +import com.casic.accessControl.user.manager.RoleManager; +import com.casic.accessControl.user.manager.UserManager; +import com.casic.accessControl.util.DataTable; +import com.casic.accessControl.util.StringUtils; +import com.google.gson.Gson; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; +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.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * Created by lenovo on 2016/4/13. + */ +@Controller +@RequestMapping("app") +public class ApkVersionController { + + @Resource + private ApkVersionManager apkVersionManager; + + @RequestMapping("get-latest-version") + @ResponseBody + public Map getLatestVersion(HttpServletResponse response, HttpSession session) { + Map result = new HashMap(); + try { + ApkVersion latest = apkVersionManager.getLatestVersion(); + if (null != latest) { + result.put("version", latest.getVersion()); + result.put("path", latest.getPath()); + } else { + result.put("version", "1.0.0"); + } + } catch (Exception e) { + e.printStackTrace(); + result.put("version", "1.0.0"); + } + + return result; + } + +} diff --git a/src/main/java/com/casic/accessControl/marker/domain/Marker.java b/src/main/java/com/casic/accessControl/marker/domain/Marker.java index 0575cfe..7d5b854 100644 --- a/src/main/java/com/casic/accessControl/marker/domain/Marker.java +++ b/src/main/java/com/casic/accessControl/marker/domain/Marker.java @@ -67,6 +67,10 @@ private String area; @Column(name = "line") private String line; + @Column(name = "colorType") + private String colorType; + @Column(name = "photos") + private String photos; @@ -315,4 +319,20 @@ public void setArea(String area) { this.area = area; } + + public String getColorType() { + return colorType; + } + + public void setColorType(String colorType) { + this.colorType = colorType; + } + + public String getPhotos() { + return photos; + } + + public void setPhotos(String photos) { + this.photos = photos; + } } diff --git a/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java b/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java index 506f31d..c5f8cf5 100644 --- a/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java +++ b/src/main/java/com/casic/accessControl/marker/dto/MarkerDto.java @@ -2,12 +2,12 @@ //import com.casic.accessControl.feature.domain.Feature; import com.casic.accessControl.marker.domain.Marker; +import com.casic.accessControl.util.StringUtils; +import com.casic.accessControl.util.TimeFormat; import org.apache.commons.collections.CollectionUtils; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.List; +import java.text.ParseException; +import java.util.*; /** * Created by lenovo on 2016/5/16. @@ -43,6 +43,8 @@ private Long userId; private String area; private String line; + private String colorType; + private String photos; private String btnEdit = "编辑"; private String btnDelete = "删除"; @@ -296,6 +298,23 @@ this.area = area; } + public String getColorType() { + if (StringUtils.isEmpty(colorType)) return "0"; + return colorType; + } + + public void setColorType(String colorType) { + this.colorType = colorType; + } + + public String getPhotos() { + return photos; + } + + public void setPhotos(String photos) { + this.photos = photos; + } + public String getLine() { return line; } @@ -335,6 +354,52 @@ result.setRoad(doNullChange(marker.getRoad())); result.setArea(doNullChange(marker.getArea())); result.setLine(doNullChange(marker.getLine())); + result.setColorType(marker.getColorType()); + result.setPhotos(marker.getPhotos()); + return result; + } + + public static Marker convert2Marker(MarkerDto markerDto) { + if (markerDto == null) return null; + Marker result = new Marker(); + if(markerDto.getLongitude()==null||markerDto.getLatitude()==null) return null; + if (null != markerDto.getCreateTime() && markerDto.getCreateTime().length() == 19) { + try { + result.setCreateTime(TimeFormat.parse(markerDto.getCreateTime(), "yyyy-MM-dd HH:mm:ss")); + } catch (ParseException pex) { + result.setCreateTime(Calendar.getInstance().getTime()); + } + } else { + result.setCreateTime(Calendar.getInstance().getTime()); + } + result.setDepth(doNullChange(markerDto.getDepth())); + result.setId(markerDto.getId()); + result.setLatitude(markerDto.getLatitude()); + result.setLongitude(markerDto.getLongitude()); + result.setMarkerId(markerDto.getMarkerId()); + result.setMarkerDepth(doNullChange(markerDto.getMarkerDepth())); + result.setMarkerObjectId(doNullChange(markerDto.getMarkerObjectId())); + result.setMarkerObjectType(doNullChange(markerDto.getMarkerObjectType())); + result.setOwnerComp(doNullChange(markerDto.getOwnerComp())); + result.setIsValid(markerDto.getIsValid()); + result.setMemo(doNullChange(markerDto.getMemo())); + result.setPipeDiameter(doNullChange(markerDto.getPipeDiameter())); + result.setPipeMaterial(doNullChange(markerDto.getPipeMaterial())); + result.setMarkerType(doNullChange(markerDto.getMarkerType())); + result.setCreator(doNullChange(markerDto.getCreator())); + + result.setLayStyle(doNullChange(markerDto.getLayStyle())); + result.setBelowDepth(doNullChange(markerDto.getBelowDepth())); + result.setBelowDiameter(doNullChange(markerDto.getBelowDiameter())); + result.setBelowMaterial(doNullChange(markerDto.getBelowMaterial())); + result.setBelowType(doNullChange(markerDto.getBelowType())); + result.setConstructTime(doNullChange(markerDto.getConstructTime())); + result.setRecordType(markerDto.getRecordType()); + result.setRoad(doNullChange(markerDto.getRoad())); + result.setArea(doNullChange(markerDto.getArea())); + result.setLine(doNullChange(markerDto.getLine())); + result.setColorType(markerDto.getColorType()); + result.setPhotos(markerDto.getPhotos()); return result; } diff --git a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java index dd0fa4b..ba5a1fb 100644 --- a/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java +++ b/src/main/java/com/casic/accessControl/marker/manager/MarkerManager.java @@ -9,10 +9,7 @@ import com.casic.accessControl.marker.domain.Marker; import com.casic.accessControl.user.domain.Company; import com.casic.accessControl.user.domain.User; -import com.casic.accessControl.util.DataTable; -import com.casic.accessControl.util.DataTableParameter; -import com.casic.accessControl.util.DataTableUtils; -import com.casic.accessControl.util.DateUtils; +import com.casic.accessControl.util.*; import com.google.gson.Gson; import jxl.*; import jxl.read.biff.BiffException; @@ -31,11 +28,15 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; +import sun.misc.BASE64Decoder; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.File; +import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.text.ParseException; @@ -183,6 +184,53 @@ } /** + * 保存标识器和图片信息 + * @param markerDto + * @param companyId + * @param fileNames + * @param fileBuffers + * @return + */ + public boolean saveMarkerAndPhotos(MarkerDto markerDto, Long companyId, String[] fileNames, String[] fileBuffers) { + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + String strDirPath = request.getSession().getServletContext().getRealPath(""); + FileOutputStream fos = null; + String month = TimeFormat.format(Calendar.getInstance().getTime(), "yyyyMM"); + String webPath = "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String toDir = strDirPath + "/images/markers/" + month + "/"; //本地存储路径,每个月的图片单独保存 + String filePaths = ""; + try { + for (int i = 0; i < fileBuffers.length; i++) { + if (fileBuffers[i] != null && fileNames[i] != null) { +// filePaths += toDir+fileNames[i]+","; + filePaths += webPath + fileNames[i] + ","; + byte[] buffer = new BASE64Decoder().decodeBuffer(fileBuffers[i]); //对android传过来的图片字符串进行解码 + File destDir = new File(toDir); + if (!destDir.exists()) + destDir.mkdirs(); + File imageFile = new File(destDir, fileNames[i]); + fos = new FileOutputStream(imageFile); //保存图片 + fos.write(buffer); + fos.flush(); + fos.close(); + } + } + if (filePaths.endsWith(",")) { + filePaths = filePaths.substring(0, filePaths.length() - 1); + } + } catch (Exception e) { + return false; + } + Marker marker = MarkerDto.convert2Marker(markerDto); + marker.setIsValid(1); + marker.setCompanyId(companyId); + marker.setPhotos(filePaths); + save(marker); + return true; + + } + + /** * 新增标识器 8-9 * * @param markers @@ -582,7 +630,7 @@ "所属区域","所属线路","所属道路","建设年代","权属单位","标示对象ID", "标识器ID","标识器类型","标识器埋深","安装部门","经度", "纬度", "最后修改时间","备注","下层管种类", "下层管埋深", - "下层管直径", "下层管材料", "标识对象类别"}; + "下层管直径", "下层管材料", "标识对象类别", "标识点颜色", "图片地址"}; Label[][] labels = new Label[markerDtos.size() + 1][titleTxt.length]; for(int k=0;k saveMarkerAndPhotos(@RequestParam(value = "fileBuffer1", required = false) MultipartFile fileBuffer1, + @RequestParam(value = "fileBuffer2", required = false) MultipartFile fileBuffer2, + @RequestParam(value = "fileBuffer3", required = false) MultipartFile fileBuffer3, + @RequestParam(value = "jsonMarker", required = true) String jsonMarker) { + Map map = new HashMap(); + map.put("message", "安装无标识器信息"); + Gson gson = new Gson(); + try { + MarkerDto marker = gson.fromJson(jsonMarker, MarkerDto.class); + + if (null == marker.getMarkerId()) { + map.put("message", "无标识器ID"); + map.put("success", "false"); + return map; + } else if (markerManager.getMarkerByMarkerId(marker.getMarkerId()).size() > 0) { + map.put("message", "已安装过该标识器[" + marker.getMarkerId() + "]"); + map.put("success", "false"); + return map; + } else { + String[] fileNames = new String[3]; + String[] fileBuffers = new String[3]; + if (fileBuffer1 != null) { + fileNames[0] = marker.getMarkerId() + "_" + fileBuffer1.getOriginalFilename(); + byte[] fis = fileBuffer1.getBytes(); + fileBuffers[0] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, com.sun.org.apache.xml.internal.security.utils.Base64.BASE64DEFAULTLENGTH)); + } + if (fileBuffer2 != null) { + fileNames[1] = marker.getMarkerId() + "_" + fileBuffer2.getOriginalFilename(); + byte[] fis = fileBuffer2.getBytes(); + fileBuffers[1] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, com.sun.org.apache.xml.internal.security.utils.Base64.BASE64DEFAULTLENGTH)); + } + if (fileBuffer3 != null) { + fileNames[2] = marker.getMarkerId() + "_" + fileBuffer3.getOriginalFilename(); + byte[] fis = fileBuffer3.getBytes(); + fileBuffers[2] = new String(com.sun.org.apache.xml.internal.security.utils.Base64.encode(fis, Base64.BASE64DEFAULTLENGTH)); + } + Long companyId = marker.getCompanyId(); + if (companyId == null) { + return map; + } + boolean result = markerManager.saveMarkerAndPhotos(marker, companyId, fileNames, fileBuffers); + if (!result) { + return map; + } + } + } catch (Exception e) { + return map; + } + map.put("success", "true"); + map.put("message", "保存成功"); + return map; + } + + @RequestMapping("marker-info-delete") @ResponseBody public Map delete(@RequestParam(value = "id", required = true) Long id) { @@ -144,6 +208,9 @@ map.put("message", "删除需要ID信息"); return map; } + + System.out.println(ids); + markerManager.delMarkerByIds(ids); map.put("success", true); map.put("message", "删除成功"); @@ -240,6 +307,54 @@ return map; } + /** + * 批量上传标识点,用于无信号地区标识器信息统一上传,不修改已有标识点信息 + * @param strMarkers + * @return + */ + @RequestMapping("batch-save-no-update") + @ResponseBody + public Map batchSaveOrUpdate(@RequestParam(value = "markers", required = true) String strMarkers) { + strMarkers = strMarkers.replace('\n',' '); + Map map = new HashMap(); + map.put("message", "批量导入失败,或无导入标识器信息"); + Gson gson = new Gson(); + try { + List markers = gson.fromJson(strMarkers, new TypeToken>() { + }.getType()); + if (CollectionUtils.isEmpty(markers)) {//批量导入数据不存在,直接返回 + map.put("message", "批量导入数据不存在"); + return map; + } + + Long companyId = markers.get(0).getCompanyId(); + if (companyId == null) { + map.put("message", "未找到所属公司属性"); + return map; + } + + List markerDtoForSave = new ArrayList(); + for (MarkerDto markerDto : markers) { + // 上传marker的Id不为空且数据库中不存在记录,经纬度不为空,允许保存 + if (StringUtils.isNotBlank(markerDto.getMarkerId()) && markerManager.getMarkerByMarkerId(markerDto.getMarkerId()).size() <= 0) { + if (null != markerDto.getLongitude() && null != markerDto.getLatitude()) { + markerDtoForSave.add(markerDto); + } + } + } + boolean result = markerManager.batchSave(markerDtoForSave, companyId); + if (!result) { + return map; + } + } catch (Exception e) { + e.printStackTrace(); + return map; + } + map.put("success", true); + map.put("message", "保存成功"); + return map; + } + @RequestMapping("getMarkerListByCondition") @ResponseBody @POST diff --git a/src/main/java/com/casic/accessControl/user/web/UserController.java b/src/main/java/com/casic/accessControl/user/web/UserController.java index feab678..3534a97 100644 --- a/src/main/java/com/casic/accessControl/user/web/UserController.java +++ b/src/main/java/com/casic/accessControl/user/web/UserController.java @@ -46,6 +46,7 @@ @ResponseBody public Map login(@ModelAttribute User userInfo, HttpSession session) { Map result = new HashMap(); + User user = null; try{ user = userManager.login(userInfo); diff --git a/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java b/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java new file mode 100644 index 0000000..582120f --- /dev/null +++ b/src/main/java/com/casic/accessControl/util/HttpRequestUtils.java @@ -0,0 +1,129 @@ +package com.casic.accessControl.util; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.net.URL; +import java.net.URLConnection; +import java.util.List; +import java.util.Map; + +/** + * Created by lenovo on 2016/8/31. + */ +public class HttpRequestUtils { + + /** + * 向指定URL发送GET方法的请求 + * + * @param url + * 发送请求的URL + * @param param + * 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 + * @return URL 所代表远程资源的响应结果 + */ + public static String sendGet(String url, String param) { + String result = ""; + BufferedReader in = null; + try { + String urlNameString = url + "?" + param; + URL realUrl = new URL(urlNameString); + // 打开和URL之间的连接 + URLConnection connection = realUrl.openConnection(); + // 设置通用的请求属性 + connection.setRequestProperty("accept", "*/*"); + connection.setRequestProperty("connection", "Keep-Alive"); + connection.setRequestProperty("user-agent", + "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + // 建立实际的连接 + connection.connect(); + // 获取所有响应头字段 + Map> map = connection.getHeaderFields(); + // 遍历所有的响应头字段 + for (String key : map.keySet()) { + System.out.println(key + "--->" + map.get(key)); + } + // 定义 BufferedReader输入流来读取URL的响应 + in = new BufferedReader(new InputStreamReader( + connection.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + result += line; + } + } catch (Exception e) { + System.out.println("发送GET请求出现异常!" + e); + e.printStackTrace(); + } + // 使用finally块来关闭输入流 + finally { + try { + if (in != null) { + in.close(); + } + } catch (Exception e2) { + e2.printStackTrace(); + } + } + return result; + } + + /** + * 向指定 URL 发送POST方法的请求 + * + * @param url + * 发送请求的 URL + * @param param + * 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 + * @return 所代表远程资源的响应结果 + */ + public static String sendPost(String url, String param) { + PrintWriter out = null; + BufferedReader in = null; + String result = ""; + try { + URL realUrl = new URL(url); + // 打开和URL之间的连接 + URLConnection conn = realUrl.openConnection(); + // 设置通用的请求属性 + conn.setRequestProperty("accept", "*/*"); + conn.setRequestProperty("connection", "Keep-Alive"); + conn.setRequestProperty("user-agent", + "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + // 发送POST请求必须设置如下两行 + conn.setDoOutput(true); + conn.setDoInput(true); + // 获取URLConnection对象对应的输出流 + out = new PrintWriter(conn.getOutputStream()); + // 发送请求参数 + out.print(param); + // flush输出流的缓冲 + out.flush(); + // 定义BufferedReader输入流来读取URL的响应 + in = new BufferedReader( + new InputStreamReader(conn.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + result += line; + } + } catch (Exception e) { + System.out.println("发送 POST 请求出现异常!"+e); + e.printStackTrace(); + } + //使用finally块来关闭输出流、输入流 + finally{ + try{ + if(out!=null){ + out.close(); + } + if(in!=null){ + in.close(); + } + } + catch(IOException ex){ + ex.printStackTrace(); + } + } + return result; + } + } \ No newline at end of file diff --git a/src/main/java/com/casic/accessControl/util/TimeFormat.java b/src/main/java/com/casic/accessControl/util/TimeFormat.java new file mode 100644 index 0000000..e9168d5 --- /dev/null +++ b/src/main/java/com/casic/accessControl/util/TimeFormat.java @@ -0,0 +1,148 @@ +package com.casic.accessControl.util; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +/** + * 格式化日期工具类 + * 默认模式yyyy-MM-dd HH:mm:ss + * @author Administrator + * + */ +public class TimeFormat { + + private static final String DATE_FORMAT_STRING = "yyyy-MM-dd"; + private static final String TIME_FORMAT_STRING = "HH:mm:ss"; + private static final String TIMESTAMP_FORMAT_STRING = "yyyy-MM-dd HH:mm:ss"; + + // 默认格式化格式 + private static SimpleDateFormat defaultFormat = new SimpleDateFormat(TIMESTAMP_FORMAT_STRING); + + public static void setFormatString(String pattern) { + defaultFormat.applyPattern(pattern); + } + + /** + * 默认格式化日期 + * + * @param Date date + * @return String + */ + public static String format(Date date) { + return defaultFormat.format(date); + } + + /** + * 日期格式化 + * + * @param date + * @return + */ + public static String formatDate(Date date) { + return TimeFormat.format(date, DATE_FORMAT_STRING); + } + + /** + * 时间格式化 + * + * @param date + * @return + */ + public static String formatTime(Date date) { + return TimeFormat.format(date, TIME_FORMAT_STRING); + } + + /** + * 时间戳格式化 + * + * @param date + * @return + */ + public static String formatTimestamp(Date date) { + return TimeFormat.format(date, TIMESTAMP_FORMAT_STRING); + } + + /** + * 以指定模式格式化日期 + * + * @param Date date + * @param String pattern + * @return String + */ + public static String format(Date date, String pattern) { + SimpleDateFormat formatter = new SimpleDateFormat(pattern); + return formatter.format(date); + } + + /** + * 根据起止日期生成日期序列 + * 包括start和end的日期 + * + * @param start + * @param end + * @return + */ + public static List generateDates(String start, String end) throws ParseException { + List dates = new ArrayList(); + Calendar s = Calendar.getInstance(); + Calendar e = Calendar.getInstance(); + s.setTime(TimeFormat.parse(start, DATE_FORMAT_STRING)); + s.set(Calendar.HOUR_OF_DAY, 0); + s.set(Calendar.MINUTE, 0); + s.set(Calendar.SECOND, 0); + e.setTime(TimeFormat.parse(end, DATE_FORMAT_STRING)); + e.set(Calendar.HOUR_OF_DAY, 0); + e.set(Calendar.MINUTE, 0); + e.set(Calendar.SECOND, 0); + while (s.before(e) == true) { + dates.add(TimeFormat.formatDate(s.getTime())); + s.add(Calendar.DATE, 1); + } + + dates.add(end); + return dates; + } + + + /** + * 解析日期字符串 + * + * @param String source + * @return Date + * + * @throws ParseException + */ + public static Date parse(String source) throws ParseException { + return defaultFormat.parse(source); + } + + /** + * 以指定模式解析日期 + * + * @param String source + * @param String pattern + * @return Date + * + * @throws ParseException + */ + public static Date parse(String source, String pattern) throws ParseException { + SimpleDateFormat formatter = new SimpleDateFormat(pattern); + return formatter.parse(source); + } + + + public static Date parseDateWithoutTime(String source) throws ParseException { + SimpleDateFormat formatter = new SimpleDateFormat(DATE_FORMAT_STRING); + Calendar date = Calendar.getInstance(); + date.setTime(formatter.parse(source)); + date.set(Calendar.HOUR, 0); + date.set(Calendar.HOUR, 0); + date.set(Calendar.MINUTE, 0); + return date.getTime(); + } + +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 53c91ea..cea976f 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -15,19 +15,17 @@ # ============================================================================ # db # ============================================================================ -#db.default.driverClassName=oracle.jdbc.driver.OracleDriver -#db.default.url=jdbc:oracle:thin:@192.168.0.203:1521:SZHTDB2 -#db.default.username=scott -#db.default.password=SZHTDB2 db.default.driverClassName=com.mysql.jdbc.Driver -db.default.url=jdbc:mysql://127.0.0.1:3306/ems?useUnicode=true&characterEncoding=UTF-8 -db.default.username=emsweb -db.default.password=emsweb +db.default.url=jdbc:mysql://127.0.0.1:3306/ems_tong?useUnicode=true&characterEncoding=UTF-8 +db.default.username=root +db.default.password=root +#db.default.username=emsweb +#db.default.password=emsweb #db.default.url=jdbc:mysql://119.254.110.71:3307/ems?useUnicode=true&characterEncoding=UTF-8 #db.default.username=root #db.default.password=rootems - -# ============================================================================ +# +## ============================================================================ # log4jdbc # ============================================================================ log4jdbc.enable=true diff --git a/src/main/resources/spring/applicationContext-filter.xml b/src/main/resources/spring/applicationContext-filter.xml index a08c5fc..98ac7d6 100644 --- a/src/main/resources/spring/applicationContext-filter.xml +++ b/src/main/resources/spring/applicationContext-filter.xml @@ -35,9 +35,13 @@ /user/ill-login.do /marker/exportMarker.do /marker/batchSave-na.do + /marker/batch-save-no-update.do + /marker/save-marker-photo.do /event/save-event.do /task/get-task.do + /app/get-latest-version.do /xls/* + /apk/* diff --git a/src/main/resources/spring/applicationContext-hibernate.xml b/src/main/resources/spring/applicationContext-hibernate.xml index 5bb1a7e..dc54192 100644 --- a/src/main/resources/spring/applicationContext-hibernate.xml +++ b/src/main/resources/spring/applicationContext-hibernate.xml @@ -65,6 +65,7 @@ com.casic.accessControl.task.domain.Position com.casic.accessControl.event.domain.Event com.casic.accessControl.marker.domain.OptionItem + com.casic.accessControl.app.domain.ApkVersion diff --git a/src/main/webapp/common/layout/menu_new.jsp b/src/main/webapp/common/layout/menu_new.jsp index 3cf4b4e..cbd822e 100644 --- a/src/main/webapp/common/layout/menu_new.jsp +++ b/src/main/webapp/common/layout/menu_new.jsp @@ -20,7 +20,7 @@
                                          • - + @@ -54,7 +54,7 @@
                                          • - + diff --git a/src/main/webapp/content/ems/ems-gd.jsp b/src/main/webapp/content/ems/ems-gd.jsp new file mode 100644 index 0000000..5137b49 --- /dev/null +++ b/src/main/webapp/content/ems/ems-gd.jsp @@ -0,0 +1,604 @@ +<%@page contentType="text/html;charset=UTF-8" %> + +<%@include file="/taglibs.jsp" %> + +<%pageContext.setAttribute("currentMenu", "ems");%> + + + + + + + + + + + + + 地下管线电子标识系统 + + + + + + + + + + + + + + + + + + +<%-- + +--%> + + + + + + + + + + + + + + +<%@include file="/common/layout/header.jsp" %> + +
                                            + + + + <%@include file="/common/layout/menu_new.jsp" %> + + + +
                                            + + + +
                                            + +
                                            + + +
                                            +
                                            +
                                            +
                                            + +
                                            +
                                            + +
                                            +
                                            + +
                                            +
                                            + +
                                            +
                                            + +
                                            + +
                                            + +
                                            + +
                                            + +
                                            + +
                                            +
                                            +
                                            + + + + +
                                            +
                                            +
                                            +
                                            + + + + +
                                            +
                                            +
                                            + +
                                            + +
                                            + +<%--todo list:错误使用方法 + +--%> +
                                            + +
                                            +
                                            + +
                                            + +
                                            + +
                                            + + +
                                            + +
                                            + + 移动 + 绘制区域 + 新增标识器 + 删除标识器 + 保存标识器 + 批量导入 + 导出Excel + 清空 + +
                                            + +
                                            +
                                            + +
                                            + + + +
                                            + +
                                            + +
                                            + + + + +
                                            + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/webapp/content/task/task-gd.jsp b/src/main/webapp/content/task/task-gd.jsp new file mode 100644 index 0000000..d2d5549 --- /dev/null +++ b/src/main/webapp/content/task/task-gd.jsp @@ -0,0 +1,374 @@ +<%@page contentType="text/html;charset=UTF-8" %> + +<%@include file="/taglibs.jsp" %> + +<%pageContext.setAttribute("currentMenu", "task");%> + + + + + + + + + + + + + 地下管线电子标识系统 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +<%@include file="/common/layout/header.jsp" %> + +
                                            + + + + <%@include file="/common/layout/menu_new.jsp" %> + + + +
                                            + + + +
                                            + +
                                            + +
                                            + + 移动 + 绘制区域 + 选择多点创建工单 + 清空选择 + +
                                            + +
                                            + +
                                            + + +
                                            + +
                                            + +
                                            + +
                                            历史工单
                                            + +
                                            + +
                                            + +
                                            + <%--巡检员:--%> +
                                            +
                                            + + +
                                            +
                                            + + +
                                              +
                                            +
                                              +
                                              + +
                                              + +
                                              + +
                                              + +
                                              +
                                              + +
                                              + + + +
                                              + +
                                              + +
                                              + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/webapp/images/drop/0.png b/src/main/webapp/images/drop/0.png new file mode 100644 index 0000000..f4b966b --- /dev/null +++ b/src/main/webapp/images/drop/0.png Binary files differ diff --git a/src/main/webapp/images/drop/1.png b/src/main/webapp/images/drop/1.png new file mode 100644 index 0000000..9284b64 --- /dev/null +++ b/src/main/webapp/images/drop/1.png Binary files differ diff --git a/src/main/webapp/images/drop/2.png b/src/main/webapp/images/drop/2.png new file mode 100644 index 0000000..b5425db --- /dev/null +++ b/src/main/webapp/images/drop/2.png Binary files differ diff --git a/src/main/webapp/images/drop/3.png b/src/main/webapp/images/drop/3.png new file mode 100644 index 0000000..dd09655 --- /dev/null +++ b/src/main/webapp/images/drop/3.png Binary files differ diff --git a/src/main/webapp/images/drop/4.png b/src/main/webapp/images/drop/4.png new file mode 100644 index 0000000..50cf1f7 --- /dev/null +++ b/src/main/webapp/images/drop/4.png Binary files differ diff --git a/src/main/webapp/images/drop/5.png b/src/main/webapp/images/drop/5.png new file mode 100644 index 0000000..a2029bd --- /dev/null +++ b/src/main/webapp/images/drop/5.png Binary files differ diff --git a/src/main/webapp/images/drop/6.png b/src/main/webapp/images/drop/6.png new file mode 100644 index 0000000..b53248a --- /dev/null +++ b/src/main/webapp/images/drop/6.png Binary files differ diff --git a/src/main/webapp/images/ems/point.png b/src/main/webapp/images/ems/point.png new file mode 100644 index 0000000..a814351 --- /dev/null +++ b/src/main/webapp/images/ems/point.png Binary files differ diff --git a/src/main/webapp/images/ems/rect.png b/src/main/webapp/images/ems/rect.png new file mode 100644 index 0000000..99d0c9e --- /dev/null +++ b/src/main/webapp/images/ems/rect.png Binary files differ diff --git a/src/main/webapp/images/events/red_icon.png b/src/main/webapp/images/events/red_icon.png new file mode 100644 index 0000000..78c26e4 --- /dev/null +++ b/src/main/webapp/images/events/red_icon.png Binary files differ diff --git a/src/main/webapp/images/point-task.png b/src/main/webapp/images/point-task.png new file mode 100644 index 0000000..b2e22c6 --- /dev/null +++ b/src/main/webapp/images/point-task.png Binary files differ diff --git a/src/main/webapp/images/point.png b/src/main/webapp/images/point.png new file mode 100644 index 0000000..4b887dc --- /dev/null +++ b/src/main/webapp/images/point.png Binary files differ diff --git a/src/main/webapp/images/tasks/point.png b/src/main/webapp/images/tasks/point.png new file mode 100644 index 0000000..a814351 --- /dev/null +++ b/src/main/webapp/images/tasks/point.png Binary files differ diff --git a/src/main/webapp/images/tasks/rect.png b/src/main/webapp/images/tasks/rect.png new file mode 100644 index 0000000..99d0c9e --- /dev/null +++ b/src/main/webapp/images/tasks/rect.png Binary files differ diff --git a/src/main/webapp/s/app/ems/EMSBean.js b/src/main/webapp/s/app/ems/EMSBean.js index ca6914b..a3b1dca 100644 --- a/src/main/webapp/s/app/ems/EMSBean.js +++ b/src/main/webapp/s/app/ems/EMSBean.js @@ -1,5 +1,6 @@ EMSBean = function (markerObjectType,pipeMaterial,pipeDiameter, layStyle, depth, belowType, belowDepth, belowDiameter, belowMaterial, road, - constructTime, ownerComp, markerObjectId, markerId, markerType, markerDepth, creator, createTime, memo, lat, long, recordType,id,line,area) { + constructTime, ownerComp, markerObjectId, markerId, markerType, markerDepth, creator, createTime, memo, lat, long, + recordType,id,line,area, colorType) { this.markerObjectType = markerObjectType; this.pipeMaterial = pipeMaterial; @@ -26,5 +27,5 @@ this.id = id; this.line=line; this.area =area; - + this.colorType = colorType; }; diff --git a/src/main/webapp/s/app/ems/ems-gd.js b/src/main/webapp/s/app/ems/ems-gd.js new file mode 100644 index 0000000..8875ae8 --- /dev/null +++ b/src/main/webapp/s/app/ems/ems-gd.js @@ -0,0 +1,627 @@ +/** + * Created by lenovo on 2016/4/13. + */ +//定义全局变量,缓存组织结构 + +var EmsGd = function () { + var isSaveStatus = false; + var map = null; + var mouseTool = null; + var drawOverlays = new Array(); + var readyToUploadMarkers = new Array(); + var vectorMarkers = []; + var markerData = []; + var hadRequest = false; + + var blueIcon = new AMap.Icon({ + size: new AMap.Size(25, 34), + image: $('#context').val() + '/images/drop/0.png' + }); + + var orangeIcon = new AMap.Icon({ + size: new AMap.Size(25, 34), + image: $('#context').val() + '/images/drop/1.png' + }); + + var redIcon = new AMap.Icon({ + size: new AMap.Size(25, 34), + image: $('#context').val() + '/images/drop/2.png' + }); + + var blackIcon = new AMap.Icon({ + size: new AMap.Size(25, 34), + image: $('#context').val() + '/images/drop/3.png' + }); + + var pinkIcon = new AMap.Icon({ + size: new AMap.Size(25, 34), + image: $('#context').val() + '/images/drop/4.png' + }); + + var yellowIcon = new AMap.Icon({ + size: new AMap.Size(25, 34), + image: $('#context').val() + '/images/drop/5.png' + }); + + var greenIcon = new AMap.Icon({ + size: new AMap.Size(25, 34), + image: $('#context').val() + '/images/drop/6.png' + }); + + var handleDatePickers = function () { + + if (jQuery().datepicker) { + $('.date-picker').datepicker({ + rtl: App.isRTL() + }); + } + } + + function requestMarkers() { + if (markerData.length == 0&!hadRequest) { + hadRequest = true; + $.ajax({ + type: "get", + url: $('#context').val() + "/marker/all-point-list.do", + dataType: "json", +// async:false, + cache: false, + success: function (r) { + if (r.data) {//请求成功,将获取到的数据加载到地图上 + //1.解析返回的结果,.设置全局变量data的值 + markerData = [];//清空原来的数据 + for (var t = 0; t < r.data.length; t++) { + var markerDto = r.data[t]; + var emsBean = new EMSBean(markerDto.markerObjectType, markerDto.pipeMaterial, markerDto.pipeDiameter, markerDto.layStyle, + markerDto.depth, markerDto.belowType, markerDto.belowDepth, markerDto.belowDiameter, + markerDto.belowMaterial, markerDto.road, markerDto.constructTime, markerDto.ownerComp, + markerDto.markerObjectId, markerDto.markerId, markerDto.markerType, markerDto.markerDepth, + markerDto.creator, markerDto.createTime, markerDto.memo, markerDto.latitude, markerDto.longitude, + markerDto.recordType, markerDto.id,markerDto.line,markerDto.area,markerDto.colorType); + markerData[t] = emsBean; + } + //2.增加marker + EmsGd.addMarker(markerData); + } + hadRequest = false; + map.off("complete", requestMarkers()); + }, + error: function (d) {//请求出错 + hadRequest = false; + map.off("complete", requestMarkers()); + } + }); + } else if(!hadRequest){ + EmsGd.addMarker(markerData); + } + + } + + return { + + //添加标识器 + emsAddCallBack: function () { + $('#addModal').modal('show'); + }, + + //删除标识器 + emsDelCallBack: function () { + //绘制矩形区域: + if (drawOverlays.length == 0) { + swal("请先绘制区域", "", "warning"); + return; + } + + var pointArray = new Array(); + var readyToDel = ""; + for (var i = 0; i < drawOverlays.length; i++) { + var layer = drawOverlays[i]; + try { + // 生成判断是否在多边形内的数据格式 + var path = []; + for (var k = 0; k < layer.He.path.length; k++) { + var pos = []; + pos.push(layer.He.path[k].lng, layer.He.path[k].lat); + path.push(pos); + } + for (var j = 0; j < markerData.length; j++) { + var emsBean = markerData[j]; + var point = new AMap.LngLat(emsBean.longitude, emsBean.latitude); + var isPointInRing = AMap.GeometryUtil.isPointInRing(point, path); + if (isPointInRing) { + pointArray.push(point); + readyToDel = readyToDel + emsBean.id + ","; + } + } + } catch (e) { + swal("脚本异常", e.message, "error"); + } + if (pointArray.length <= 0) { + swal("选择区域没有要删除的点", "", "warning"); + for (var i in drawOverlays) { + map.remove(drawOverlays[i]); + } + return; + } + + swal({ + title: "是否确认删除?", + text: "删除是不可恢复的", + type: "warning", + showCancelButton: true, + confirmButtonText: "确认", + cancelButtonText: "取消", + closeOnConfirm: false + }, function() { + $.ajax({ + type: "get", + url: $('#context').val() + "/marker/delMarkerByIds.do", + dataType: "json", + cache: false, + data: { + "ids": readyToDel + }, + success: function (r) { + if (r.success) {//请求成功 + swal({ + title: "删除标识器成功", + text: "", + type: "success", + confirmButtonText: "确认", + closeOnConfirm: false + }, function() { + location.href = $('#context').val() + "/content/ems/ems-gd.jsp"; + }); + } + }, + error: function (d) {//请求出错 + swal("请求异常", d.responseText, "error"); + } + }); + }); + } + }, + + //保存标识器 + emsSaveCallBack: function () { + + if (readyToUploadMarkers.length == 0) { + return; + } + if (isSaveStatus) { + swal("保存过于频繁", "请稍后操作", "warning"); + return; + } + isSaveStatus = true; + //TODO LIST:上传 + var uploadMaker = new Array(); + for (var i = 0; i < readyToUploadMarkers.length; i++) { + var emsBean = readyToUploadMarkers[i].Tag; + + if (!emsBean.depth) { + emsBean.depth = 0; + } + uploadMaker.push(emsBean); + } + $.ajax({ + type: "get", + url: $('#context').val() + "/marker/batchSave.do", + dataType: "json", + cache: false, + data: { + markers: JSON.stringify(uploadMaker) + }, + success: function (r) { + if (r.success) {//请求成功 + swal({ + title: "保存标识器成功", + text: "", + type: "success", + confirmButtonText: "确认", + closeOnConfirm: false + }, function() { + location.href = $('#context').val() + "/content/ems/ems-gd.jsp"; + }); + } + }, + error: function (d) {//请求出错 + swal("请求出错", d.responseText, "error"); + isSaveStatus = false; + } + }); + }, + + emsUploadCallBack: function () { + // map.zoomTo(map.getZoom() + 2); + //TODO LIST:弹出对应的对话框 + $('#uploadModal').modal('show'); + }, + + emsExportCallBack: function () { + //TODO LIST:选择导出的文件 +// map.zoomTo(map.getZoom() + 2); + location.href = $('#context').val() + "/marker/export.do"; + + }, + + // 清除地图上所有后添加的标记点 + clearOverlays: function () { + mouseTool.close(true)//关闭,并清除覆盖物 + + for (var i = 0; i < drawOverlays.length; i++) { + map.remove(drawOverlays[i]); + } + for (var i = 0; i < readyToUploadMarkers.length; i++) { + map.remove(readyToUploadMarkers[i]); + } + for (var i = 0; i < vectorMarkers.length; i++) { + map.remove(vectorMarkers[i]); + } + + drawOverlays = []; + readyToUploadMarkers = []; + vectorMarkers = []; + }, + + initMap: function () { + + // 创建地图实例 + map = new AMap.Map("container", { + zoom: 13, + resizeEnable: true, + zooms: [4,18],//设置地图级别范围 + }); + + //声明全局变量 + if (!markerData || markerData.length == 0) { + markerData = new Array(); + } + + // 鼠标操作工具栏 + mouseTool = new AMap.MouseTool(map); + mouseTool.on('draw',function(e){ + drawOverlays.push(e.obj); + }) + + //加载完毕请求标识点信息 + map.on("complete", requestMarkers); + }, + + // 绘制区域矩形框 + drawRect: function () { + mouseTool.rectangle(); + }, + + //取消绘制区域矩形框 + moveMap: function () { + mouseTool.close(true)//关闭,并清除覆盖物 + }, + + initForm: function () { + handleDatePickers(); + $("#selectObjectType").chosen(); + $("#resetEms").live("click", function (e) { + $("#markerObjectType").val(""); + $("#pipeDiameter").val(""); + $("#pipeMaterial").val(""); + $("#belowPipeType").val(""); + $("#belowPipeDepth").val(""); + $("#belowPipeDiameter").val(""); + $("#belowPipeMaterial").val(""); + $("#pipeDepth").val(""); + $("#layStyle").val(""); + $("#line").val(""); + $("#area").val(""); + $("#road").val(""); + $("#constructTime").val(""); + $("#ownerComp").val(""); + $("#markerObjectId").val(""); + $("#markerId").val(""); + $("#markerType").val(""); + $("#markerDepth").val(""); + $("#creator").val(""); + $("#memo").val(""); + + }); + + $('#localize').click(function (e) { + $('#addModal').modal('hide'); + + //注册地图点击事件 + function showInfo(e) { + map.off("click", showInfo); + var lng = e.lnglat.lng; + var lat = e.lnglat.lat; + //TODO LIST:获取填写表单的信息 所属区域也需要保存的 + var selectObjectType = $("#selectObjectType").val();//判断是哪个类别 + var markerObjectType = $("#markerObjectType").val(); + var pipeDiameter = $("#pipeDiameter").val(); + var pipeMaterial = $("#pipeMaterial").val(); + var belowPipeType = $("#belowPipeType").val(); + var belowPipeDepth = $("#belowPipeDepth").val(); + var belowPipeDiameter = $("#belowPipeDiameter").val(); + var belowPipeMaterial = $("#belowPipeMaterial").val(); + var pipeDepth = $("#pipeDepth").val(); + var layStyle = $("#layStyle").val(); + var road = $("#road").val(); + var constructTime = $("#constructTime").val(); + var ownerComp = $("#ownerComp").val(); + var markerObjectId = $("#markerObjectId").val(); + var markerId = $("#markerId").val(); + var markerType = $("#markerType").val(); + var markerDepth = $("#markerDepth").val(); + var creator = $("#creator").val(); + var memo = $("#memo").val(); + var line = $("#line").val(); + var area = $("#area").val(); + var emsBean = new EMSBean(markerObjectType, pipeMaterial, pipeDiameter, layStyle, pipeDepth, belowPipeType, belowPipeDepth, belowPipeDiameter, belowPipeMaterial, + road, constructTime, ownerComp, markerObjectId, markerId, markerType, markerDepth, creator, null, memo, lat, lng, selectObjectType,null,line,area); + var marker = new AMap.Marker({ + position: [lng, lat], + draggable: true + }); + + marker.on("click", attribute); + marker.Tag = emsBean; + map.add(marker); //增加点 + readyToUploadMarkers.push(marker); + function attribute() { + var emsBean2 = marker.Tag; + var searchInfoWindow = null; + var msg = ""; + var height = 0; + var titleName =""; + if (emsBean.recordType == 1) { + titleName = "
                                              管线
                                              "; + msg = msg + "管线种类:" + emsBean2.markerObjectType + "
                                              " + + "管线直径(mm):" + emsBean2.pipeDiameter + "
                                              " + + "管线材质:" + emsBean2.pipeMaterial + "
                                              " + + "埋设方式:" + emsBean2.layStyle + "
                                              " + + "管线埋深(mm):" + emsBean2.depth + "
                                              "; + height = 100; + } else if (emsBean.recordType == 2) { + titleName = "
                                              管线附属物
                                              "; + msg = msg + "附属物名称:" + emsBean2.markerObjectType + "
                                              " + + "井深(mm):" + emsBean2.depth + "
                                              "; + height = 40; + } else if (emsBean.recordType == 3) { + titleName = "
                                              管线特征管点
                                              "; + msg = msg + "管点特征:" + emsBean2.markerObjectType + "
                                              " + + "特征点埋深(mm):" + emsBean2.depth + "
                                              "; + height = 40; + } else { + titleName = "
                                              交叉穿越点
                                              "; + msg = msg + "上层管种类:" + emsBean2.markerObjectType + "
                                              " + + "上层管埋深(mm):" + emsBean2.depth + "
                                              " + + "上层管直径(mm):" + emsBean2.pipeDiameter + "
                                              " + + "上层管材料:" + emsBean2.pipeMaterial + "
                                              " + + "下层管种类:" + emsBean2.belowType + "
                                              " + + "下层管埋深(mm):" + emsBean2.belowDepth + "
                                              "+ + "下层管直径(mm):" + emsBean2.belowDiameter + "
                                              " + + "下层管材料:" + emsBean2.belowMaterial + "
                                              " ; + height = 160; + } + height = height +225; + msg = msg + "所属区域:" + emsBean2.area + "
                                              " + + "所属线路:" + emsBean2.line + "
                                              " + + "所属道路:" + emsBean2.road + "
                                              " + + "建设年代:" + emsBean2.constructTime + "
                                              " + + "权属单位:" + emsBean2.ownerComp + "
                                              " + + "标识器ID:" + emsBean2.markerId + "
                                              " + + "标识器类型:" + emsBean2.markerType + "
                                              " + + "标识器埋深(mm):" + emsBean2.markerDepth + "
                                              " + + "安装部门:" + emsBean2.creator + "
                                              " + + "最后修改时间:"+emsBean2.createTime + "
                                              " + + "备注:" + emsBean2.memo + "
                                              "; + var imgUrl = $('#context').val() + "/images/ems.jpg"; + var content = titleName + '
                                              ' + + '' + msg + + '
                                              '; + + var infowindow = new AMap.AdvancedInfoWindow({ + content: content, + width: 290, //宽度 + height: height, //高度 + panel: "panel", //检索结果面板 + enableAutoPan: true //自动平移 + }); + + infowindow.open(map, [e.lnglat.lng, e.lnglat.lat]); + } + + } + map.on("click", showInfo); + }); + + $("#searchMarker").click(function (e) { + var Marker = {}; + if (vectorMarkers.length != 0) { + for (var i = 0; i < vectorMarkers.length; i++) { + map.remove(vectorMarkers[i]); + } + } + vectorMarkers = []; + Marker.road = $("#roadCondition").val(); + Marker.memo = $("#memoCondition").val(); + Marker.area = $("#select_area").val(); + Marker.line = $("#select_line").val(); + Marker.ownerComp = $("#company").val(); + Marker.creator = $("#department").val(); + Marker.sDate = $("#txt_begin_day").val(); + Marker.eDate = $("#txt_end_day").val(); + //请求后台的id列表,然后遍历marker列表,修改marker的颜色 + $.ajax({ + type: "POST", + url: $('#context').val() + "/marker/getMarkerListByCondition.do", + data: {"strMarkerDto": JSON.stringify(Marker)}, + dataType: "json", + success: function (r) { + if (r.data) { + var pointArray = new Array(); + if (r.data.length > 1000) { + swal("有超过一千个点符合筛选条件", "会造成浏览器卡顿,请重新选择", "warning"); + } else { + if (r.data.length == 0) { + swal("没有搜到符合条件的标识器", "请重新选择", "warning"); + return; + } + for (var a in r.data) {//遍历列表,添加marker + var vectorMarker = new AMap.Marker({ + position: [r.data[a].longitude,r.data[a].latitude], + size: new AMap.Size(30, 30), + icon: $('#context').val() + '/images/point.png' + }); + vectorMarkers.push(vectorMarker); + map.add(vectorMarker); + } + map.setFitView(vectorMarkers); + } + + } + }, + error: function (request) { + //提示错误信息 + swal("脚本异常", r.message, "error"); + } + }); + }); + + //控制不同种类对象的标签信息显示 + $("#selectObjectType").die().live("change", function (e) { + var type = $("#selectObjectType").val(); + OptionItemProcess.initPipeTypeList(type); + if (type == 1) {//管线 + $("#pipeTypeLabel").text("管线种类"); + $(".up-pipe").show(); + $("#pipeDiameterLabel").text("管线直径"); + $("#pipeMaterialLabel").text("管线材质"); + $(".below").addClass("hidden"); + $("#pipeDepthLabel").text("管线埋深"); + $(".pipeOnly").show(); + } else if (type == 2) {//管线附属物 + $("#pipeTypeLabel").text("附属物名称"); + $(".up-pipe").hide(); + $(".below").addClass("hidden"); + $("#pipeDepthLabel").text("井深"); + $(".pipeOnly").hide(); + } else if (type == 3) {//管线特征点 + $("#pipeTypeLabel").text("管点特征"); + $(".up-pipe").hide(); + $(".below").addClass("hidden"); + $("#pipeDepthLabel").text("特征点埋深"); + $(".pipeOnly").hide(); + } else {//交叉穿越点 + $("#pipeTypeLabel").text("上层管种类"); + $(".up-pipe").show(); + $("#pipeDiameterLabel").text("上层管直径"); + $("#pipeMaterialLabel").text("上层管材料"); + $(".below").removeClass("hidden"); + $("#pipeDepthLabel").text("上层管埋深"); + $(".pipeOnly").hide(); + } + }); + + OptionItemProcess.initPipeTypeList($("#selectObjectType").val()); + OptionItemProcess.initBelowPipeTypeList(); + OptionItemProcess.initAreaList(); + OptionItemProcess.initLayStyleList(); + OptionItemProcess.initMaterialList(); + }, + + initSelect: function () { + $("#selectObjectType").chosen(); + }, + + addMarker: function (data) { + for (var i = 0; i < data.length; i++) { + var icon = blueIcon; + var color = data[i].colorType; + if (color == "1") { + icon = orangeIcon; + } else if (color == "2") { + icon = redIcon; + } else if (color == "3") { + icon = blackIcon; + } else if (color == "4") { + icon = pinkIcon; + } else if (color == "5") { + icon = yellowIcon; + } else if (color == "6") { + icon = greenIcon; + } + + var marker = new AMap.Marker({ + position: [data[i].longitude, data[i].latitude], + icon: icon + }); + marker.Tag = data[i]; + + marker.on("click", function (e) { + + var emsBean = e.target.Tag; + var msg = ""; + var height = 0; + var titleName =""; + if (emsBean.recordType == 1) { + titleName = "
                                              管线
                                              "; + msg = msg + "管线种类:" + emsBean.markerObjectType + "
                                              " + + "管线直径(mm):" + emsBean.pipeDiameter + "
                                              " + + "管线材质:" + emsBean.pipeMaterial + "
                                              " + + "埋设方式:" + emsBean.layStyle + "
                                              " + + "管线埋深(mm):" + emsBean.depth + "
                                              "; + height = 100; + } else if (emsBean.recordType == 2) { + titleName = "
                                              管线附属物
                                              "; + msg = msg + "附属物名称:" + emsBean.markerObjectType + "
                                              " + + "井深(mm):" + emsBean.depth + "
                                              "; + height = 40; + } else if (emsBean.recordType == 3) { + titleName = "
                                              管线特征管点
                                              "; + msg = msg + "管点特征:" + emsBean.markerObjectType + "
                                              " + + "特征点埋深(mm):" + emsBean.depth + "
                                              "; + height = 40; + } else { + titleName = "
                                              交叉穿越点
                                              "; + msg = msg + "上层管种类:" + emsBean.markerObjectType + "
                                              " + + "上层管埋深(mm):" + emsBean.depth + "
                                              " + + "上层管直径(mm):" + emsBean.pipeDiameter + "
                                              " + + "上层管材料:" + emsBean.pipeMaterial + "
                                              " + + "下层管种类:" + emsBean.belowType + "
                                              " + + "下层管埋深(mm):" + emsBean.belowDepth + "
                                              "+ + "下层管直径(mm):" + emsBean.belowDiameter + "
                                              " + + "下层管材料:" + emsBean.belowMaterial + "
                                              " ; + height = 160; + } + height = height +225; + msg = msg + "所属区域:" + emsBean.area + "
                                              " + + "所属线路:" + emsBean.line + "
                                              " + + "所属道路:" + emsBean.road + "
                                              " + + "建设年代:" + emsBean.constructTime + "
                                              " + + "权属单位:" + emsBean.ownerComp + "
                                              " + + "标识器ID:" + emsBean.markerId + "
                                              " + + "标识器类型:" + emsBean.markerType + "
                                              " + + "标识器埋深(mm):" + emsBean.markerDepth + "
                                              " + + "安装部门:" + emsBean.creator + "
                                              " + + "最后修改时间:"+emsBean.createTime + "
                                              " + + "备注:" + emsBean.memo + "
                                              "; + var imgUrl = $('#context').val() + "/images/ems.jpg"; + var content = titleName + '
                                              ' + + '' + msg + + '
                                              '; + + var infowindow = new AMap.AdvancedInfoWindow({ + content: content, + width: 290, //宽度 + height: height, //高度 + panel: "panel", //检索结果面板 + enableAutoPan: true //自动平移 + }); + + infowindow.open(map, [e.lnglat.lng, e.lnglat.lat]); + }); + + map.add(marker); + } + } + }; +}(); \ No newline at end of file diff --git a/src/main/webapp/s/app/task/task-gd.js b/src/main/webapp/s/app/task/task-gd.js new file mode 100644 index 0000000..abf4da0 --- /dev/null +++ b/src/main/webapp/s/app/task/task-gd.js @@ -0,0 +1,689 @@ +/** + * Created by lenovo on 2016/4/13. + */ +//定义全局变量,缓存组织结构 + +var TaskGd = function () { + + var map = null; + var mouseTool = null; + var taskMarkers = ""; + var drawOverlays = new Array(); + var drawTaskOverlays = new Array(); + var drawEventOverlays = []; + var taskLists; + var taskDetailLists = new Array(); + var eventBeanList = []; + var viewPoints = []; + var markerData = []; + var hadRequest = false; + + var blueIcon = new AMap.Icon({ + size: new AMap.Size(25, 34), + image: $('#context').val() + '/images/drop/0.png' + }); + + var orangeIcon = new AMap.Icon({ + size: new AMap.Size(25, 34), + image: $('#context').val() + '/images/drop/1.png' + }); + + var redIcon = new AMap.Icon({ + size: new AMap.Size(25, 34), + image: $('#context').val() + '/images/drop/2.png' + }); + + var blackIcon = new AMap.Icon({ + size: new AMap.Size(25, 34), + image: $('#context').val() + '/images/drop/3.png' + }); + + var pinkIcon = new AMap.Icon({ + size: new AMap.Size(25, 34), + image: $('#context').val() + '/images/drop/4.png' + }); + + var yellowIcon = new AMap.Icon({ + size: new AMap.Size(25, 34), + image: $('#context').val() + '/images/drop/5.png' + }); + + var greenIcon = new AMap.Icon({ + size: new AMap.Size(25, 34), + image: $('#context').val() + '/images/drop/6.png' + }); + + // 历史工单列表属性 + var options = { + valueNames: [ 'id', 'patrolerName', 'status', 'deployDate', 'beginDate', 'endDate', 'description', {attr: 'src', name: 'image'} ], + item: '
                                            • ' + + '

                                              ' + + '

                                              ' + + '

                                              ' + + '

                                              ' + + '

                                              ' + + '

                                              ' + + '' + + '
                                              ' + + '
                                              ' + + '
                                            • ', + page: 3, + plugins: [ ListPagination({}) ] + }; + + // 清除所有绘制的区域图层 + function clearAll() { + for (var i = 0; i < drawOverlays.length; i++) { + map.remove(drawOverlays[i]); + } + drawOverlays.length = 0; + } + + // 清除工单任务绘制的标识器点 + function clearAllTaskPoint() { + for (var i = 0; i < drawTaskOverlays.length; i++) { + map.remove(drawTaskOverlays[i]); + } + drawTaskOverlays.length = 0; + taskDetailLists.length = 0; + } + + // 清除工单任务绘制的事件点 + function clearAllEventPoint() { + for (var i = 0; i < drawEventOverlays.length; i++) { + map.remove(drawEventOverlays[i]); + } +// drawEventOverlays.length = 0; + drawEventOverlays = []; + eventBeanList = []; + } + + // 查询巡检任务列表 + function getTaskInfo(patroler) { + taskLists.clear(); + $.ajax({ + type: "get", + url: $('#context').val() + "/task/get-task.do", + dataType: "json", + cache: false, + data: { + + }, + success: function (r) { + if (r.success) {//请求成功 + for (var data in r.data) { + var icon = $('#context').val() + "/images/accidents/worker.png"; + var id = r.data[data].id; + var patrolerName = r.data[data].patrolerName; + if (patroler && patrolerName != patroler) { + continue; + } + var description = r.data[data].description; + var deployDate = r.data[data].deployDate; + var beginDate = r.data[data].beginDate; + var endDate = r.data[data].endDate; + var status = r.data[data].status; + var creatorName = r.data[data].creatorName; + var task = new TaskBean(id, icon, patrolerName, description, deployDate, beginDate, endDate, status, creatorName); + + task.patrolerName = "巡检员:" + task.patrolerName; + task.description = "任务描述:" + task.description; + task.deployDate = "下发时间:" + task.deployDate; + task.beginDate = task.beginDate == null ? "开始时间:" : "开始时间:" + task.beginDate; + task.endDate = task.endDate == null ? "完成时间:" : "完成时间:" + task.endDate; + task.status = "任务状态:" + task.status; + taskLists.add(task); + } + } else { + swal("后台数据请求异常", r.message, "error"); + } + }, + error: function (d) {//请求出错 + swal("后台数据请求出错", d.responseText, "error"); + } + }); + } + + // 展示事件信息 + function showEventInfo(e) { + var p = e.target; + var imgName = p.Tag.imageName; + var images = imgName.split(",");//图片路径数组 +// alert(images[0]); + var msg2 = "事件描述:" + p.Tag.description + "
                                              " + + "上传时间:" + p.Tag.createTime + "
                                              "; + $("#eventImg").children().remove();//avatar1.jpg + var imageDivs="
                                              "; +// var imageDivs =""; + var width = 100/images.length;//动态展示 + $("#viewHelper").children().remove(); + for(var i =0;i" + + "
                                              " + + "
                                              " + +// "
                                              "+ +// ""+ +// ""+ +// " "+ +// ""+ +// "
                                              " + + "
                                              " + +// imageDivs +=""; + } + imageDivs+="" + $(".fancybox-close").die().live("click",function(){ + $('#eventModal').modal('show').css({width: "300px"}); + }); + $(".zoom-icon").die().live("click",function(){ + $('#eventModal').modal('hide'); + }); +// alert(eval(imageDivs)) + $("#eventImg").append(imageDivs) + $("#eventDescription").html(msg2); + $('#eventModal').modal('show').css({width: "300px"}); +// alert("showEventInfo:"+images); +// eventImgPage(images.length, 1, images); + + } + + // 获取标识器点 + function requestMarkers() { + if (markerData.length == 0&&!hadRequest) { + hadRequest = true; + $.ajax({ + type: "get", + url: $('#context').val() + "/marker/all-point-list.do", + dataType: "json", + cache: false, + success: function (r) { + if (r.data) {//请求成功,将获取到的数据加载到地图上 + //1.解析返回的结果,.设置全局变量data的值 + markerData = [];//清空原来的数据 + for (var t = 0; t < r.data.length; t++) { + var markerDto = r.data[t]; + var emsBean = new EMSBean(markerDto.markerObjectType, markerDto.pipeMaterial, markerDto.pipeDiameter, markerDto.layStyle, + markerDto.depth, markerDto.belowType, markerDto.belowDepth, markerDto.belowDiameter, + markerDto.belowMaterial, markerDto.road, markerDto.constructTime, markerDto.ownerComp, + markerDto.markerObjectId, markerDto.markerId, markerDto.markerType, markerDto.markerDepth, + markerDto.creator, markerDto.createTime, markerDto.memo, markerDto.latitude, markerDto.longitude, + markerDto.recordType, markerDto.id,markerDto.line,markerDto.area, markerDto.colorType); + markerData[t] = emsBean; + } + //2.增加marker + TaskGd.addMarker(markerData); + } + hadRequest = false; + map.off("complete", requestMarkers()); + + }, + error: function (d) {//请求出错 + hadRequest = false; + map.off("complete", requestMarkers()); + } + }); + } else if(!hadRequest){ + TaskGd.addMarker(markerData); + } + + } + return { + + //添加工单 + selectMarkerCallBack: function () { + //绘制矩形区域: + taskMarkers = ""; + if (drawOverlays.length == 0) { + swal("请先绘制区域", "", "warning"); + return; + } + for (var i = 0; i < drawOverlays.length; i++) { + var layer = drawOverlays[i]; + try { + // 生成判断是否在多边形内的数据格式 + var path = []; + for (var k = 0; k < layer.He.path.length; k++) { + var pos = []; + pos.push(layer.He.path[k].lng, layer.He.path[k].lat); + path.push(pos); + } + + for (var j = 0; j < markerData.length; j++) { + var emsBean = markerData[j]; + var point = new AMap.LngLat(emsBean.longitude, emsBean.latitude); + var isPointInRing = AMap.GeometryUtil.isPointInRing(point, path); + if (isPointInRing) { + taskMarkers = taskMarkers + emsBean.id + ","; + } + } + } catch (e) { + swal("脚本异常", e.message, "error"); + } + } + if (taskMarkers == "") { + swal("请选择标识器点!", "", "error"); + return; + } + + $('#addTaskModal2').modal('show'); + clearAll(); + }, + + //清除 + clearCallBack: function () { + taskMarkers = ""; + clearAll(); + }, + + //上传工单 + uploadTaskCallBack: function (patrolerId, description) { + $.ajax({ + type: "get", + url: $('#context').val() + "/task/task-Save.do", + dataType: "json", + cache: false, + data: { + markers: taskMarkers, + patrolerId: patrolerId, + description: description + }, + success: function (r) { + if (r.success) {//请求成功 + swal({ + title: "请求成功", + text: r.message, + type: "success", + confirmButtonText: "确认" + }, function() { + TaskGd.updateList(); + }); + } else { + swal("请求失败", r.message, "error"); + } + }, + error: function (d) {//请求出错 + swal("请求失败", d.message, "error"); + } + }); + }, + + // 初始化地图 + initMap: function () { + + map = new AMap.Map("container", { + zoom: 13, + resizeEnable: true, + zooms: [4,18],//设置地图级别范围 + }); + + //声明全局变量 + if (!markerData || markerData.length == 0) { + markerData = new Array(); + } + + // 鼠标操作工具栏 + mouseTool = new AMap.MouseTool(map); + mouseTool.on('draw',function(e){ + drawOverlays.push(e.obj); + }); + + //加载完毕请求标识点信息 + map.on("complete", requestMarkers); + }, + + initList: function () { + taskLists = new List('worksheets', options); + TaskGd.updateList(); + //$('.sort').click(); + $('#btnSort').trigger("click"); + $('#btnSort').trigger("click"); + + $('#btnSort').css("padding", 0); + $('#btnSort').css("padding-left", 10); + $('#btnSort').css("padding-right", 15); + $('#btnSort').css("margin-bottom", 10); + + TaskGd.bindClickEvent(); + + $('#selectPatroler3').live('change', function (e) {//下拉列表更改的时候查询数据,更新列表,待优化为查询条件在后台利用 + TaskGd.updateList($("#selectPatroler3").val()); + }); + }, + + // 绑定任务列表单击事件 + bindClickEvent: function () { + $('#worksheets ul li').live('click', function (e) { + viewPoints = []; + if (null == this.getElementsByClassName("id")[0]) { + return; + } + clearAllTaskPoint(); + clearAllEventPoint(); + var taskId = this.getElementsByClassName("id")[0].innerHTML; + var i = 0; + //请求任务 + $.ajax({ + type: "get", + url: $('#context').val() + "/task/get-task-markers.do", + dataType: "json", + async:false, + cache: false, + data: { + taskId: taskId + }, + success: function (r) { + if (r.success) {//请求成功 + for (var data in r.data) { + var id = r.data[data].id; + var markerName = r.data[data].markerIdReal; + var latitude = r.data[data].latitude; + var longitude = r.data[data].longitude; + var finishTime = r.data[data].finishTime == null ? "" : r.data[data].finishTime; + var description = r.data[data].description == null ? "" : r.data[data].description; + var status = r.data[data].isChecked; + var icon = ""; + var isChecked = ""; + if (status == 0) { + icon = $('#context').val() + "/images/point-task.png"; + isChecked = "未巡检"; + } + else { + icon = $('#context').val() + "/images/point.png"; + isChecked = "已巡检"; + } + + var taskDetailBean = new TaskDetailBean(id, icon, markerName, latitude, longitude, isChecked, finishTime, description); + taskDetailLists.push(taskDetailBean); + + } + TaskGd.addTaskDetailMarker(taskDetailLists); + } + else { + alert(r.message); + } + }, + error: function (d) {//请求出错 + alert(d.message); + } + }); + + //请求该任务上报的事件 + $.ajax({ + type: "get", + url: $('#context').val() + "/event/get-event-list.do", + dataType: "json", + cache: false, + async:false, + data: { + taskId: taskId + }, + success: function (r) { + if (r.success) {//请求成功 + for (var data in r.data) { + var id = r.data[data].id; + var imageName = r.data[data].imageName; + var latitude = r.data[data].latitude; + var longitude = r.data[data].longitude; + var createTime = r.data[data].createTime == null ? "" : r.data[data].createTime; + var description = r.data[data].description == null ? "" : r.data[data].description; + var status = r.data[data].status; + var eventBean = new EventBean(id, imageName, latitude, longitude, description, status, createTime); + + eventBeanList.push(eventBean); + + } + TaskGd.addEventMarker(eventBeanList); + } + else { + alert(r.message); + } + }, + error: function (d) {//请求出错 + alert(d.message); + } + }); + + map.setFitView(viewPoints); + + }); + + }, + + /* + * 增加报警信息到列表 + * */ + updateList: function (patroler) { + getTaskInfo(patroler); + }, + + // 初始化表单操作 + initForm: function () { + $("#saveTask2").click(function (e) { + //alert(taskMarkers); + var patrolerId = $("#selectPatroler2").val(); + var description = $("#description2").val(); + TaskGd.uploadTaskCallBack(patrolerId, description); + $('#addTaskModal2').modal('hide'); + $("#description2").val(""); + }); + }, + + //获取巡检员列表 + initPatrolerArray: function () { + + $.ajax({ + type: "POST", + url: $('#context').val() + "/user/get-patroler.do", + data: {}, + dataType: "json", + success: function (r) { + //获取面的列表,将下拉列表初始化 + if (r.data) { + for (var user in r.data) { + //alert(r.data[user].id+":"+r.data[user].userName); + $("#selectPatroler").append(" "); + $("#selectPatroler2").append(" "); + $("#selectPatroler3").append(" "); + } + $("#selectPatroler").chosen(); + $("#selectPatroler2").chosen(); + $("#selectPatroler3").chosen(); + } + }, + error: function (d) { + //提示错误信息 + swal("请求巡检员列表出错", d.responseText, "error"); + } + }); + + }, + + // 绘制区域矩形框 + drawRect: function () { + mouseTool.rectangle(); + }, + + //取消绘制区域矩形框 + moveMap: function () { + mouseTool.close(true)//关闭,并清除覆盖物 + }, + + //初始化下拉列表框 + initSelect: function () { + TaskGd.initPatrolerArray(); + }, + + // 显示标识器点 + addMarker: function (data) { + for (var i = 0; i < data.length; i++) { + var icon = blueIcon; + var color = data[i].colorType; + if (color == "1") { + icon = orangeIcon; + } else if (color == "2") { + icon = redIcon; + } else if (color == "3") { + icon = blackIcon; + } else if (color == "4") { + icon = pinkIcon; + } else if (color == "5") { + icon = yellowIcon; + } else if (color == "6") { + icon = greenIcon; + } + + var marker = new AMap.Marker({ + position: [data[i].longitude, data[i].latitude], + icon: icon + }); + marker.Tag = data[i]; + + marker.on("click", function (e) { + + var emsBean = e.target.Tag; + var msg = ""; + var height = 0; + var titleName =""; + if (emsBean.recordType == 1) { + titleName = "
                                              管线
                                              "; + msg = msg + "管线种类:" + emsBean.markerObjectType + "
                                              " + + "管线直径(mm):" + emsBean.pipeDiameter + "
                                              " + + "管线材质:" + emsBean.pipeMaterial + "
                                              " + + "埋设方式:" + emsBean.layStyle + "
                                              " + + "管线埋深(mm):" + emsBean.depth + "
                                              "; + height = 100; + } else if (emsBean.recordType == 2) { + titleName = "
                                              管线附属物
                                              "; + msg = msg + "附属物名称:" + emsBean.markerObjectType + "
                                              " + + "井深(mm):" + emsBean.depth + "
                                              "; + height = 40; + } else if (emsBean.recordType == 3) { + titleName = "
                                              管线特征管点
                                              "; + msg = msg + "管点特征:" + emsBean.markerObjectType + "
                                              " + + "特征点埋深(mm):" + emsBean.depth + "
                                              "; + height = 40; + } else { + titleName = "
                                              交叉穿越点
                                              "; + msg = msg + "上层管种类:" + emsBean.markerObjectType + "
                                              " + + "上层管埋深(mm):" + emsBean.depth + "
                                              " + + "上层管直径(mm):" + emsBean.pipeDiameter + "
                                              " + + "上层管材料:" + emsBean.pipeMaterial + "
                                              " + + "下层管种类:" + emsBean.belowType + "
                                              " + + "下层管埋深(mm):" + emsBean.belowDepth + "
                                              "+ + "下层管直径(mm):" + emsBean.belowDiameter + "
                                              " + + "下层管材料:" + emsBean.belowMaterial + "
                                              " ; + height = 160; + } + height = height +225; + msg = msg + "所属区域:" + emsBean.area + "
                                              " + + "所属线路:" + emsBean.line + "
                                              " + + "所属道路:" + emsBean.road + "
                                              " + + "建设年代:" + emsBean.constructTime + "
                                              " + + "权属单位:" + emsBean.ownerComp + "
                                              " + + "标识器ID:" + emsBean.markerId + "
                                              " + + "标识器类型:" + emsBean.markerType + "
                                              " + + "标识器埋深(mm):" + emsBean.markerDepth + "
                                              " + + "安装部门:" + emsBean.creator + "
                                              " + + "最后修改时间:"+emsBean.createTime + "
                                              " + + "备注:" + emsBean.memo + "
                                              "; + var imgUrl = $('#context').val() + "/images/ems.jpg"; + var content = titleName + '
                                              ' + + '' + msg + + '
                                              '; + + var infowindow = new AMap.AdvancedInfoWindow({ + content: content, + width: 290, //宽度 + height: height, //高度 + panel: "panel", //检索结果面板 + enableAutoPan: true //自动平移 + }); + + infowindow.open(map, [e.lnglat.lng, e.lnglat.lat]); + }); + + map.add(marker); + } + }, + + //增加事件图片的marker + addEventMarker: function () { + console.log(eventBeanList); + for (var i = 0; i < eventBeanList.length; i++) { + var eventMarker = new AMap.Marker({ + position: [eventBeanList[i].longitude, eventBeanList[i].latitude], + size: new AMap.Size(30, 30), + icon: new AMap.Icon({ + size: new AMap.Size(38, 38), + image: $('#context').val() + "/images/events/red_icon.png" + }) + }); + + var msg = "事件描述:" + eventBeanList[i].description + "\r\n" + + "上传时间:" + eventBeanList[i].createTime + "\r\n"; + eventMarker.setTitle(msg); + eventMarker.Tag = eventBeanList[i]; + viewPoints.push(eventMarker); + eventMarker.on("click", showEventInfo); + map.add(eventMarker); // 将标注添加到地图中 + drawEventOverlays.push(eventMarker); + } + }, + + // 点击任务列表绘制任务对应的标识器点 + addTaskDetailMarker: function (data) { + for (var i = 0; i < data.length; i++) { + var msg = "标识器名称:" + data[i].markerName + "\r\n" + + "巡检状态:" + data[i].isChecked + "\r\n" + + "巡检时间:" + data[i].finishTime + "\r\n" + + "描述:" + data[i].description + "\r\n"; + + var marker = new AMap.Marker({ + position: [data[i].longitude, data[i].latitude], + size: new AMap.Size(30, 30), + icon: data[i].icon + }); + + marker.setTitle(msg); + + viewPoints.push(marker); + drawTaskOverlays.push(marker); + map.add(marker); // 将标注添加到地图中 + } + } + }; +}(); + +TaskBean = function (id, icon, patrolerName, description, deployDate, beginDate, endDate, status, creatorName) { + this.id = id; + this.image = icon; + this.patrolerName = patrolerName; + this.description = description; + this.deployDate = deployDate; + this.beginDate = beginDate; + this.endDate = endDate; + this.status = status; + this.creatorName = creatorName; +}; + +TaskDetailBean = function (id, icon, markerName, latitude, longitude, isChecked, finishTime, description) { + this.id = id; + this.icon = icon; + this.markerName = markerName; + this.latitude = latitude; + this.longitude = longitude; + this.isChecked = isChecked; + this.finishTime = finishTime; + this.description = description; +}; + +EventBean = function (id, imageName, latitude, longitude, description, status, createTime) { + this.id = id; + this.imageName = imageName; + this.latitude = latitude; + this.longitude = longitude; + this.description = description; + this.status = status; + this.createTime = createTime; +} \ No newline at end of file diff --git a/src/main/webapp/s/media/css/sweetalert.css b/src/main/webapp/s/media/css/sweetalert.css new file mode 100644 index 0000000..f2af7e3 --- /dev/null +++ b/src/main/webapp/s/media/css/sweetalert.css @@ -0,0 +1,935 @@ +body.stop-scrolling { + height: 100%; + overflow: hidden; } + +.sweet-overlay { + background-color: black; + /* IE8 */ + -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=40)"; + /* IE8 */ + background-color: rgba(0, 0, 0, 0.4); + position: fixed; + left: 0; + right: 0; + top: 0; + bottom: 0; + display: none; + z-index: 10000; } + +.sweet-alert { + background-color: white; + font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif; + width: 478px; + padding: 17px; + border-radius: 5px; + text-align: center; + position: fixed; + left: 50%; + top: 50%; + margin-left: -256px; + margin-top: -200px; + overflow: hidden; + display: none; + z-index: 99999; } + @media all and (max-width: 540px) { + .sweet-alert { + width: auto; + margin-left: 0; + margin-right: 0; + left: 15px; + right: 15px; } } + .sweet-alert h2 { + color: #575757; + font-size: 30px; + text-align: center; + font-weight: 600; + text-transform: none; + position: relative; + margin: 25px 0; + padding: 0; + line-height: 40px; + display: block; } + .sweet-alert p { + color: #797979; + font-size: 16px; + text-align: center; + font-weight: 300; + position: relative; + text-align: inherit; + float: none; + margin: 0; + padding: 0; + line-height: normal; } + .sweet-alert fieldset { + border: none; + position: relative; } + .sweet-alert .sa-error-container { + background-color: #f1f1f1; + margin-left: -17px; + margin-right: -17px; + overflow: hidden; + padding: 0 10px; + max-height: 0; + webkit-transition: padding 0.15s, max-height 0.15s; + transition: padding 0.15s, max-height 0.15s; } + .sweet-alert .sa-error-container.show { + padding: 10px 0; + max-height: 100px; + webkit-transition: padding 0.2s, max-height 0.2s; + transition: padding 0.25s, max-height 0.25s; } + .sweet-alert .sa-error-container .icon { + display: inline-block; + width: 24px; + height: 24px; + border-radius: 50%; + background-color: #ea7d7d; + color: white; + line-height: 24px; + text-align: center; + margin-right: 3px; } + .sweet-alert .sa-error-container p { + display: inline-block; } + .sweet-alert .sa-input-error { + position: absolute; + top: 29px; + right: 26px; + width: 20px; + height: 20px; + opacity: 0; + -webkit-transform: scale(0.5); + transform: scale(0.5); + -webkit-transform-origin: 50% 50%; + transform-origin: 50% 50%; + -webkit-transition: all 0.1s; + transition: all 0.1s; } + .sweet-alert .sa-input-error::before, .sweet-alert .sa-input-error::after { + content: ""; + width: 20px; + height: 6px; + background-color: #f06e57; + border-radius: 3px; + position: absolute; + top: 50%; + margin-top: -4px; + left: 50%; + margin-left: -9px; } + .sweet-alert .sa-input-error::before { + -webkit-transform: rotate(-45deg); + transform: rotate(-45deg); } + .sweet-alert .sa-input-error::after { + -webkit-transform: rotate(45deg); + transform: rotate(45deg); } + .sweet-alert .sa-input-error.show { + opacity: 1; + -webkit-transform: scale(1); + transform: scale(1); } + .sweet-alert input { + width: 100%; + box-sizing: border-box; + border-radius: 3px; + border: 1px solid #d7d7d7; + height: 43px; + margin-top: 10px; + margin-bottom: 17px; + font-size: 18px; + box-shadow: inset 0px 1px 1px rgba(0, 0, 0, 0.06); + padding: 0 12px; + display: none; + -webkit-transition: all 0.3s; + transition: all 0.3s; } + .sweet-alert input:focus { + outline: none; + box-shadow: 0px 0px 3px #c4e6f5; + border: 1px solid #b4dbed; } + .sweet-alert input:focus::-moz-placeholder { + transition: opacity 0.3s 0.03s ease; + opacity: 0.5; } + .sweet-alert input:focus:-ms-input-placeholder { + transition: opacity 0.3s 0.03s ease; + opacity: 0.5; } + .sweet-alert input:focus::-webkit-input-placeholder { + transition: opacity 0.3s 0.03s ease; + opacity: 0.5; } + .sweet-alert input::-moz-placeholder { + color: #bdbdbd; } + .sweet-alert input::-ms-clear { + display: none; } + .sweet-alert input:-ms-input-placeholder { + color: #bdbdbd; } + .sweet-alert input::-webkit-input-placeholder { + color: #bdbdbd; } + .sweet-alert.show-input input { + display: block; } + .sweet-alert .sa-confirm-button-container { + display: inline-block; + position: relative; } + .sweet-alert .la-ball-fall { + position: absolute; + left: 50%; + top: 50%; + margin-left: -27px; + margin-top: 4px; + opacity: 0; + visibility: hidden; } + .sweet-alert button { + background-color: #8CD4F5; + color: white; + border: none; + box-shadow: none; + font-size: 17px; + font-weight: 500; + -webkit-border-radius: 4px; + border-radius: 5px; + padding: 10px 32px; + margin: 26px 5px 0 5px; + cursor: pointer; } + .sweet-alert button:focus { + outline: none; + box-shadow: 0 0 2px rgba(128, 179, 235, 0.5), inset 0 0 0 1px rgba(0, 0, 0, 0.05); } + .sweet-alert button:hover { + background-color: #7ecff4; } + .sweet-alert button:active { + background-color: #5dc2f1; } + .sweet-alert button.cancel { + background-color: #C1C1C1; } + .sweet-alert button.cancel:hover { + background-color: #b9b9b9; } + .sweet-alert button.cancel:active { + background-color: #a8a8a8; } + .sweet-alert button.cancel:focus { + box-shadow: rgba(197, 205, 211, 0.8) 0px 0px 2px, rgba(0, 0, 0, 0.0470588) 0px 0px 0px 1px inset !important; } + .sweet-alert button[disabled] { + opacity: .6; + cursor: default; } + .sweet-alert button.confirm[disabled] { + color: transparent; } + .sweet-alert button.confirm[disabled] ~ .la-ball-fall { + opacity: 1; + visibility: visible; + transition-delay: 0s; } + .sweet-alert button::-moz-focus-inner { + border: 0; } + .sweet-alert[data-has-cancel-button=false] button { + box-shadow: none !important; } + .sweet-alert[data-has-confirm-button=false][data-has-cancel-button=false] { + padding-bottom: 40px; } + .sweet-alert .sa-icon { + width: 80px; + height: 80px; + border: 4px solid gray; + -webkit-border-radius: 40px; + border-radius: 40px; + border-radius: 50%; + margin: 20px auto; + padding: 0; + position: relative; + box-sizing: content-box; } + .sweet-alert .sa-icon.sa-error { + border-color: #F27474; } + .sweet-alert .sa-icon.sa-error .sa-x-mark { + position: relative; + display: block; } + .sweet-alert .sa-icon.sa-error .sa-line { + position: absolute; + height: 5px; + width: 47px; + background-color: #F27474; + display: block; + top: 37px; + border-radius: 2px; } + .sweet-alert .sa-icon.sa-error .sa-line.sa-left { + -webkit-transform: rotate(45deg); + transform: rotate(45deg); + left: 17px; } + .sweet-alert .sa-icon.sa-error .sa-line.sa-right { + -webkit-transform: rotate(-45deg); + transform: rotate(-45deg); + right: 16px; } + .sweet-alert .sa-icon.sa-warning { + border-color: #F8BB86; } + .sweet-alert .sa-icon.sa-warning .sa-body { + position: absolute; + width: 5px; + height: 47px; + left: 50%; + top: 10px; + -webkit-border-radius: 2px; + border-radius: 2px; + margin-left: -2px; + background-color: #F8BB86; } + .sweet-alert .sa-icon.sa-warning .sa-dot { + position: absolute; + width: 7px; + height: 7px; + -webkit-border-radius: 50%; + border-radius: 50%; + margin-left: -3px; + left: 50%; + bottom: 10px; + background-color: #F8BB86; } + .sweet-alert .sa-icon.sa-info { + border-color: #C9DAE1; } + .sweet-alert .sa-icon.sa-info::before { + content: ""; + position: absolute; + width: 5px; + height: 29px; + left: 50%; + bottom: 17px; + border-radius: 2px; + margin-left: -2px; + background-color: #C9DAE1; } + .sweet-alert .sa-icon.sa-info::after { + content: ""; + position: absolute; + width: 7px; + height: 7px; + border-radius: 50%; + margin-left: -3px; + top: 19px; + background-color: #C9DAE1; + left: 50%; } + .sweet-alert .sa-icon.sa-success { + border-color: #A5DC86; } + .sweet-alert .sa-icon.sa-success::before, .sweet-alert .sa-icon.sa-success::after { + content: ''; + -webkit-border-radius: 40px; + border-radius: 40px; + border-radius: 50%; + position: absolute; + width: 60px; + height: 120px; + background: white; + -webkit-transform: rotate(45deg); + transform: rotate(45deg); } + .sweet-alert .sa-icon.sa-success::before { + -webkit-border-radius: 120px 0 0 120px; + border-radius: 120px 0 0 120px; + top: -7px; + left: -33px; + -webkit-transform: rotate(-45deg); + transform: rotate(-45deg); + -webkit-transform-origin: 60px 60px; + transform-origin: 60px 60px; } + .sweet-alert .sa-icon.sa-success::after { + -webkit-border-radius: 0 120px 120px 0; + border-radius: 0 120px 120px 0; + top: -11px; + left: 30px; + -webkit-transform: rotate(-45deg); + transform: rotate(-45deg); + -webkit-transform-origin: 0px 60px; + transform-origin: 0px 60px; } + .sweet-alert .sa-icon.sa-success .sa-placeholder { + width: 80px; + height: 80px; + border: 4px solid rgba(165, 220, 134, 0.2); + -webkit-border-radius: 40px; + border-radius: 40px; + border-radius: 50%; + box-sizing: content-box; + position: absolute; + left: -4px; + top: -4px; + z-index: 2; } + .sweet-alert .sa-icon.sa-success .sa-fix { + width: 5px; + height: 90px; + background-color: white; + position: absolute; + left: 28px; + top: 8px; + z-index: 1; + -webkit-transform: rotate(-45deg); + transform: rotate(-45deg); } + .sweet-alert .sa-icon.sa-success .sa-line { + height: 5px; + background-color: #A5DC86; + display: block; + border-radius: 2px; + position: absolute; + z-index: 2; } + .sweet-alert .sa-icon.sa-success .sa-line.sa-tip { + width: 25px; + left: 14px; + top: 46px; + -webkit-transform: rotate(45deg); + transform: rotate(45deg); } + .sweet-alert .sa-icon.sa-success .sa-line.sa-long { + width: 47px; + right: 8px; + top: 38px; + -webkit-transform: rotate(-45deg); + transform: rotate(-45deg); } + .sweet-alert .sa-icon.sa-custom { + background-size: contain; + border-radius: 0; + border: none; + background-position: center center; + background-repeat: no-repeat; } + +/* + * Animations + */ +@-webkit-keyframes showSweetAlert { + 0% { + transform: scale(0.7); + -webkit-transform: scale(0.7); } + 45% { + transform: scale(1.05); + -webkit-transform: scale(1.05); } + 80% { + transform: scale(0.95); + -webkit-transform: scale(0.95); } + 100% { + transform: scale(1); + -webkit-transform: scale(1); } } + +@keyframes showSweetAlert { + 0% { + transform: scale(0.7); + -webkit-transform: scale(0.7); } + 45% { + transform: scale(1.05); + -webkit-transform: scale(1.05); } + 80% { + transform: scale(0.95); + -webkit-transform: scale(0.95); } + 100% { + transform: scale(1); + -webkit-transform: scale(1); } } + +@-webkit-keyframes hideSweetAlert { + 0% { + transform: scale(1); + -webkit-transform: scale(1); } + 100% { + transform: scale(0.5); + -webkit-transform: scale(0.5); } } + +@keyframes hideSweetAlert { + 0% { + transform: scale(1); + -webkit-transform: scale(1); } + 100% { + transform: scale(0.5); + -webkit-transform: scale(0.5); } } + +@-webkit-keyframes slideFromTop { + 0% { + top: 0%; } + 100% { + top: 50%; } } + +@keyframes slideFromTop { + 0% { + top: 0%; } + 100% { + top: 50%; } } + +@-webkit-keyframes slideToTop { + 0% { + top: 50%; } + 100% { + top: 0%; } } + +@keyframes slideToTop { + 0% { + top: 50%; } + 100% { + top: 0%; } } + +@-webkit-keyframes slideFromBottom { + 0% { + top: 70%; } + 100% { + top: 50%; } } + +@keyframes slideFromBottom { + 0% { + top: 70%; } + 100% { + top: 50%; } } + +@-webkit-keyframes slideToBottom { + 0% { + top: 50%; } + 100% { + top: 70%; } } + +@keyframes slideToBottom { + 0% { + top: 50%; } + 100% { + top: 70%; } } + +.showSweetAlert[data-animation=pop] { + -webkit-animation: showSweetAlert 0.3s; + animation: showSweetAlert 0.3s; } + +.showSweetAlert[data-animation=none] { + -webkit-animation: none; + animation: none; } + +.showSweetAlert[data-animation=slide-from-top] { + -webkit-animation: slideFromTop 0.3s; + animation: slideFromTop 0.3s; } + +.showSweetAlert[data-animation=slide-from-bottom] { + -webkit-animation: slideFromBottom 0.3s; + animation: slideFromBottom 0.3s; } + +.hideSweetAlert[data-animation=pop] { + -webkit-animation: hideSweetAlert 0.2s; + animation: hideSweetAlert 0.2s; } + +.hideSweetAlert[data-animation=none] { + -webkit-animation: none; + animation: none; } + +.hideSweetAlert[data-animation=slide-from-top] { + -webkit-animation: slideToTop 0.4s; + animation: slideToTop 0.4s; } + +.hideSweetAlert[data-animation=slide-from-bottom] { + -webkit-animation: slideToBottom 0.3s; + animation: slideToBottom 0.3s; } + +@-webkit-keyframes animateSuccessTip { + 0% { + width: 0; + left: 1px; + top: 19px; } + 54% { + width: 0; + left: 1px; + top: 19px; } + 70% { + width: 50px; + left: -8px; + top: 37px; } + 84% { + width: 17px; + left: 21px; + top: 48px; } + 100% { + width: 25px; + left: 14px; + top: 45px; } } + +@keyframes animateSuccessTip { + 0% { + width: 0; + left: 1px; + top: 19px; } + 54% { + width: 0; + left: 1px; + top: 19px; } + 70% { + width: 50px; + left: -8px; + top: 37px; } + 84% { + width: 17px; + left: 21px; + top: 48px; } + 100% { + width: 25px; + left: 14px; + top: 45px; } } + +@-webkit-keyframes animateSuccessLong { + 0% { + width: 0; + right: 46px; + top: 54px; } + 65% { + width: 0; + right: 46px; + top: 54px; } + 84% { + width: 55px; + right: 0px; + top: 35px; } + 100% { + width: 47px; + right: 8px; + top: 38px; } } + +@keyframes animateSuccessLong { + 0% { + width: 0; + right: 46px; + top: 54px; } + 65% { + width: 0; + right: 46px; + top: 54px; } + 84% { + width: 55px; + right: 0px; + top: 35px; } + 100% { + width: 47px; + right: 8px; + top: 38px; } } + +@-webkit-keyframes rotatePlaceholder { + 0% { + transform: rotate(-45deg); + -webkit-transform: rotate(-45deg); } + 5% { + transform: rotate(-45deg); + -webkit-transform: rotate(-45deg); } + 12% { + transform: rotate(-405deg); + -webkit-transform: rotate(-405deg); } + 100% { + transform: rotate(-405deg); + -webkit-transform: rotate(-405deg); } } + +@keyframes rotatePlaceholder { + 0% { + transform: rotate(-45deg); + -webkit-transform: rotate(-45deg); } + 5% { + transform: rotate(-45deg); + -webkit-transform: rotate(-45deg); } + 12% { + transform: rotate(-405deg); + -webkit-transform: rotate(-405deg); } + 100% { + transform: rotate(-405deg); + -webkit-transform: rotate(-405deg); } } + +.animateSuccessTip { + -webkit-animation: animateSuccessTip 0.75s; + animation: animateSuccessTip 0.75s; } + +.animateSuccessLong { + -webkit-animation: animateSuccessLong 0.75s; + animation: animateSuccessLong 0.75s; } + +.sa-icon.sa-success.animate::after { + -webkit-animation: rotatePlaceholder 4.25s ease-in; + animation: rotatePlaceholder 4.25s ease-in; } + +@-webkit-keyframes animateErrorIcon { + 0% { + transform: rotateX(100deg); + -webkit-transform: rotateX(100deg); + opacity: 0; } + 100% { + transform: rotateX(0deg); + -webkit-transform: rotateX(0deg); + opacity: 1; } } + +@keyframes animateErrorIcon { + 0% { + transform: rotateX(100deg); + -webkit-transform: rotateX(100deg); + opacity: 0; } + 100% { + transform: rotateX(0deg); + -webkit-transform: rotateX(0deg); + opacity: 1; } } + +.animateErrorIcon { + -webkit-animation: animateErrorIcon 0.5s; + animation: animateErrorIcon 0.5s; } + +@-webkit-keyframes animateXMark { + 0% { + transform: scale(0.4); + -webkit-transform: scale(0.4); + margin-top: 26px; + opacity: 0; } + 50% { + transform: scale(0.4); + -webkit-transform: scale(0.4); + margin-top: 26px; + opacity: 0; } + 80% { + transform: scale(1.15); + -webkit-transform: scale(1.15); + margin-top: -6px; } + 100% { + transform: scale(1); + -webkit-transform: scale(1); + margin-top: 0; + opacity: 1; } } + +@keyframes animateXMark { + 0% { + transform: scale(0.4); + -webkit-transform: scale(0.4); + margin-top: 26px; + opacity: 0; } + 50% { + transform: scale(0.4); + -webkit-transform: scale(0.4); + margin-top: 26px; + opacity: 0; } + 80% { + transform: scale(1.15); + -webkit-transform: scale(1.15); + margin-top: -6px; } + 100% { + transform: scale(1); + -webkit-transform: scale(1); + margin-top: 0; + opacity: 1; } } + +.animateXMark { + -webkit-animation: animateXMark 0.5s; + animation: animateXMark 0.5s; } + +@-webkit-keyframes pulseWarning { + 0% { + border-color: #F8D486; } + 100% { + border-color: #F8BB86; } } + +@keyframes pulseWarning { + 0% { + border-color: #F8D486; } + 100% { + border-color: #F8BB86; } } + +.pulseWarning { + -webkit-animation: pulseWarning 0.75s infinite alternate; + animation: pulseWarning 0.75s infinite alternate; } + +@-webkit-keyframes pulseWarningIns { + 0% { + background-color: #F8D486; } + 100% { + background-color: #F8BB86; } } + +@keyframes pulseWarningIns { + 0% { + background-color: #F8D486; } + 100% { + background-color: #F8BB86; } } + +.pulseWarningIns { + -webkit-animation: pulseWarningIns 0.75s infinite alternate; + animation: pulseWarningIns 0.75s infinite alternate; } + +@-webkit-keyframes rotate-loading { + 0% { + transform: rotate(0deg); } + 100% { + transform: rotate(360deg); } } + +@keyframes rotate-loading { + 0% { + transform: rotate(0deg); } + 100% { + transform: rotate(360deg); } } + +/* Internet Explorer 9 has some special quirks that are fixed here */ +/* The icons are not animated. */ +/* This file is automatically merged into sweet-alert.min.js through Gulp */ +/* Error icon */ +.sweet-alert .sa-icon.sa-error .sa-line.sa-left { + -ms-transform: rotate(45deg) \9; } + +.sweet-alert .sa-icon.sa-error .sa-line.sa-right { + -ms-transform: rotate(-45deg) \9; } + +/* Success icon */ +.sweet-alert .sa-icon.sa-success { + border-color: transparent\9; } + +.sweet-alert .sa-icon.sa-success .sa-line.sa-tip { + -ms-transform: rotate(45deg) \9; } + +.sweet-alert .sa-icon.sa-success .sa-line.sa-long { + -ms-transform: rotate(-45deg) \9; } + +/*! + * Load Awesome v1.1.0 (http://github.danielcardoso.net/load-awesome/) + * Copyright 2015 Daniel Cardoso <@DanielCardoso> + * Licensed under MIT + */ +.la-ball-fall, +.la-ball-fall > div { + position: relative; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; } + +.la-ball-fall { + display: block; + font-size: 0; + color: #fff; } + +.la-ball-fall.la-dark { + color: #333; } + +.la-ball-fall > div { + display: inline-block; + float: none; + background-color: currentColor; + border: 0 solid currentColor; } + +.la-ball-fall { + width: 54px; + height: 18px; } + +.la-ball-fall > div { + width: 10px; + height: 10px; + margin: 4px; + border-radius: 100%; + opacity: 0; + -webkit-animation: ball-fall 1s ease-in-out infinite; + -moz-animation: ball-fall 1s ease-in-out infinite; + -o-animation: ball-fall 1s ease-in-out infinite; + animation: ball-fall 1s ease-in-out infinite; } + +.la-ball-fall > div:nth-child(1) { + -webkit-animation-delay: -200ms; + -moz-animation-delay: -200ms; + -o-animation-delay: -200ms; + animation-delay: -200ms; } + +.la-ball-fall > div:nth-child(2) { + -webkit-animation-delay: -100ms; + -moz-animation-delay: -100ms; + -o-animation-delay: -100ms; + animation-delay: -100ms; } + +.la-ball-fall > div:nth-child(3) { + -webkit-animation-delay: 0ms; + -moz-animation-delay: 0ms; + -o-animation-delay: 0ms; + animation-delay: 0ms; } + +.la-ball-fall.la-sm { + width: 26px; + height: 8px; } + +.la-ball-fall.la-sm > div { + width: 4px; + height: 4px; + margin: 2px; } + +.la-ball-fall.la-2x { + width: 108px; + height: 36px; } + +.la-ball-fall.la-2x > div { + width: 20px; + height: 20px; + margin: 8px; } + +.la-ball-fall.la-3x { + width: 162px; + height: 54px; } + +.la-ball-fall.la-3x > div { + width: 30px; + height: 30px; + margin: 12px; } + +/* + * Animation + */ +@-webkit-keyframes ball-fall { + 0% { + opacity: 0; + -webkit-transform: translateY(-145%); + transform: translateY(-145%); } + 10% { + opacity: .5; } + 20% { + opacity: 1; + -webkit-transform: translateY(0); + transform: translateY(0); } + 80% { + opacity: 1; + -webkit-transform: translateY(0); + transform: translateY(0); } + 90% { + opacity: .5; } + 100% { + opacity: 0; + -webkit-transform: translateY(145%); + transform: translateY(145%); } } + +@-moz-keyframes ball-fall { + 0% { + opacity: 0; + -moz-transform: translateY(-145%); + transform: translateY(-145%); } + 10% { + opacity: .5; } + 20% { + opacity: 1; + -moz-transform: translateY(0); + transform: translateY(0); } + 80% { + opacity: 1; + -moz-transform: translateY(0); + transform: translateY(0); } + 90% { + opacity: .5; } + 100% { + opacity: 0; + -moz-transform: translateY(145%); + transform: translateY(145%); } } + +@-o-keyframes ball-fall { + 0% { + opacity: 0; + -o-transform: translateY(-145%); + transform: translateY(-145%); } + 10% { + opacity: .5; } + 20% { + opacity: 1; + -o-transform: translateY(0); + transform: translateY(0); } + 80% { + opacity: 1; + -o-transform: translateY(0); + transform: translateY(0); } + 90% { + opacity: .5; } + 100% { + opacity: 0; + -o-transform: translateY(145%); + transform: translateY(145%); } } + +@keyframes ball-fall { + 0% { + opacity: 0; + -webkit-transform: translateY(-145%); + -moz-transform: translateY(-145%); + -o-transform: translateY(-145%); + transform: translateY(-145%); } + 10% { + opacity: .5; } + 20% { + opacity: 1; + -webkit-transform: translateY(0); + -moz-transform: translateY(0); + -o-transform: translateY(0); + transform: translateY(0); } + 80% { + opacity: 1; + -webkit-transform: translateY(0); + -moz-transform: translateY(0); + -o-transform: translateY(0); + transform: translateY(0); } + 90% { + opacity: .5; } + 100% { + opacity: 0; + -webkit-transform: translateY(145%); + -moz-transform: translateY(145%); + -o-transform: translateY(145%); + transform: translateY(145%); } } diff --git a/src/main/webapp/s/media/js/login.js b/src/main/webapp/s/media/js/login.js index 0fffb30..3e93c60 100644 --- a/src/main/webapp/s/media/js/login.js +++ b/src/main/webapp/s/media/js/login.js @@ -89,7 +89,7 @@ if (jData.success == true) { - window.location.href = $('#context').val()+"/content/ems/ems.jsp"; + window.location.href = $('#context').val()+"/content/ems/ems-gd.jsp"; } else { diff --git a/src/main/webapp/s/media/js/sweetalert.min.js b/src/main/webapp/s/media/js/sweetalert.min.js new file mode 100644 index 0000000..500bf92 --- /dev/null +++ b/src/main/webapp/s/media/js/sweetalert.min.js @@ -0,0 +1 @@ +!function(e,t,n){"use strict";!function o(e,t,n){function a(s,l){if(!t[s]){if(!e[s]){var i="function"==typeof require&&require;if(!l&&i)return i(s,!0);if(r)return r(s,!0);var u=new Error("Cannot find module '"+s+"'");throw u.code="MODULE_NOT_FOUND",u}var c=t[s]={exports:{}};e[s][0].call(c.exports,function(t){var n=e[s][1][t];return a(n?n:t)},c,c.exports,o,e,t,n)}return t[s].exports}for(var r="function"==typeof require&&require,s=0;s=0;)n=n.replace(" "+t+" "," ");e.className=n.replace(/^\s+|\s+$/g,"")}},i=function(e){var n=t.createElement("div");return n.appendChild(t.createTextNode(e)),n.innerHTML},u=function(e){e.style.opacity="",e.style.display="block"},c=function(e){if(e&&!e.length)return u(e);for(var t=0;t0?setTimeout(a,t):e.style.display="none"};o()},b=function(n){if("function"==typeof MouseEvent){var o=new MouseEvent("click",{view:e,bubbles:!1,cancelable:!0});n.dispatchEvent(o)}else if(t.createEvent){var a=t.createEvent("MouseEvents");a.initEvent("click",!1,!1),n.dispatchEvent(a)}else t.createEventObject?n.fireEvent("onclick"):"function"==typeof n.onclick&&n.onclick()},h=function(t){"function"==typeof t.stopPropagation?(t.stopPropagation(),t.preventDefault()):e.event&&e.event.hasOwnProperty("cancelBubble")&&(e.event.cancelBubble=!0)};a.hasClass=r,a.addClass=s,a.removeClass=l,a.escapeHtml=i,a._show=u,a.show=c,a._hide=d,a.hide=f,a.isDescendant=p,a.getTopMargin=m,a.fadeIn=v,a.fadeOut=y,a.fireClick=b,a.stopEventPropagation=h},{}],5:[function(t,o,a){Object.defineProperty(a,"__esModule",{value:!0});var r=t("./handle-dom"),s=t("./handle-swal-dom"),l=function(t,o,a){var l=t||e.event,i=l.keyCode||l.which,u=a.querySelector("button.confirm"),c=a.querySelector("button.cancel"),d=a.querySelectorAll("button[tabindex]");if(-1!==[9,13,32,27].indexOf(i)){for(var f=l.target||l.srcElement,p=-1,m=0;m"),i.innerHTML=e.html?e.text:(0,s.escapeHtml)(e.text||"").split("\n").join("
                                              "),e.text&&(0,s.show)(i),e.customClass)(0,s.addClass)(t,e.customClass),t.setAttribute("data-custom-class",e.customClass);else{var d=t.getAttribute("data-custom-class");(0,s.removeClass)(t,d),t.setAttribute("data-custom-class","")}if((0,s.hide)(t.querySelectorAll(".sa-icon")),e.type&&!(0,a.isIE8)()){var f=function(){for(var o=!1,a=0;ao;o++)n=parseInt(e.substr(2*o,2),16),n=Math.round(Math.min(Math.max(0,n+n*t),255)).toString(16),a+=("00"+n).substr(n.length);return a};o.extend=a,o.hexToRgb=r,o.isIE8=s,o.logStr=l,o.colorLuminance=i},{}]},{},[1]),"function"==typeof define&&define.amd?define(function(){return sweetAlert}):"undefined"!=typeof module&&module.exports&&(module.exports=sweetAlert)}(window,document); \ No newline at end of file