commit
78bb969274
366 changed files with 32889 additions and 0 deletions
@ -0,0 +1,70 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" |
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
||||
<parent> |
||||
<groupId>com.mh</groupId> |
||||
<artifactId>chws</artifactId> |
||||
<version>1.0-SNAPSHOT</version> |
||||
</parent> |
||||
<modelVersion>4.0.0</modelVersion> |
||||
|
||||
<groupId>com.mh</groupId> |
||||
<artifactId>common</artifactId> |
||||
<version>0.0.1-SNAPSHOT</version> |
||||
<packaging>jar</packaging> |
||||
|
||||
<properties> |
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> |
||||
<encoding>UTF-8</encoding> |
||||
<java.version>1.8</java.version> |
||||
<maven.compiler.source>1.8</maven.compiler.source> |
||||
<maven.compiler.target>1.8</maven.compiler.target> |
||||
</properties> |
||||
<dependencies> |
||||
|
||||
<!-- https://mvnrepository.com/artifact/com.alibaba.fastjson2/fastjson2 --> |
||||
<dependency> |
||||
<groupId>com.alibaba.fastjson2</groupId> |
||||
<artifactId>fastjson2</artifactId> |
||||
<version>2.0.41</version> |
||||
</dependency> |
||||
|
||||
<!-- https://mvnrepository.com/artifact/com.github.pagehelper/pagehelper-spring-boot-starter --> |
||||
<dependency> |
||||
<groupId>com.github.pagehelper</groupId> |
||||
<artifactId>pagehelper-spring-boot-starter</artifactId> |
||||
<version>1.4.7</version> |
||||
</dependency> |
||||
<!-- web --> |
||||
<dependency> |
||||
<groupId>org.springframework.boot</groupId> |
||||
<artifactId>spring-boot-starter-web</artifactId> |
||||
</dependency> |
||||
<!-- commons-beanutils --> |
||||
<dependency> |
||||
<groupId>commons-beanutils</groupId> |
||||
<artifactId>commons-beanutils</artifactId> |
||||
<version>1.9.4</version> |
||||
<exclusions> |
||||
<exclusion> |
||||
<groupId>commons-collections</groupId> |
||||
<artifactId>commons-collections</artifactId> |
||||
</exclusion> |
||||
</exclusions> |
||||
</dependency> |
||||
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-collections4 --> |
||||
<dependency> |
||||
<groupId>org.apache.commons</groupId> |
||||
<artifactId>commons-collections4</artifactId> |
||||
<version>4.4</version> |
||||
</dependency> |
||||
|
||||
<!-- poi --> |
||||
<dependency> |
||||
<groupId>org.apache.poi</groupId> |
||||
<artifactId>poi-ooxml</artifactId> |
||||
<version>5.2.4</version> |
||||
</dependency> |
||||
</dependencies> |
||||
</project> |
@ -0,0 +1,13 @@
|
||||
package com.mh.common.annotation; |
||||
|
||||
import java.lang.annotation.*; |
||||
|
||||
/** |
||||
* Created by fangzhipeng on 2017/7/12. |
||||
*/ |
||||
@Target(ElementType.METHOD) |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
@Documented |
||||
public @interface SysLogger { |
||||
String value() default ""; |
||||
} |
@ -0,0 +1,26 @@
|
||||
package com.mh.common.dto; |
||||
|
||||
import java.io.Serializable; |
||||
|
||||
public class RespDTO<T> implements Serializable{ |
||||
|
||||
|
||||
public int code = 0; |
||||
public String error = ""; |
||||
public T data; |
||||
|
||||
public static RespDTO onSuc(Object data) { |
||||
RespDTO resp = new RespDTO(); |
||||
resp.data = data; |
||||
return resp; |
||||
} |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return "RespDTO{" + |
||||
"code=" + code + |
||||
", error='" + error + '\'' + |
||||
", data=" + data + |
||||
'}'; |
||||
} |
||||
} |
@ -0,0 +1,96 @@
|
||||
package com.mh.common.http; |
||||
|
||||
/** |
||||
* HTTP结果封装 |
||||
* @author Louis |
||||
* @date Jan 12, 2019 |
||||
*/ |
||||
public class HttpResult { |
||||
|
||||
private int code = 200; // 为成功
|
||||
private String msg; // 消息
|
||||
private Object data; // 数据对象
|
||||
private int count; // 记录数
|
||||
|
||||
public static HttpResult error() { |
||||
|
||||
return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, "未知异常,请联系管理员"); |
||||
} |
||||
|
||||
public static HttpResult error(String msg) |
||||
{ |
||||
return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, msg); |
||||
} |
||||
|
||||
public static HttpResult error(int code, String msg) { |
||||
HttpResult r = new HttpResult(); |
||||
r.setCode(code); |
||||
r.setMsg(msg); |
||||
return r; |
||||
} |
||||
|
||||
public static HttpResult ok(String msg) { |
||||
HttpResult r = new HttpResult(); |
||||
r.setMsg(msg); |
||||
return r; |
||||
} |
||||
|
||||
public static HttpResult ok(Object data) { |
||||
HttpResult r = new HttpResult(); |
||||
r.setData(data); |
||||
return r; |
||||
} |
||||
|
||||
public static HttpResult ok(String msg, Object data) { |
||||
HttpResult r = new HttpResult(); |
||||
r.setMsg(msg); |
||||
r.setData(data); |
||||
return r; |
||||
} |
||||
|
||||
public static HttpResult ok(int count, Object data) { |
||||
HttpResult r = new HttpResult(); |
||||
r.setCount(count); |
||||
r.setData(data); |
||||
return r; |
||||
} |
||||
|
||||
public static HttpResult ok() { |
||||
HttpResult r = new HttpResult(); |
||||
r.setMsg("success"); |
||||
r.setCode(200); |
||||
return r; |
||||
} |
||||
|
||||
public int getCode() { |
||||
return code; |
||||
} |
||||
|
||||
public void setCode(int code) { |
||||
this.code = code; |
||||
} |
||||
|
||||
public String getMsg() { |
||||
return msg; |
||||
} |
||||
|
||||
public void setMsg(String msg) { |
||||
this.msg = msg; |
||||
} |
||||
|
||||
public Object getData() { |
||||
return data; |
||||
} |
||||
|
||||
public void setData(Object data) { |
||||
this.data = data; |
||||
} |
||||
|
||||
public int getCount() { |
||||
return count; |
||||
} |
||||
|
||||
public void setCount(int count) { |
||||
this.count = count; |
||||
} |
||||
} |
@ -0,0 +1,149 @@
|
||||
package com.mh.common.http; |
||||
|
||||
/** |
||||
* Constants enumerating the HTTP status codes. |
||||
* All status codes defined in RFC1945 (HTTP/1.0), RFC2616 (HTTP/1.1), and |
||||
* RFC2518 (WebDAV) are listed. |
||||
* |
||||
* |
||||
* |
||||
* @since 4.0 |
||||
*/ |
||||
public interface HttpStatus { |
||||
|
||||
// --- 1xx Informational ---
|
||||
|
||||
/** {@code 100 Continue} (HTTP/1.1 - RFC 2616) */ |
||||
public static final int SC_CONTINUE = 100; |
||||
/** {@code 101 Switching Protocols} (HTTP/1.1 - RFC 2616)*/ |
||||
public static final int SC_SWITCHING_PROTOCOLS = 101; |
||||
/** {@code 102 Processing} (WebDAV - RFC 2518) */ |
||||
public static final int SC_PROCESSING = 102; |
||||
|
||||
// --- 2xx Success ---
|
||||
|
||||
/** {@code 200 OK} (HTTP/1.0 - RFC 1945) */ |
||||
public static final int SC_OK = 200; |
||||
/** {@code 201 Created} (HTTP/1.0 - RFC 1945) */ |
||||
public static final int SC_CREATED = 201; |
||||
/** {@code 202 Accepted} (HTTP/1.0 - RFC 1945) */ |
||||
public static final int SC_ACCEPTED = 202; |
||||
/** {@code 203 Non Authoritative Information} (HTTP/1.1 - RFC 2616) */ |
||||
public static final int SC_NON_AUTHORITATIVE_INFORMATION = 203; |
||||
/** {@code 204 No Content} (HTTP/1.0 - RFC 1945) */ |
||||
public static final int SC_NO_CONTENT = 204; |
||||
/** {@code 205 Reset Content} (HTTP/1.1 - RFC 2616) */ |
||||
public static final int SC_RESET_CONTENT = 205; |
||||
/** {@code 206 Partial Content} (HTTP/1.1 - RFC 2616) */ |
||||
public static final int SC_PARTIAL_CONTENT = 206; |
||||
/** |
||||
* {@code 207 Multi-Status} (WebDAV - RFC 2518) |
||||
* or |
||||
* {@code 207 Partial Update OK} (HTTP/1.1 - draft-ietf-http-v11-spec-rev-01?) |
||||
*/ |
||||
public static final int SC_MULTI_STATUS = 207; |
||||
|
||||
// --- 3xx Redirection ---
|
||||
|
||||
/** {@code 300 Mutliple Choices} (HTTP/1.1 - RFC 2616) */ |
||||
public static final int SC_MULTIPLE_CHOICES = 300; |
||||
/** {@code 301 Moved Permanently} (HTTP/1.0 - RFC 1945) */ |
||||
public static final int SC_MOVED_PERMANENTLY = 301; |
||||
/** {@code 302 Moved Temporarily} (Sometimes {@code Found}) (HTTP/1.0 - RFC 1945) */ |
||||
public static final int SC_MOVED_TEMPORARILY = 302; |
||||
/** {@code 303 See Other} (HTTP/1.1 - RFC 2616) */ |
||||
public static final int SC_SEE_OTHER = 303; |
||||
/** {@code 304 Not Modified} (HTTP/1.0 - RFC 1945) */ |
||||
public static final int SC_NOT_MODIFIED = 304; |
||||
/** {@code 305 Use Proxy} (HTTP/1.1 - RFC 2616) */ |
||||
public static final int SC_USE_PROXY = 305; |
||||
/** {@code 307 Temporary Redirect} (HTTP/1.1 - RFC 2616) */ |
||||
public static final int SC_TEMPORARY_REDIRECT = 307; |
||||
|
||||
// --- 4xx Client Error ---
|
||||
|
||||
/** {@code 400 Bad Request} (HTTP/1.1 - RFC 2616) */ |
||||
public static final int SC_BAD_REQUEST = 400; |
||||
/** {@code 401 Unauthorized} (HTTP/1.0 - RFC 1945) */ |
||||
public static final int SC_UNAUTHORIZED = 401; |
||||
/** {@code 402 Payment Required} (HTTP/1.1 - RFC 2616) */ |
||||
public static final int SC_PAYMENT_REQUIRED = 402; |
||||
/** {@code 403 Forbidden} (HTTP/1.0 - RFC 1945) */ |
||||
public static final int SC_FORBIDDEN = 403; |
||||
/** {@code 404 Not Found} (HTTP/1.0 - RFC 1945) */ |
||||
public static final int SC_NOT_FOUND = 404; |
||||
/** {@code 405 Method Not Allowed} (HTTP/1.1 - RFC 2616) */ |
||||
public static final int SC_METHOD_NOT_ALLOWED = 405; |
||||
/** {@code 406 Not Acceptable} (HTTP/1.1 - RFC 2616) */ |
||||
public static final int SC_NOT_ACCEPTABLE = 406; |
||||
/** {@code 407 Proxy Authentication Required} (HTTP/1.1 - RFC 2616)*/ |
||||
public static final int SC_PROXY_AUTHENTICATION_REQUIRED = 407; |
||||
/** {@code 408 Request Timeout} (HTTP/1.1 - RFC 2616) */ |
||||
public static final int SC_REQUEST_TIMEOUT = 408; |
||||
/** {@code 409 Conflict} (HTTP/1.1 - RFC 2616) */ |
||||
public static final int SC_CONFLICT = 409; |
||||
/** {@code 410 Gone} (HTTP/1.1 - RFC 2616) */ |
||||
public static final int SC_GONE = 410; |
||||
/** {@code 411 Length Required} (HTTP/1.1 - RFC 2616) */ |
||||
public static final int SC_LENGTH_REQUIRED = 411; |
||||
/** {@code 412 Precondition Failed} (HTTP/1.1 - RFC 2616) */ |
||||
public static final int SC_PRECONDITION_FAILED = 412; |
||||
/** {@code 413 Request Entity Too Large} (HTTP/1.1 - RFC 2616) */ |
||||
public static final int SC_REQUEST_TOO_LONG = 413; |
||||
/** {@code 414 Request-URI Too Long} (HTTP/1.1 - RFC 2616) */ |
||||
public static final int SC_REQUEST_URI_TOO_LONG = 414; |
||||
/** {@code 415 Unsupported Media Type} (HTTP/1.1 - RFC 2616) */ |
||||
public static final int SC_UNSUPPORTED_MEDIA_TYPE = 415; |
||||
/** {@code 416 Requested Range Not Satisfiable} (HTTP/1.1 - RFC 2616) */ |
||||
public static final int SC_REQUESTED_RANGE_NOT_SATISFIABLE = 416; |
||||
/** {@code 417 Expectation Failed} (HTTP/1.1 - RFC 2616) */ |
||||
public static final int SC_EXPECTATION_FAILED = 417; |
||||
|
||||
/** |
||||
* Static constant for a 418 error. |
||||
* {@code 418 Unprocessable Entity} (WebDAV drafts?) |
||||
* or {@code 418 Reauthentication Required} (HTTP/1.1 drafts?) |
||||
*/ |
||||
// not used
|
||||
// public static final int SC_UNPROCESSABLE_ENTITY = 418;
|
||||
|
||||
/** |
||||
* Static constant for a 419 error. |
||||
* {@code 419 Insufficient Space on Resource} |
||||
* (WebDAV - draft-ietf-webdav-protocol-05?) |
||||
* or {@code 419 Proxy Reauthentication Required} |
||||
* (HTTP/1.1 drafts?) |
||||
*/ |
||||
public static final int SC_INSUFFICIENT_SPACE_ON_RESOURCE = 419; |
||||
/** |
||||
* Static constant for a 420 error. |
||||
* {@code 420 Method Failure} |
||||
* (WebDAV - draft-ietf-webdav-protocol-05?) |
||||
*/ |
||||
public static final int SC_METHOD_FAILURE = 420; |
||||
/** {@code 422 Unprocessable Entity} (WebDAV - RFC 2518) */ |
||||
public static final int SC_UNPROCESSABLE_ENTITY = 422; |
||||
/** {@code 423 Locked} (WebDAV - RFC 2518) */ |
||||
public static final int SC_LOCKED = 423; |
||||
/** {@code 424 Failed Dependency} (WebDAV - RFC 2518) */ |
||||
public static final int SC_FAILED_DEPENDENCY = 424; |
||||
|
||||
// --- 5xx Server Error ---
|
||||
|
||||
/** {@code 500 Server Error} (HTTP/1.0 - RFC 1945) */ |
||||
public static final int SC_INTERNAL_SERVER_ERROR = 500; |
||||
/** {@code 501 Not Implemented} (HTTP/1.0 - RFC 1945) */ |
||||
public static final int SC_NOT_IMPLEMENTED = 501; |
||||
/** {@code 502 Bad Gateway} (HTTP/1.0 - RFC 1945) */ |
||||
public static final int SC_BAD_GATEWAY = 502; |
||||
/** {@code 503 Service Unavailable} (HTTP/1.0 - RFC 1945) */ |
||||
public static final int SC_SERVICE_UNAVAILABLE = 503; |
||||
/** {@code 504 Gateway Timeout} (HTTP/1.1 - RFC 2616) */ |
||||
public static final int SC_GATEWAY_TIMEOUT = 504; |
||||
/** {@code 505 HTTP Version Not Supported} (HTTP/1.1 - RFC 2616) */ |
||||
public static final int SC_HTTP_VERSION_NOT_SUPPORTED = 505; |
||||
|
||||
/** {@code 507 Insufficient Storage} (WebDAV - RFC 2518) */ |
||||
public static final int SC_INSUFFICIENT_STORAGE = 507; |
||||
|
||||
} |
@ -0,0 +1,32 @@
|
||||
package com.mh.common.page; |
||||
|
||||
/** |
||||
* 分页查询列过滤器 |
||||
* @author Louis |
||||
* @date Aug 19, 2018 |
||||
*/ |
||||
public class ColumnFilter { |
||||
|
||||
/** |
||||
* 过滤列名 |
||||
*/ |
||||
private String name; |
||||
/** |
||||
* 查询的值 |
||||
*/ |
||||
private String value; |
||||
|
||||
public String getName() { |
||||
return name; |
||||
} |
||||
public void setName(String name) { |
||||
this.name = name; |
||||
} |
||||
public String getValue() { |
||||
return value; |
||||
} |
||||
public void setValue(String value) { |
||||
this.value = value; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,63 @@
|
||||
package com.mh.common.page; |
||||
|
||||
import java.util.List; |
||||
|
||||
import com.github.pagehelper.PageHelper; |
||||
import com.github.pagehelper.PageInfo; |
||||
import com.mh.common.utils.ReflectionUtils; |
||||
|
||||
/** |
||||
* MyBatis 分页查询助手 |
||||
* @author Louis |
||||
* @date Jan 12, 2019 |
||||
*/ |
||||
public class MybatisPageHelper { |
||||
|
||||
public static final String findPage = "findPage"; |
||||
|
||||
/** |
||||
* 分页查询, 约定查询方法名为 “findPage” |
||||
* @param pageRequest 分页请求 |
||||
* @param mapper Dao对象,MyBatis的 Mapper |
||||
* @param |
||||
* @return |
||||
*/ |
||||
public static PageResult findPage(PageRequest pageRequest, Object mapper) { |
||||
return findPage(pageRequest, mapper, findPage); |
||||
} |
||||
|
||||
/** |
||||
* 调用分页插件进行分页查询 |
||||
* @param pageRequest 分页请求 |
||||
* @param mapper Dao对象,MyBatis的 Mapper |
||||
* @param queryMethodName 要分页的查询方法名 |
||||
* @param args 方法参数 |
||||
* @return |
||||
*/ |
||||
@SuppressWarnings({ "unchecked", "rawtypes" }) |
||||
public static PageResult findPage(PageRequest pageRequest, Object mapper, String queryMethodName, Object... args) { |
||||
// 设置分页参数
|
||||
int pageNum = pageRequest.getPageNum(); |
||||
int pageSize = pageRequest.getPageSize(); |
||||
PageHelper.startPage(pageNum, pageSize); |
||||
// 利用反射调用查询方法
|
||||
Object result = ReflectionUtils.invoke(mapper, queryMethodName, args); |
||||
return getPageResult(pageRequest, new PageInfo((List) result)); |
||||
} |
||||
|
||||
/** |
||||
* 将分页信息封装到统一的接口 |
||||
* @param pageRequest |
||||
* @return |
||||
*/ |
||||
private static PageResult getPageResult(PageRequest pageRequest, PageInfo<?> pageInfo) { |
||||
PageResult pageResult = new PageResult(); |
||||
pageResult.setPageNum(pageInfo.getPageNum()); |
||||
pageResult.setPageSize(pageInfo.getPageSize()); |
||||
pageResult.setTotalSize(pageInfo.getTotal()); |
||||
pageResult.setTotalPages(pageInfo.getPages()); |
||||
pageResult.setContent(pageInfo.getList()); |
||||
return pageResult; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,46 @@
|
||||
package com.mh.common.page; |
||||
|
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* 分页请求 |
||||
* @author Louis |
||||
* @date Aug 19, 2018 |
||||
*/ |
||||
public class PageRequest { |
||||
/** |
||||
* 当前页码 |
||||
*/ |
||||
private int pageNum = 1; |
||||
/** |
||||
* 每页数量 |
||||
*/ |
||||
private int pageSize = 10; |
||||
/** |
||||
* 每页数量 |
||||
*/ |
||||
private Map<String, ColumnFilter> columnFilters = new HashMap<String, ColumnFilter>(); |
||||
|
||||
public int getPageNum() { |
||||
return pageNum; |
||||
} |
||||
public void setPageNum(int pageNum) { |
||||
this.pageNum = pageNum; |
||||
} |
||||
public int getPageSize() { |
||||
return pageSize; |
||||
} |
||||
public void setPageSize(int pageSize) { |
||||
this.pageSize = pageSize; |
||||
} |
||||
public Map<String, ColumnFilter> getColumnFilters() { |
||||
return columnFilters; |
||||
} |
||||
public void setColumnFilters(Map<String, ColumnFilter> columnFilters) { |
||||
this.columnFilters = columnFilters; |
||||
} |
||||
public ColumnFilter getColumnFilter(String name) { |
||||
return columnFilters.get(name); |
||||
} |
||||
} |
@ -0,0 +1,61 @@
|
||||
package com.mh.common.page; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 分页返回结果 |
||||
* @author Louis |
||||
* @date Jan 12, 2019 |
||||
*/ |
||||
public class PageResult { |
||||
/** |
||||
* 当前页码 |
||||
*/ |
||||
private int pageNum; |
||||
/** |
||||
* 每页数量 |
||||
*/ |
||||
private int pageSize; |
||||
/** |
||||
* 记录总数 |
||||
*/ |
||||
private long totalSize; |
||||
/** |
||||
* 页码总数 |
||||
*/ |
||||
private int totalPages; |
||||
/** |
||||
* 分页数据 |
||||
*/ |
||||
private List<?> content; |
||||
public int getPageNum() { |
||||
return pageNum; |
||||
} |
||||
public void setPageNum(int pageNum) { |
||||
this.pageNum = pageNum; |
||||
} |
||||
public int getPageSize() { |
||||
return pageSize; |
||||
} |
||||
public void setPageSize(int pageSize) { |
||||
this.pageSize = pageSize; |
||||
} |
||||
public long getTotalSize() { |
||||
return totalSize; |
||||
} |
||||
public void setTotalSize(long totalSize) { |
||||
this.totalSize = totalSize; |
||||
} |
||||
public int getTotalPages() { |
||||
return totalPages; |
||||
} |
||||
public void setTotalPages(int totalPages) { |
||||
this.totalPages = totalPages; |
||||
} |
||||
public List<?> getContent() { |
||||
return content; |
||||
} |
||||
public void setContent(List<?> content) { |
||||
this.content = content; |
||||
} |
||||
} |
@ -0,0 +1,50 @@
|
||||
package com.mh.common.service; |
||||
|
||||
import com.mh.common.page.PageRequest; |
||||
import com.mh.common.page.PageResult; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 通用CURD接口 |
||||
*/ |
||||
public interface CurdService<T> { |
||||
|
||||
/** |
||||
* 保存操作 |
||||
* @param record |
||||
* @return |
||||
*/ |
||||
int save(T record); |
||||
|
||||
/** |
||||
* 删除操作 |
||||
* @param record |
||||
* @return |
||||
*/ |
||||
int delete(T record); |
||||
|
||||
/** |
||||
* 批量删除操作 |
||||
* @param records |
||||
*/ |
||||
int delete(List<T> records); |
||||
|
||||
/** |
||||
* 根据ID查询 |
||||
* @param id |
||||
* @return |
||||
*/ |
||||
T findById(Long id); |
||||
|
||||
/** |
||||
* 分页查询 |
||||
* 这里统一封装了分页请求和结果,避免直接引入具体框架的分页对象, 如MyBatis或JPA的分页对象 |
||||
* 从而避免因为替换ORM框架而导致服务层、控制层的分页接口也需要变动的情况,替换ORM框架也不会 |
||||
* 影响服务层以上的分页接口,起到了解耦的作用 |
||||
* @param pageRequest 自定义,统一分页查询请求 |
||||
* @return PageResult 自定义,统一分页查询结果 |
||||
*/ |
||||
PageResult findPage(PageRequest pageRequest); |
||||
|
||||
} |
@ -0,0 +1,32 @@
|
||||
package com.mh.common.utils; |
||||
|
||||
import java.text.SimpleDateFormat; |
||||
import java.util.Date; |
||||
|
||||
/** |
||||
* 日期时间相关工具 |
||||
* @author Louis |
||||
* @date Jan 14, 2019 |
||||
*/ |
||||
public class DateTimeUtils { |
||||
|
||||
public static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss"; |
||||
|
||||
/** |
||||
* 获取当前标准格式化日期时间 |
||||
* @param date |
||||
* @return |
||||
*/ |
||||
public static String getDateTime() { |
||||
return getDateTime(new Date()); |
||||
} |
||||
|
||||
/** |
||||
* 标准格式化日期时间 |
||||
* @param date |
||||
* @return |
||||
*/ |
||||
public static String getDateTime(Date date) { |
||||
return (new SimpleDateFormat(DATE_FORMAT)).format(date); |
||||
} |
||||
} |
@ -0,0 +1,42 @@
|
||||
package com.mh.common.utils; |
||||
|
||||
import javax.servlet.http.HttpServletResponse; |
||||
import java.io.BufferedInputStream; |
||||
import java.io.BufferedOutputStream; |
||||
import java.io.File; |
||||
import java.io.FileInputStream; |
||||
import java.io.InputStream; |
||||
|
||||
/** |
||||
* 文件相关操作 |
||||
* @author Louis |
||||
* @date Jan 14, 2019 |
||||
*/ |
||||
public class FileUtils { |
||||
|
||||
/** |
||||
* 下载文件 |
||||
* @param response |
||||
* @param file |
||||
* @param newFileName |
||||
*/ |
||||
public static void downloadFile(HttpServletResponse response, File file, String newFileName) { |
||||
try { |
||||
response.setHeader("Content-Disposition", "attachment; filename=" + new String(newFileName.getBytes("ISO-8859-1"), "UTF-8")); |
||||
BufferedOutputStream bos = new BufferedOutputStream(response.getOutputStream()); |
||||
InputStream is = new FileInputStream(file.getAbsolutePath()); |
||||
BufferedInputStream bis = new BufferedInputStream(is); |
||||
int length = 0; |
||||
byte[] temp = new byte[1 * 1024 * 10]; |
||||
while ((length = bis.read(temp)) != -1) { |
||||
bos.write(temp, 0, length); |
||||
} |
||||
bos.flush(); |
||||
bis.close(); |
||||
bos.close(); |
||||
is.close(); |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,26 @@
|
||||
package com.mh.common.utils; |
||||
|
||||
import java.io.Closeable; |
||||
import java.io.IOException; |
||||
|
||||
/** |
||||
* IO相关工具类 |
||||
* @author Louis |
||||
* @date Oct 29, 2018 |
||||
*/ |
||||
public class IOUtils { |
||||
|
||||
/** |
||||
* 关闭对象,连接 |
||||
* @param closeable |
||||
*/ |
||||
public static void closeQuietly(final Closeable closeable) { |
||||
try { |
||||
if (closeable != null) { |
||||
closeable.close(); |
||||
} |
||||
} catch (final IOException ioe) { |
||||
// ignore
|
||||
} |
||||
} |
||||
} |
@ -0,0 +1,41 @@
|
||||
//package com.mh.common.utils;
|
||||
//
|
||||
//import java.io.File;
|
||||
//import java.io.FileNotFoundException;
|
||||
//import java.io.FileOutputStream;
|
||||
//import java.io.IOException;
|
||||
//import java.io.OutputStream;
|
||||
//
|
||||
//import org.apache.poi.ss.usermodel.Workbook;
|
||||
//
|
||||
///**
|
||||
// * POI相关操作
|
||||
// * @author Louis
|
||||
// * @date Jan 14, 2019
|
||||
// */
|
||||
//public class PoiUtils {
|
||||
//
|
||||
// /**
|
||||
// * 生成Excel文件
|
||||
// * @param workbook
|
||||
// * @param fileName
|
||||
// * @return
|
||||
// */
|
||||
// public static File createExcelFile(Workbook workbook, String fileName) {
|
||||
// OutputStream stream = null;
|
||||
// File file = null;
|
||||
// try {
|
||||
// file = File.createTempFile(fileName, ".xlsx");
|
||||
// stream = new FileOutputStream(file.getAbsoluteFile());
|
||||
// workbook.write(stream);
|
||||
// } catch (FileNotFoundException e) {
|
||||
// e.printStackTrace();
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// } finally {
|
||||
// IOUtils.closeQuietly(workbook);
|
||||
// IOUtils.closeQuietly(stream);
|
||||
// }
|
||||
// return file;
|
||||
// }
|
||||
//}
|
@ -0,0 +1,78 @@
|
||||
package com.mh.common.utils; |
||||
|
||||
import java.lang.reflect.InvocationTargetException; |
||||
import java.lang.reflect.Method; |
||||
|
||||
/** |
||||
* 反射相关辅助方法 |
||||
* @author Louis |
||||
* @date Aug 19, 2018 |
||||
*/ |
||||
public class ReflectionUtils { |
||||
|
||||
|
||||
/** |
||||
* 根据方法名调用指定对象的方法 |
||||
* @param object 要调用方法的对象 |
||||
* @param method 要调用的方法名 |
||||
* @param args 参数对象数组 |
||||
* @return |
||||
*/ |
||||
public static Object invoke(Object object, String method, Object... args) { |
||||
Object result = null; |
||||
Class<? extends Object> clazz = object.getClass(); |
||||
Method queryMethod = getMethod(clazz, method, args); |
||||
if(queryMethod != null) { |
||||
try { |
||||
result = queryMethod.invoke(object, args); |
||||
} catch (IllegalAccessException e) { |
||||
e.printStackTrace(); |
||||
} catch (IllegalArgumentException e) { |
||||
e.printStackTrace(); |
||||
} catch (InvocationTargetException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
} else { |
||||
try { |
||||
throw new NoSuchMethodException(clazz.getName() + " 类中没有找到 " + method + " 方法。"); |
||||
} catch (NoSuchMethodException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
return result; |
||||
} |
||||
|
||||
/** |
||||
* 根据方法名和参数对象查找方法 |
||||
* @param clazz |
||||
* @param name |
||||
* @param args 参数实例数据 |
||||
* @return |
||||
*/ |
||||
public static Method getMethod(Class<? extends Object> clazz, String name, Object[] args) { |
||||
Method queryMethod = null; |
||||
Method[] methods = clazz.getMethods(); |
||||
for(Method method:methods) { |
||||
if(method.getName().equals(name)) { |
||||
Class<?>[] parameterTypes = method.getParameterTypes(); |
||||
if(parameterTypes.length == args.length) { |
||||
boolean isSameMethod = true; |
||||
for(int i=0; i<parameterTypes.length; i++) { |
||||
Object arg = args[i]; |
||||
if(arg == null) { |
||||
arg = ""; |
||||
} |
||||
if(!parameterTypes[i].equals(args[i].getClass())) { |
||||
isSameMethod = false; |
||||
} |
||||
} |
||||
if(isSameMethod) { |
||||
queryMethod = method; |
||||
break ; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
return queryMethod; |
||||
} |
||||
} |
@ -0,0 +1,19 @@
|
||||
package com.mh.common.utils; |
||||
|
||||
/** |
||||
* 字符串工具类 |
||||
* @author Louis |
||||
* @date Sep 1, 2018 |
||||
*/ |
||||
public class StringUtils { |
||||
|
||||
/** |
||||
* 判空操作 |
||||
* @param value |
||||
* @return |
||||
*/ |
||||
public static boolean isBlank(String value) { |
||||
return value == null || "".equals(value) || "null".equals(value) || "undefined".equals(value); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,88 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" |
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
||||
<modelVersion>4.0.0</modelVersion> |
||||
|
||||
<groupId>com.mh</groupId> |
||||
<artifactId>chws</artifactId> |
||||
<version>1.0-SNAPSHOT</version> |
||||
<packaging>pom</packaging> |
||||
<modules> |
||||
<module>common</module> |
||||
<module>user-service</module> |
||||
</modules> |
||||
|
||||
<parent> |
||||
<groupId>org.springframework.boot</groupId> |
||||
<artifactId>spring-boot-starter-parent</artifactId> |
||||
<version>2.2.5.RELEASE</version> |
||||
<relativePath/> <!-- lookup parent from repository --> |
||||
</parent> |
||||
|
||||
<properties> |
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> |
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> |
||||
<java.version>1.8</java.version> |
||||
<spring-cloud.version>Hoxton.SR3</spring-cloud.version> |
||||
<swagger.version>2.9.2</swagger.version> |
||||
</properties> |
||||
|
||||
<dependencies> |
||||
<dependency> |
||||
<groupId>org.springframework.boot</groupId> |
||||
<artifactId>spring-boot-starter-test</artifactId> |
||||
<scope>test</scope> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.jolokia</groupId> |
||||
<artifactId>jolokia-core</artifactId> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>io.springfox</groupId> |
||||
<artifactId>springfox-swagger2</artifactId> |
||||
<version>${swagger.version}</version> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>io.springfox</groupId> |
||||
<artifactId>springfox-swagger-ui</artifactId> |
||||
<version>${swagger.version}</version> |
||||
</dependency> |
||||
<!-- 添加consul依赖--> |
||||
<!-- <dependency>--> |
||||
<!-- <groupId>org.springframework.cloud</groupId>--> |
||||
<!-- <artifactId>spring-cloud-starter-consul-discovery</artifactId>--> |
||||
<!-- </dependency>--> |
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-aop --> |
||||
<dependency> |
||||
<groupId>org.springframework.boot</groupId> |
||||
<artifactId>spring-boot-starter-aop</artifactId> |
||||
<version>2.2.5.RELEASE</version> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.rxtx</groupId> |
||||
<artifactId>rxtx</artifactId> |
||||
<version>2.1.7</version> |
||||
</dependency> |
||||
<!--串口开发--> |
||||
<dependency> |
||||
<groupId>com.github.purejavacomm</groupId> |
||||
<artifactId>purejavacomm</artifactId> |
||||
<version>1.0.1.RELEASE</version> |
||||
</dependency> |
||||
|
||||
</dependencies> |
||||
|
||||
<dependencyManagement> |
||||
<dependencies> |
||||
<dependency> |
||||
<groupId>org.springframework.cloud</groupId> |
||||
<artifactId>spring-cloud-dependencies</artifactId> |
||||
<version>${spring-cloud.version}</version> |
||||
<type>pom</type> |
||||
<scope>import</scope> |
||||
</dependency> |
||||
</dependencies> |
||||
</dependencyManagement> |
||||
</project> |
Binary file not shown.
@ -0,0 +1,186 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> |
||||
<modelVersion>4.0.0</modelVersion> |
||||
<parent> |
||||
<groupId>com.mh</groupId> |
||||
<artifactId>chws</artifactId> |
||||
<version>1.0-SNAPSHOT</version> |
||||
</parent> |
||||
<groupId>com.mh</groupId> |
||||
<artifactId>user-service</artifactId> |
||||
<version>0.0.1-SNAPSHOT</version> |
||||
<name>user-service</name> |
||||
<packaging>jar</packaging> |
||||
<description>Demo project for Spring Boot</description> |
||||
|
||||
<properties> |
||||
<java.version>1.8</java.version> |
||||
<spring-cloud.version>Hoxton.SR3</spring-cloud.version> |
||||
</properties> |
||||
|
||||
<dependencies> |
||||
<dependency> |
||||
<groupId>org.springframework.boot</groupId> |
||||
<artifactId>spring-boot-starter-web</artifactId> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.springframework.boot</groupId> |
||||
<artifactId>spring-boot-starter-tomcat</artifactId> |
||||
<scope>import</scope> |
||||
<!-- <scope>provided</scope>--> |
||||
<!-- 当时本地启动需要注释掉--> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.springframework.boot</groupId> |
||||
<artifactId>spring-boot-starter-quartz</artifactId> |
||||
</dependency> |
||||
<!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-config --> |
||||
<dependency> |
||||
<groupId>org.springframework.cloud</groupId> |
||||
<artifactId>spring-cloud-starter-config</artifactId> |
||||
<version>2.2.2.RELEASE</version> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.springframework.boot</groupId> |
||||
<artifactId>spring-boot-starter-test</artifactId> |
||||
<scope>test</scope> |
||||
<exclusions> |
||||
<exclusion> |
||||
<groupId>org.junit.vintage</groupId> |
||||
<artifactId>junit-vintage-engine</artifactId> |
||||
</exclusion> |
||||
</exclusions> |
||||
</dependency> |
||||
<!-- mybatis配置--> |
||||
<dependency> |
||||
<groupId>org.mybatis.spring.boot</groupId> |
||||
<artifactId>mybatis-spring-boot-starter</artifactId> |
||||
<version>2.3.0</version> |
||||
</dependency> |
||||
<!-- <!– mysql数据库链接–>--> |
||||
<!-- <dependency>--> |
||||
<!-- <groupId>mysql</groupId>--> |
||||
<!-- <artifactId>mysql-connector-java</artifactId>--> |
||||
<!-- </dependency>--> |
||||
<!-- druid配置--> |
||||
<dependency> |
||||
<groupId>com.alibaba</groupId> |
||||
<artifactId>druid-spring-boot-starter</artifactId> |
||||
<version>1.1.18</version> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>com.microsoft.sqlserver</groupId> |
||||
<artifactId>mssql-jdbc</artifactId> |
||||
<scope>runtime</scope> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>io.netty</groupId> |
||||
<artifactId>netty-all</artifactId> |
||||
<version>5.0.0.Alpha2</version> |
||||
</dependency> |
||||
<!-- 登录验证码--> |
||||
<dependency> |
||||
<groupId>com.github.penggle</groupId> |
||||
<artifactId>kaptcha</artifactId> |
||||
<version>2.3.2</version> |
||||
</dependency> |
||||
<!-- spring security安全验证--> |
||||
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-security --> |
||||
<dependency> |
||||
<groupId>org.springframework.boot</groupId> |
||||
<artifactId>spring-boot-starter-security</artifactId> |
||||
</dependency> |
||||
|
||||
<!-- jwt(json web token)验证--> |
||||
<!-- https://mvnrepository.com/artifact/io.jsonwebtoken/jjwt --> |
||||
<dependency> |
||||
<groupId>io.jsonwebtoken</groupId> |
||||
<artifactId>jjwt</artifactId> |
||||
<version>0.9.1</version> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>com.mh</groupId> |
||||
<artifactId>common</artifactId> |
||||
<version>0.0.1-SNAPSHOT</version> |
||||
</dependency> |
||||
|
||||
<!-- 添加consul依赖--> |
||||
<!-- <dependency>--> |
||||
<!-- <groupId>org.springframework.cloud</groupId>--> |
||||
<!-- <artifactId>spring-cloud-starter-consul-discovery</artifactId>--> |
||||
<!-- </dependency>--> |
||||
|
||||
<!--spring-boot-admin --> |
||||
<dependency> |
||||
<groupId>de.codecentric</groupId> |
||||
<artifactId>spring-boot-admin-starter-client</artifactId> |
||||
<version>2.2.2</version> |
||||
</dependency> |
||||
<!-- Lombok--> |
||||
<dependency> |
||||
<groupId>org.projectlombok</groupId> |
||||
<artifactId>lombok</artifactId> |
||||
<optional>true</optional> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>tk.mybatis</groupId> |
||||
<artifactId>mapper</artifactId> |
||||
<version>3.3.9</version> |
||||
</dependency> |
||||
|
||||
<dependency> |
||||
<groupId>org.apache.commons</groupId> |
||||
<artifactId>commons-pool2</artifactId> |
||||
</dependency> |
||||
|
||||
</dependencies> |
||||
<dependencyManagement> |
||||
<dependencies> |
||||
<dependency> |
||||
<groupId>org.springframework.cloud</groupId> |
||||
<artifactId>spring-cloud-dependencies</artifactId> |
||||
<version>${spring-cloud.version}</version> |
||||
<type>pom</type> |
||||
<scope>import</scope> |
||||
</dependency> |
||||
</dependencies> |
||||
</dependencyManagement> |
||||
|
||||
<build> |
||||
<!-- 打包时拷贝MyBatis的映射文件 --> |
||||
<resources> |
||||
<resource> |
||||
<directory>src/main/java</directory> |
||||
<includes> |
||||
<include>**/sqlmapper/*.xml</include> |
||||
</includes> |
||||
<filtering>false</filtering> |
||||
</resource> |
||||
<resource> |
||||
<directory>src/main/resources</directory> |
||||
<includes> |
||||
<include>**/*.*</include> |
||||
</includes> |
||||
<filtering>true</filtering> |
||||
</resource> |
||||
</resources> |
||||
<plugins> |
||||
<plugin> |
||||
<groupId>org.springframework.boot</groupId> |
||||
<artifactId>spring-boot-maven-plugin</artifactId> |
||||
<version>2.7.2</version> |
||||
</plugin> |
||||
<!-- <plugin>--> |
||||
<!-- <groupId>org.apache.maven.plugins</groupId>--> |
||||
<!-- <artifactId>maven-resources-plugin</artifactId>--> |
||||
<!-- <version>3.1.0</version>--> |
||||
<!-- <configuration>--> |
||||
<!-- <encoding>UTF-8</encoding>--> |
||||
<!-- </configuration>--> |
||||
<!-- </plugin>--> |
||||
</plugins> |
||||
</build> |
||||
|
||||
</project> |
@ -0,0 +1,37 @@
|
||||
package com.mh.user; |
||||
|
||||
import com.mh.user.job.CollectionLoopRunner; |
||||
import com.mh.user.serialport.SerialPortListener; |
||||
import com.mh.user.serialport.SerialPortUtil; |
||||
import com.mh.user.utils.TimedTask2; |
||||
import org.springframework.boot.SpringApplication; |
||||
import org.springframework.boot.autoconfigure.SpringBootApplication; |
||||
import org.springframework.boot.builder.SpringApplicationBuilder; |
||||
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; |
||||
import org.springframework.scheduling.annotation.EnableScheduling; |
||||
|
||||
import javax.annotation.PreDestroy; |
||||
|
||||
@SpringBootApplication(scanBasePackages = "com.mh.user") |
||||
@EnableScheduling |
||||
public class UserServiceApplication extends SpringBootServletInitializer { |
||||
|
||||
@Override |
||||
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { |
||||
return builder.sources(UserServiceApplication.class); |
||||
} |
||||
|
||||
public static void main(String[] args) { |
||||
|
||||
SpringApplication.run(UserServiceApplication.class, args); |
||||
} |
||||
|
||||
@PreDestroy |
||||
public void destory() { |
||||
//关闭应用前 关闭端口
|
||||
SerialPortUtil serialPortUtil = SerialPortUtil.getSerialPortUtil(); |
||||
serialPortUtil.removeListener(CollectionLoopRunner.serialPort, new SerialPortListener()); |
||||
serialPortUtil.closePort(CollectionLoopRunner.serialPort); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,30 @@
|
||||
package com.mh.user.annotation; |
||||
|
||||
public enum BusinessType { |
||||
|
||||
OTHER("其它"), |
||||
SELECT("查找"), |
||||
INSERT("新增"), |
||||
UPDATE("修改"), |
||||
DELETE("删除"); |
||||
|
||||
private String label; |
||||
|
||||
BusinessType(String label) { |
||||
this.label = label; |
||||
} |
||||
|
||||
public String getLabel() { |
||||
return label; |
||||
} |
||||
|
||||
public void setLabel(String label) { |
||||
this.label = label; |
||||
} |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return label; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,15 @@
|
||||
package com.mh.user.annotation; |
||||
|
||||
import java.lang.annotation.*; |
||||
|
||||
/** |
||||
* Created by nxr on 2023/8/18. |
||||
*/ |
||||
@Target(ElementType.METHOD) |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
@Documented |
||||
public @interface SysLogger { |
||||
|
||||
String title() default ""; // 自定义操作模块
|
||||
String optDesc() default ""; // 业务操作描述
|
||||
} |
@ -0,0 +1,91 @@
|
||||
package com.mh.user.aspect; |
||||
|
||||
import java.util.Date; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
|
||||
import com.mh.common.utils.StringUtils; |
||||
import com.mh.user.utils.SecurityUtils; |
||||
import org.apache.commons.beanutils.BeanUtils; |
||||
import org.aspectj.lang.ProceedingJoinPoint; |
||||
import org.aspectj.lang.annotation.Around; |
||||
import org.aspectj.lang.annotation.Aspect; |
||||
import org.aspectj.lang.annotation.Pointcut; |
||||
import org.springframework.context.annotation.Configuration; |
||||
import org.springframework.stereotype.Component; |
||||
import org.springframework.web.context.request.RequestContextHolder; |
||||
import org.springframework.web.context.request.ServletRequestAttributes; |
||||
|
||||
/** |
||||
* DAO切面,插入创建人,创建时间,修改人,修改时间 |
||||
* @author Louis |
||||
* @date Oct 29, 2018 |
||||
*/ |
||||
@Aspect |
||||
@Component |
||||
@Configuration |
||||
public class DaoAspect { |
||||
private static final String createBy = "createBy"; |
||||
private static final String createTime = "createTime"; |
||||
private static final String lastUpdateBy = "lastUpdateBy"; |
||||
private static final String lastUpdateTime = "lastUpdateTime"; |
||||
|
||||
@Pointcut("execution(* com.mh.*.mapper.*.update*(..))") |
||||
public void daoUpdate() { |
||||
} |
||||
|
||||
@Pointcut("execution(* com.mh.*.mapper.*.insert*(..))") |
||||
public void daoCreate() { |
||||
} |
||||
|
||||
@Around("daoUpdate()") |
||||
public Object doAroundUpdate(ProceedingJoinPoint pjp) throws Throwable { |
||||
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); |
||||
if (attributes == null) { |
||||
return pjp.proceed(); |
||||
} |
||||
HttpServletRequest request = attributes.getRequest(); |
||||
String token = request.getHeader("token"); |
||||
String username = getUserName(); |
||||
if (token != null && username != null) { |
||||
Object[] objects = pjp.getArgs(); |
||||
if (objects != null && objects.length > 0) { |
||||
for (Object arg : objects) { |
||||
BeanUtils.setProperty(arg, lastUpdateBy, username); |
||||
BeanUtils.setProperty(arg, lastUpdateTime, new Date()); |
||||
} |
||||
} |
||||
} |
||||
Object object = pjp.proceed(); |
||||
return object; |
||||
|
||||
} |
||||
|
||||
@Around("daoCreate()") |
||||
public Object doAroundCreate(ProceedingJoinPoint pjp) throws Throwable { |
||||
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); |
||||
if (attributes == null) { |
||||
return pjp.proceed(); |
||||
} |
||||
Object[] objects = pjp.getArgs(); |
||||
if (objects != null && objects.length > 0) { |
||||
for (Object arg : objects) { |
||||
String username = getUserName(); |
||||
if (username != null) { |
||||
if (StringUtils.isBlank(BeanUtils.getProperty(arg, createBy))) { |
||||
BeanUtils.setProperty(arg, createBy, username); |
||||
} |
||||
if (StringUtils.isBlank(BeanUtils.getProperty(arg, createTime))) { |
||||
BeanUtils.setProperty(arg, createTime, new Date()); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
Object object = pjp.proceed(); |
||||
return object; |
||||
} |
||||
|
||||
private String getUserName() { |
||||
return SecurityUtils.getUsername(); |
||||
} |
||||
} |
@ -0,0 +1,126 @@
|
||||
package com.mh.user.aspect; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
|
||||
import com.alibaba.fastjson2.JSONObject; |
||||
import com.mh.user.annotation.SysLogger; |
||||
import com.mh.user.model.SysLog; |
||||
import com.mh.user.service.SysLogService; |
||||
import com.mh.user.utils.HttpUtils; |
||||
import com.mh.user.utils.IPUtils; |
||||
import com.mh.user.utils.SecurityUtils; |
||||
import org.aspectj.lang.JoinPoint; |
||||
import org.aspectj.lang.ProceedingJoinPoint; |
||||
import org.aspectj.lang.annotation.Around; |
||||
import org.aspectj.lang.annotation.Aspect; |
||||
import org.aspectj.lang.annotation.Pointcut; |
||||
import org.aspectj.lang.reflect.MethodSignature; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
import java.lang.reflect.Method; |
||||
import java.util.Date; |
||||
|
||||
|
||||
/** |
||||
* 系统日志,切面处理类,记录日志 |
||||
*/ |
||||
@Aspect |
||||
@Component |
||||
public class SysLogAspect { |
||||
|
||||
@Autowired |
||||
private SysLogService sysLogService; |
||||
|
||||
// @Pointcut("execution(* com.mh.*.service.*.*(..))")
|
||||
@Pointcut("@annotation(com.mh.user.annotation.SysLogger)") |
||||
public void logPointCut() { |
||||
|
||||
} |
||||
|
||||
@Around("logPointCut()") |
||||
public Object around(ProceedingJoinPoint point) throws Throwable { |
||||
long beginTime = System.currentTimeMillis(); |
||||
// 执行方法
|
||||
Object result = point.proceed(); |
||||
// 执行时长(毫秒)
|
||||
long time = System.currentTimeMillis() - beginTime; |
||||
// 保存日志
|
||||
saveSysLog(point, time); |
||||
return result; |
||||
|
||||
} |
||||
|
||||
private void saveSysLog(ProceedingJoinPoint joinPoint, long time) { |
||||
SysLog sysLog = new SysLog(); |
||||
String methodName = joinPoint.getSignature().getName(); |
||||
Method method = currentMethod(joinPoint,methodName); |
||||
SysLogger sysLogger = method.getAnnotation(SysLogger.class); |
||||
String module = sysLogger.title(); //操作模块
|
||||
String optDesc=sysLogger.optDesc();//业务操作描述
|
||||
sysLog.setOptDesc(optDesc); |
||||
sysLog.setOperation(module); |
||||
String userName = SecurityUtils.getUsername(); //用户名称
|
||||
|
||||
if(joinPoint.getTarget() instanceof SysLogService) { |
||||
return ; |
||||
} |
||||
MethodSignature signature = (MethodSignature) joinPoint.getSignature(); |
||||
|
||||
// 请求的方法名
|
||||
String className = joinPoint.getTarget().getClass().getName(); |
||||
String methodName1 = signature.getName(); |
||||
sysLog.setMethod(className + "." + methodName1 + "()"); |
||||
|
||||
// 请求的参数
|
||||
Object[] args = joinPoint.getArgs(); |
||||
try{ |
||||
String params = JSONObject.toJSONString(args[0]); |
||||
if(params.length() > 200) { |
||||
params = params.substring(0, 200) + "..."; |
||||
} |
||||
sysLog.setParams(params); |
||||
} catch (Exception e){ |
||||
} |
||||
// 获取request
|
||||
HttpServletRequest request = HttpUtils.getHttpServletRequest(); |
||||
// 设置IP地址
|
||||
sysLog.setIp(IPUtils.getIpAddr(request)); |
||||
String ip=IPUtils.getRemoteIp(); |
||||
// 用户名
|
||||
sysLog.setUserName(userName); |
||||
Date date1 = SecurityUtils.getLoginTime(); |
||||
// 登录时间
|
||||
sysLog.setCreateTime(date1); |
||||
Date date=new Date(); |
||||
// 最后操作时间
|
||||
sysLog.setLastUpdateTime(date); |
||||
// 执行时长(毫秒)
|
||||
sysLog.setTime(time); |
||||
// 保存系统日志
|
||||
sysLogService.save(sysLog); |
||||
} |
||||
|
||||
/** |
||||
* 获取当前执行的方法 |
||||
* |
||||
* @param joinPoint 连接点 |
||||
* @param methodName 方法名称 |
||||
* @return 方法 |
||||
*/ |
||||
private Method currentMethod(JoinPoint joinPoint, String methodName) { |
||||
/** |
||||
* 获取目标类的所有方法,找到当前要执行的方法 |
||||
*/ |
||||
Method[] methods = joinPoint.getTarget().getClass().getMethods(); |
||||
Method resultMethod = null; |
||||
for (Method method : methods) { |
||||
if (method.getName().equals(methodName)) { |
||||
resultMethod = method; |
||||
break; |
||||
} |
||||
} |
||||
return resultMethod; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,40 @@
|
||||
package com.mh.user.config; |
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.context.annotation.Configuration; |
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry; |
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry; |
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; |
||||
|
||||
/** |
||||
* 跨域配置 |
||||
* @author Louis |
||||
* @date Oct 29, 2018 |
||||
*/ |
||||
@Configuration |
||||
public class CorsConfig implements WebMvcConfigurer { |
||||
|
||||
|
||||
@Autowired(required = false) |
||||
private PrimessionInterceptor primessionInterceptor; |
||||
|
||||
/** |
||||
* 注册拦截器 |
||||
*/ |
||||
@Override |
||||
public void addInterceptors(InterceptorRegistry registry) { |
||||
registry.addInterceptor(primessionInterceptor); |
||||
} |
||||
|
||||
|
||||
@Override |
||||
public void addCorsMappings(CorsRegistry registry) { |
||||
registry.addMapping("/**") // 允许跨域访问的路径
|
||||
.allowedOrigins("*") // 允许跨域访问的源
|
||||
.allowedMethods("POST", "GET", "PUT", "OPTIONS", "DELETE") // 允许请求方法
|
||||
.maxAge(168000) // 预检间隔时间
|
||||
.allowedHeaders("*") // 允许头部设置
|
||||
.allowCredentials(true); // 是否发送cookie
|
||||
} |
||||
|
||||
} |
@ -0,0 +1,117 @@
|
||||
package com.mh.user.config; |
||||
|
||||
import java.sql.SQLException; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
import javax.servlet.Filter; |
||||
import javax.servlet.Servlet; |
||||
import javax.sql.DataSource; |
||||
|
||||
import com.alibaba.druid.wall.WallConfig; |
||||
import com.alibaba.druid.wall.WallFilter; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; |
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties; |
||||
import org.springframework.boot.web.servlet.FilterRegistrationBean; |
||||
import org.springframework.boot.web.servlet.ServletRegistrationBean; |
||||
import org.springframework.context.annotation.Bean; |
||||
import org.springframework.context.annotation.Configuration; |
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource; |
||||
import com.alibaba.druid.support.http.StatViewServlet; |
||||
import com.alibaba.druid.support.http.WebStatFilter; |
||||
|
||||
/** |
||||
* @author ljf |
||||
* @title : |
||||
* @description : |
||||
* @updateTime 2020-03-13 |
||||
* @throws : |
||||
*/ |
||||
@Configuration |
||||
@EnableConfigurationProperties({DruidDataSourceProperties.class}) |
||||
public class DruidConfig { |
||||
@Autowired |
||||
private DruidDataSourceProperties properties; |
||||
|
||||
@Bean |
||||
@ConditionalOnMissingBean |
||||
public DataSource druidDataSource() { |
||||
DruidDataSource druidDataSource = new DruidDataSource(); |
||||
druidDataSource.setDriverClassName(properties.getDriverClassName()); |
||||
druidDataSource.setUrl(properties.getUrl()); |
||||
druidDataSource.setUsername(properties.getUsername()); |
||||
druidDataSource.setPassword(properties.getPassword()); |
||||
druidDataSource.setInitialSize(properties.getInitialSize()); |
||||
druidDataSource.setMinIdle(properties.getMinIdle()); |
||||
druidDataSource.setMaxActive(properties.getMaxActive()); |
||||
druidDataSource.setMaxWait(properties.getMaxWait()); |
||||
druidDataSource.setTimeBetweenEvictionRunsMillis(properties.getTimeBetweenEvictionRunsMillis()); |
||||
druidDataSource.setMinEvictableIdleTimeMillis(properties.getMinEvictableIdleTimeMillis()); |
||||
druidDataSource.setValidationQuery(properties.getValidationQuery()); |
||||
druidDataSource.setTestWhileIdle(properties.isTestWhileIdle()); |
||||
druidDataSource.setTestOnBorrow(properties.isTestOnBorrow()); |
||||
druidDataSource.setTestOnReturn(properties.isTestOnReturn()); |
||||
druidDataSource.setPoolPreparedStatements(properties.isPoolPreparedStatements()); |
||||
druidDataSource.setMaxPoolPreparedStatementPerConnectionSize(properties.getMaxPoolPreparedStatementPerConnectionSize()); |
||||
|
||||
List list=new ArrayList<>(); |
||||
WallFilter wallFilter=new WallFilter(); |
||||
WallConfig config = new WallConfig(); |
||||
//允许一次执行多条语句
|
||||
config.setMultiStatementAllow(true); |
||||
//允许非基本语句的其他语句
|
||||
//config.setNoneBaseStatementAllow(true);
|
||||
wallFilter.setConfig(config); |
||||
list.add(wallFilter); |
||||
druidDataSource.setProxyFilters(list); |
||||
|
||||
try { |
||||
druidDataSource.setFilters(properties.getFilters()); |
||||
druidDataSource.init(); |
||||
} catch (SQLException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
|
||||
return druidDataSource; |
||||
} |
||||
|
||||
/** |
||||
* 注册Servlet信息, 配置监控视图 |
||||
* |
||||
* @return |
||||
*/ |
||||
@Bean |
||||
@ConditionalOnMissingBean |
||||
public ServletRegistrationBean<Servlet> druidServlet() { |
||||
ServletRegistrationBean<Servlet> servletRegistrationBean = new ServletRegistrationBean<Servlet>(new StatViewServlet(), "/druid/*"); |
||||
|
||||
//白名单:
|
||||
// servletRegistrationBean.addInitParameter("allow","127.0.0.1,139.196.87.48");
|
||||
//IP黑名单 (存在共同时,deny优先于allow) : 如果满足deny的话提示:Sorry, you are not permitted to view this page.
|
||||
servletRegistrationBean.addInitParameter("deny","192.168.1.222"); |
||||
//登录查看信息的账号密码, 用于登录Druid监控后台
|
||||
servletRegistrationBean.addInitParameter("loginUsername", "admin"); |
||||
servletRegistrationBean.addInitParameter("loginPassword", "admin"); |
||||
//是否能够重置数据.
|
||||
servletRegistrationBean.addInitParameter("resetEnable", "true"); |
||||
return servletRegistrationBean; |
||||
|
||||
} |
||||
|
||||
/** |
||||
* 注册Filter信息, 监控拦截器 |
||||
* |
||||
* @return |
||||
*/ |
||||
@Bean |
||||
@ConditionalOnMissingBean |
||||
public FilterRegistrationBean<Filter> filterRegistrationBean() { |
||||
FilterRegistrationBean<Filter> filterRegistrationBean = new FilterRegistrationBean<Filter>(); |
||||
filterRegistrationBean.setFilter(new WebStatFilter()); |
||||
filterRegistrationBean.addUrlPatterns("/*"); |
||||
filterRegistrationBean.addInitParameter("exclusions", "*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*"); |
||||
return filterRegistrationBean; |
||||
} |
||||
} |
@ -0,0 +1,172 @@
|
||||
package com.mh.user.config; |
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties; |
||||
|
||||
/** |
||||
* @author ljf |
||||
* @title : |
||||
* @description : |
||||
* @updateTime 2020-03-13 |
||||
* @throws : |
||||
*/ |
||||
@ConfigurationProperties(prefix = "spring.datasource.druid") |
||||
public class DruidDataSourceProperties { |
||||
|
||||
// jdbc
|
||||
private String driverClassName; |
||||
private String url; |
||||
private String username; |
||||
private String password; |
||||
// jdbc connection pool
|
||||
private int initialSize; |
||||
private int minIdle; |
||||
private int maxActive = 100; |
||||
private long maxWait; |
||||
private long timeBetweenEvictionRunsMillis; |
||||
private long minEvictableIdleTimeMillis; |
||||
private String validationQuery; |
||||
private boolean testWhileIdle; |
||||
private boolean testOnBorrow; |
||||
private boolean testOnReturn; |
||||
private boolean poolPreparedStatements; |
||||
private int maxPoolPreparedStatementPerConnectionSize; |
||||
// filter
|
||||
private String filters; |
||||
|
||||
public int getInitialSize() { |
||||
return initialSize; |
||||
} |
||||
|
||||
public void setInitialSize(int initialSize) { |
||||
this.initialSize = initialSize; |
||||
} |
||||
|
||||
public int getMinIdle() { |
||||
return minIdle; |
||||
} |
||||
|
||||
public void setMinIdle(int minIdle) { |
||||
this.minIdle = minIdle; |
||||
} |
||||
|
||||
public int getMaxActive() { |
||||
return maxActive; |
||||
} |
||||
|
||||
public void setMaxActive(int maxActive) { |
||||
this.maxActive = maxActive; |
||||
} |
||||
|
||||
public long getMaxWait() { |
||||
return maxWait; |
||||
} |
||||
|
||||
public void setMaxWait(long maxWait) { |
||||
this.maxWait = maxWait; |
||||
} |
||||
|
||||
public long getTimeBetweenEvictionRunsMillis() { |
||||
return timeBetweenEvictionRunsMillis; |
||||
} |
||||
|
||||
public void setTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis) { |
||||
this.timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis; |
||||
} |
||||
|
||||
public long getMinEvictableIdleTimeMillis() { |
||||
return minEvictableIdleTimeMillis; |
||||
} |
||||
|
||||
public void setMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis) { |
||||
this.minEvictableIdleTimeMillis = minEvictableIdleTimeMillis; |
||||
} |
||||
|
||||
public String getValidationQuery() { |
||||
return validationQuery; |
||||
} |
||||
|
||||
public void setValidationQuery(String validationQuery) { |
||||
this.validationQuery = validationQuery; |
||||
} |
||||
|
||||
public boolean isTestWhileIdle() { |
||||
return testWhileIdle; |
||||
} |
||||
|
||||
public void setTestWhileIdle(boolean testWhileIdle) { |
||||
this.testWhileIdle = testWhileIdle; |
||||
} |
||||
|
||||
public boolean isTestOnBorrow() { |
||||
return testOnBorrow; |
||||
} |
||||
|
||||
public void setTestOnBorrow(boolean testOnBorrow) { |
||||
this.testOnBorrow = testOnBorrow; |
||||
} |
||||
|
||||
public boolean isTestOnReturn() { |
||||
return testOnReturn; |
||||
} |
||||
|
||||
public void setTestOnReturn(boolean testOnReturn) { |
||||
this.testOnReturn = testOnReturn; |
||||
} |
||||
|
||||
public boolean isPoolPreparedStatements() { |
||||
return poolPreparedStatements; |
||||
} |
||||
|
||||
public void setPoolPreparedStatements(boolean poolPreparedStatements) { |
||||
this.poolPreparedStatements = poolPreparedStatements; |
||||
} |
||||
|
||||
public int getMaxPoolPreparedStatementPerConnectionSize() { |
||||
return maxPoolPreparedStatementPerConnectionSize; |
||||
} |
||||
|
||||
public void setMaxPoolPreparedStatementPerConnectionSize(int maxPoolPreparedStatementPerConnectionSize) { |
||||
this.maxPoolPreparedStatementPerConnectionSize = maxPoolPreparedStatementPerConnectionSize; |
||||
} |
||||
|
||||
public String getFilters() { |
||||
return filters; |
||||
} |
||||
|
||||
public void setFilters(String filters) { |
||||
this.filters = filters; |
||||
} |
||||
|
||||
public String getDriverClassName() { |
||||
return driverClassName; |
||||
} |
||||
|
||||
public void setDriverClassName(String driverClassName) { |
||||
this.driverClassName = driverClassName; |
||||
} |
||||
|
||||
public String getUrl() { |
||||
return url; |
||||
} |
||||
|
||||
public void setUrl(String url) { |
||||
this.url = url; |
||||
} |
||||
|
||||
public String getUsername() { |
||||
return username; |
||||
} |
||||
|
||||
public void setUsername(String username) { |
||||
this.username = username; |
||||
} |
||||
|
||||
public String getPassword() { |
||||
return password; |
||||
} |
||||
|
||||
public void setPassword(String password) { |
||||
this.password = password; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,17 @@
|
||||
package com.mh.user.config; |
||||
|
||||
import com.alibaba.druid.support.http.StatViewServlet; |
||||
|
||||
/** |
||||
* druid监控视图配置 |
||||
*/ |
||||
//@WebServlet(urlPatterns = "/druid/*", initParams={
|
||||
// @WebInitParam(name="allow",value="192.168.6.195"), // IP白名单 (没有配置或者为空,则允许所有访问)
|
||||
// @WebInitParam(name="deny",value="192.168.6.73"), // IP黑名单 (存在共同时,deny优先于allow)
|
||||
// @WebInitParam(name="loginUsername",value="admin"), // 用户名
|
||||
// @WebInitParam(name="loginPassword",value="admin"), // 密码
|
||||
// @WebInitParam(name="resetEnable",value="true") // 禁用HTML页面上的“Reset All”功能
|
||||
//})
|
||||
//public class DruidStatViewServlet extends StatViewServlet {
|
||||
// private static final long serialVersionUID = 7359758657306626394L;
|
||||
//}
|
@ -0,0 +1,56 @@
|
||||
package com.mh.user.config; |
||||
|
||||
import com.google.code.kaptcha.impl.DefaultKaptcha; |
||||
import com.google.code.kaptcha.util.Config; |
||||
import org.springframework.context.annotation.Bean; |
||||
import org.springframework.context.annotation.Configuration; |
||||
|
||||
import java.util.Properties; |
||||
|
||||
/** |
||||
* author:ljf |
||||
* update:2020-03-13 |
||||
* description:登陆验证码 |
||||
*/ |
||||
@Configuration |
||||
public class KaptchaConfig { |
||||
|
||||
@Bean |
||||
public DefaultKaptcha getDefaultKaptcha(){ |
||||
DefaultKaptcha defaultKaptcha = new DefaultKaptcha(); |
||||
Properties properties = new Properties(); |
||||
// 图片边框,合法值:yes[默认] , no
|
||||
properties.setProperty("kaptcha.border", "no"); |
||||
// 边框颜色,合法值: r,g,b (and optional alpha) 或者 white,black,blue.默认black
|
||||
properties.setProperty("kaptcha.border.color", "105,179,90"); |
||||
// 边框厚度,合法值:>0,默认1
|
||||
// properties.setProperty("kaptcha.border.thickness", "1");
|
||||
// 图片宽,默认200
|
||||
properties.setProperty("kaptcha.image.width", "110"); |
||||
// 图片高,默认50
|
||||
properties.setProperty("kaptcha.image.height", "40"); |
||||
// 字体大小,默认40px
|
||||
properties.setProperty("kaptcha.textproducer.font.size", "35"); |
||||
// 字体,默认Arial, Courier
|
||||
properties.setProperty("kaptcha.textproducer.font.names", "宋体,楷体,微软雅黑"); |
||||
// 字体颜色,合法值: r,g,b 或者 white,black,blue.默认black
|
||||
properties.setProperty("kaptcha.textproducer.font.color", "blue"); |
||||
// session key,默认KAPTCHA_SESSION_KEY
|
||||
properties.setProperty("kaptcha.session.key", "code"); |
||||
// session date,默认KAPTCHA_SESSION_DATE
|
||||
// properties.setProperty("kaptcha.session.date", "KAPTCHA_SESSION_DATE");
|
||||
// 验证码长度,默认5
|
||||
properties.setProperty("kaptcha.textproducer.char.length", "4"); |
||||
// 文字间隔,默认2
|
||||
properties.setProperty("kaptcha.textproducer.char.space", "5"); |
||||
// 干扰 颜色,合法值: r,g,b 或者 white,black,blue.默认black
|
||||
// properties.setProperty("kaptcha.noise.color", "black");
|
||||
// 更多可参考:https://blog.csdn.net/elephantboy/article/details/52795309
|
||||
|
||||
Config config = new Config(properties); |
||||
defaultKaptcha.setConfig(config); |
||||
|
||||
return defaultKaptcha; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,68 @@
|
||||
package com.mh.user.config; |
||||
|
||||
import com.alibaba.fastjson2.JSON; |
||||
import com.alibaba.fastjson2.JSONObject; |
||||
import com.mh.user.dynamic.datasource.DataSourceContextHolder; |
||||
import com.mh.user.dynamic.datasource.DataSourceObject; |
||||
import com.mh.user.entity.DBEntity; |
||||
import com.mh.user.service.SysUserService; |
||||
import com.mh.user.utils.JwtTokenUtils; |
||||
import com.mh.user.utils.AESUtil; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Component; |
||||
import org.springframework.web.servlet.HandlerInterceptor; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
|
||||
/** |
||||
* @author chison |
||||
* @date 2020-09-03 08:44 |
||||
* @Description 请求拦截器 |
||||
*/ |
||||
@Component |
||||
public class PrimessionInterceptor implements HandlerInterceptor { |
||||
|
||||
|
||||
@Autowired |
||||
private SysUserService sysUserService; |
||||
|
||||
/** |
||||
* 根据token获取用户项目信息,对数据源进行切换 |
||||
* @param request |
||||
* @param response |
||||
* @param handler |
||||
* @return |
||||
* @throws Exception |
||||
*/ |
||||
@Override |
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { |
||||
String token = request.getHeader("token"); |
||||
if (token != null && token.contains("token")) { |
||||
JSONObject jsonObject = (JSONObject) JSON.parse(token); |
||||
System.out.println("header---->" + jsonObject.get("token")); |
||||
if (jsonObject.get("token") !=null ) { |
||||
token = jsonObject.get("token").toString(); |
||||
} |
||||
System.out.println(" token==> " + token); |
||||
} |
||||
String uri = request.getRequestURI(); |
||||
System.out.println(uri); |
||||
DataSourceContextHolder.setDBType("default"); |
||||
// 除了中间库业务的请求都使用多数据源切换
|
||||
// if(!(uri.contains("/sysUser") || uri.contains("/sysRole") || uri.contains("/sysMenu") )){
|
||||
// if(token != null){
|
||||
// String userName = JwtTokenUtils.getUsernameFromToken(token);
|
||||
// System.out.println(userName);
|
||||
// DBEntity dbEntity = sysUserService.queryDBInfo(userName);
|
||||
// dbEntity.setDB_Pwd(AESUtil.AESdecrypt(dbEntity.getDB_Pwd()));
|
||||
// // 切换数据源
|
||||
// DataSourceObject dataSourceObject = new DataSourceObject();
|
||||
// String SourceName = "sqlServer-"+dbEntity.getDB_Names();
|
||||
// dataSourceObject.SwitchSQLServerDataSource(dbEntity,SourceName);
|
||||
// DataSourceContextHolder.setDBType(SourceName);
|
||||
// }
|
||||
// }
|
||||
return true; |
||||
} |
||||
} |
@ -0,0 +1,60 @@
|
||||
package com.mh.user.config; |
||||
|
||||
import com.mh.user.job.JobFactory; |
||||
import com.mh.user.utils.TimedTask2; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.quartz.Scheduler; |
||||
import org.springframework.context.annotation.Bean; |
||||
import org.springframework.context.annotation.Configuration; |
||||
import org.springframework.scheduling.quartz.SchedulerFactoryBean; |
||||
|
||||
/** |
||||
* @author ljf |
||||
* @title : Quartz配置 |
||||
* @description : |
||||
* @updateTime 2020-04-03 |
||||
* @throws : |
||||
*/ |
||||
@Slf4j |
||||
@Configuration |
||||
public class QuartzConfig { |
||||
|
||||
private JobFactory jobFactory; |
||||
|
||||
/** |
||||
* @author jinhaoxun |
||||
* @description 构造器 |
||||
* @param jobFactory |
||||
*/ |
||||
public QuartzConfig(JobFactory jobFactory){ |
||||
this.jobFactory = jobFactory; |
||||
} |
||||
|
||||
/** |
||||
* @author jinhaoxun |
||||
* @description 配置SchedulerFactoryBean,将一个方法产生为Bean并交给Spring容器管理 |
||||
* @return SchedulerFactoryBean |
||||
*/ |
||||
@Bean |
||||
public SchedulerFactoryBean schedulerFactoryBean() { |
||||
// log.info("开始注入定时任务调度器工厂...");
|
||||
System.out.println("开始注入定时任务调度器工厂..."); |
||||
SchedulerFactoryBean factory = new SchedulerFactoryBean();// Spring提供SchedulerFactoryBean为Scheduler提供配置信息,并被Spring容器管理其生命周期
|
||||
factory.setJobFactory(jobFactory);// 设置自定义Job Factory,用于Spring管理Job bean
|
||||
factory.setOverwriteExistingJobs(true);// 覆盖存在的定时任务
|
||||
factory.setStartupDelay(30); //延时30秒启动定时任务,避免系统未完全启动却开始执行定时任务的情况
|
||||
// log.info("注入定时任务调度器工厂成功!");
|
||||
System.out.println("注入定时任务调度器工厂成功!"); |
||||
// TimedTask2 timedTask2=new TimedTask2();
|
||||
// timedTask2.cronJob();
|
||||
// System.out.println("定点启动任务!");
|
||||
return factory; |
||||
} |
||||
|
||||
@Bean(name = "scheduler") |
||||
public Scheduler scheduler() { |
||||
System.out.println("进来了---------------!"); |
||||
return schedulerFactoryBean().getScheduler(); |
||||
|
||||
} |
||||
} |
@ -0,0 +1,14 @@
|
||||
package com.mh.user.config; |
||||
|
||||
import org.springframework.context.annotation.Configuration; |
||||
|
||||
/** |
||||
* @author ljf |
||||
* @title : |
||||
* @description : redis配置 |
||||
* @updateTime 2020-08-20 |
||||
* @throws : |
||||
*/ |
||||
@Configuration |
||||
public class RestTemplateConfig { |
||||
} |
@ -0,0 +1,50 @@
|
||||
package com.mh.user.config; |
||||
|
||||
import org.springframework.context.annotation.Bean; |
||||
import org.springframework.context.annotation.Configuration; |
||||
import springfox.documentation.builders.ApiInfoBuilder; |
||||
import springfox.documentation.builders.ParameterBuilder; |
||||
import springfox.documentation.builders.PathSelectors; |
||||
import springfox.documentation.builders.RequestHandlerSelectors; |
||||
import springfox.documentation.schema.ModelRef; |
||||
import springfox.documentation.service.ApiInfo; |
||||
import springfox.documentation.service.Parameter; |
||||
import springfox.documentation.spi.DocumentationType; |
||||
import springfox.documentation.spring.web.plugins.Docket; |
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author ljf |
||||
* @title : |
||||
* @description : |
||||
* @updateTime 2020-03-13 |
||||
* @throws : |
||||
*/ |
||||
@Configuration |
||||
@EnableSwagger2 |
||||
public class SwaggerConfig { |
||||
|
||||
@Bean |
||||
public Docket createRestApi(){ |
||||
// 添加请求参数,我们这里把token作为请求头部参数传入后端
|
||||
ParameterBuilder parameterBuilder = new ParameterBuilder(); |
||||
List<Parameter> parameters = new ArrayList<Parameter>(); |
||||
parameterBuilder.name("token").description("令牌") |
||||
.modelRef(new ModelRef("string")).parameterType("header").required(false).build(); |
||||
parameters.add(parameterBuilder.build()); |
||||
return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select() |
||||
.apis(RequestHandlerSelectors.any()).paths(PathSelectors.any()) |
||||
.build().globalOperationParameters(parameters); |
||||
// return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select()
|
||||
// .apis(RequestHandlerSelectors.any()).paths(PathSelectors.any()).build();
|
||||
} |
||||
|
||||
private ApiInfo apiInfo(){ |
||||
return new ApiInfoBuilder().build(); |
||||
} |
||||
|
||||
|
||||
} |
@ -0,0 +1,81 @@
|
||||
package com.mh.user.config; |
||||
|
||||
import com.mh.user.security.JwtAuthenticationFilter; |
||||
import com.mh.user.security.JwtAuthenticationProvider; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.beans.factory.annotation.Qualifier; |
||||
import org.springframework.context.annotation.Bean; |
||||
import org.springframework.context.annotation.Configuration; |
||||
import org.springframework.http.HttpMethod; |
||||
import org.springframework.security.authentication.AuthenticationManager; |
||||
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; |
||||
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; |
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity; |
||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; |
||||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; |
||||
import org.springframework.security.core.userdetails.UserDetailsService; |
||||
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; |
||||
import org.springframework.security.web.authentication.logout.HttpStatusReturningLogoutSuccessHandler; |
||||
import org.springframework.web.cors.CorsUtils; |
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry; |
||||
|
||||
/** |
||||
* Spring Security配置 |
||||
* @author Louis |
||||
* @date Jan 14, 2019 |
||||
*/ |
||||
@Configuration |
||||
@EnableWebSecurity // 开启Spring Security
|
||||
//@EnableGlobalMethodSecurity(prePostEnabled = true) // 开启权限注解,如:@PreAuthorize注解
|
||||
public class WebSecurityConfig extends WebSecurityConfigurerAdapter { |
||||
|
||||
@Qualifier("userDetailsServiceImpl") |
||||
@Autowired |
||||
private UserDetailsService userDetailsService; |
||||
|
||||
@Override |
||||
public void configure(AuthenticationManagerBuilder auth) throws Exception { |
||||
// 使用自定义身份验证组件
|
||||
auth.authenticationProvider(new JwtAuthenticationProvider(userDetailsService)); |
||||
} |
||||
|
||||
@Override |
||||
protected void configure(HttpSecurity http) throws Exception { |
||||
// 禁用 csrf, 由于使用的是JWT,我们这里不需要csrf
|
||||
// http.cors().and().csrf().disable()
|
||||
// .authorizeRequests()
|
||||
// // 跨域预检请求
|
||||
// .antMatchers(HttpMethod.OPTIONS, "/**").permitAll()
|
||||
// // web jars
|
||||
// .antMatchers("/webjars/**").permitAll()
|
||||
// // 查看SQL监控(druid)
|
||||
// .antMatchers("/druid/**").permitAll()
|
||||
// // 首页和登录页面
|
||||
// .antMatchers("/").permitAll()
|
||||
// .antMatchers("/login").permitAll()
|
||||
// // swagger
|
||||
// .antMatchers("/swagger-ui.html").permitAll()
|
||||
// .antMatchers("/swagger-resources/**").permitAll()
|
||||
// .antMatchers("/v2/api-docs").permitAll()
|
||||
// .antMatchers("/webjars/springfox-swagger-ui/**").permitAll()
|
||||
// // 验证码
|
||||
// .antMatchers("/captcha.jpg**").permitAll()
|
||||
// // 服务监控
|
||||
// .antMatchers("/actuator/**").permitAll()
|
||||
// // 其他所有请求需要身份认证
|
||||
// .anyRequest().authenticated();
|
||||
// // 退出登录处理器
|
||||
// http.logout().logoutSuccessHandler(new HttpStatusReturningLogoutSuccessHandler());
|
||||
// // token验证过滤器
|
||||
// http.addFilterBefore(new JwtAuthenticationFilter(authenticationManager()), UsernamePasswordAuthenticationFilter.class);
|
||||
// 禁用token验证
|
||||
http.csrf().disable().authorizeRequests().anyRequest().permitAll().and().logout().permitAll(); |
||||
} |
||||
|
||||
@Bean |
||||
@Override |
||||
public AuthenticationManager authenticationManager() throws Exception { |
||||
return super.authenticationManager(); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,17 @@
|
||||
package com.mh.user.constants; |
||||
|
||||
/** |
||||
* @author ljf |
||||
* @title : |
||||
* @description : 存放一些公共全局参数 |
||||
* @updateTime 2020-05-29 |
||||
* @throws : |
||||
*/ |
||||
public class Constant { |
||||
|
||||
public static boolean CONTROL_WEB_FLAG = false; |
||||
public static boolean SEND_STATUS = false; // 指令发送状态
|
||||
public static boolean FLAG = false; |
||||
public static boolean WEB_FLAG = false; // 判断是否有前端指令下发
|
||||
|
||||
} |
@ -0,0 +1,33 @@
|
||||
package com.mh.user.constants; |
||||
|
||||
import lombok.Getter; |
||||
import lombok.Setter; |
||||
import org.springframework.beans.factory.annotation.Value; |
||||
import org.springframework.boot.context.properties.ConfigurationProperties; |
||||
import org.springframework.context.annotation.PropertySource; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
/** |
||||
* @author ljf |
||||
* @title : |
||||
* @description : |
||||
* @updateTime 2020-06-09 |
||||
* @throws : |
||||
*/ |
||||
@PropertySource("classpath:socket.yml") |
||||
@ConfigurationProperties(prefix = "socket") |
||||
@Setter |
||||
@Getter |
||||
@Component |
||||
public class SocketMessage { |
||||
|
||||
@Value("${IP}") |
||||
private String IP; |
||||
|
||||
@Value("${port}") |
||||
private int port; |
||||
|
||||
@Value("${overtime}") |
||||
private int overTime; |
||||
|
||||
} |
@ -0,0 +1,11 @@
|
||||
package com.mh.user.constants; |
||||
|
||||
/** |
||||
* author: ljf |
||||
* desc: 系统常量值 |
||||
*/ |
||||
public interface SysConstants { |
||||
|
||||
// 系统管理员用户名
|
||||
String ADMIN = "admin"; |
||||
} |
@ -0,0 +1,172 @@
|
||||
package com.mh.user.controller; |
||||
|
||||
import com.mh.common.http.HttpResult; |
||||
import com.mh.user.annotation.BusinessType; |
||||
import com.mh.user.annotation.SysLogger; |
||||
import com.mh.user.entity.AlarmInfoEntity; |
||||
import com.mh.user.entity.AlarmValueSetEntity; |
||||
import com.mh.user.entity.EnergyEntity; |
||||
import com.mh.user.model.BuildingModel; |
||||
import com.mh.user.service.AlarmInfoService; |
||||
import com.mh.user.service.BuildingService; |
||||
import com.mh.user.service.DealDataService; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import java.text.SimpleDateFormat; |
||||
import java.util.ArrayList; |
||||
import java.util.Date; |
||||
import java.util.List; |
||||
|
||||
@RestController |
||||
@RequestMapping("alarm") |
||||
public class AlarmInfoController { |
||||
|
||||
@Autowired |
||||
AlarmInfoService alarmInfoService; |
||||
|
||||
@Autowired |
||||
BuildingService buildingService; |
||||
|
||||
@Autowired |
||||
DealDataService dealDataService; |
||||
|
||||
@SysLogger(title="报警信息",optDesc ="保存报修信息") |
||||
@PostMapping("/save") |
||||
public HttpResult saveAlarmInfo(@RequestBody AlarmInfoEntity alarmInfoEntity){ |
||||
try{ |
||||
alarmInfoService.saveAlarmInfo(alarmInfoEntity); |
||||
return HttpResult.ok(); |
||||
}catch (Exception e){ |
||||
return HttpResult.error(500,"保存出错!"); |
||||
} |
||||
|
||||
} |
||||
|
||||
@SysLogger(title="报警信息",optDesc = "修改报警信息") |
||||
@PostMapping("/update") |
||||
public HttpResult updateAlarmInfo(@RequestBody AlarmInfoEntity alarmInfoEntity){ |
||||
try{ |
||||
alarmInfoService.updateAlarmInfo(alarmInfoEntity); |
||||
return HttpResult.ok(); |
||||
}catch (Exception e){ |
||||
return HttpResult.error(500,"修改出错!"); |
||||
} |
||||
|
||||
} |
||||
|
||||
@SysLogger(title="报警信息",optDesc = "删除报警信息") |
||||
@PostMapping("/delete") |
||||
public HttpResult deleteAlarmInfo(@RequestParam(value = "id") String id){ |
||||
try{ |
||||
alarmInfoService.deleteAlarmInfo(id); |
||||
return HttpResult.ok(); |
||||
}catch (Exception e){ |
||||
return HttpResult.error("删除出错!"); |
||||
} |
||||
} |
||||
|
||||
@SysLogger(title="报警信息",optDesc = "查询报警信息") |
||||
@PostMapping("/query") |
||||
public HttpResult queryAlarmInfo(@RequestParam(value = "alarmTime",required = false) String alarmTime, |
||||
@RequestParam(value = "alarmType",required = false) String alarmType, |
||||
@RequestParam(value = "buildingId",required = false) String buildingId, |
||||
@RequestParam(value = "dealState",required = false) String dealState, |
||||
@RequestParam(value = "page",required = true) int page, |
||||
@RequestParam(value = "limit",required = true) int limit){ |
||||
try{ |
||||
List<AlarmInfoEntity> list; |
||||
list=alarmInfoService.queryAlarmInfo(alarmTime,alarmType,buildingId,dealState,page,limit); |
||||
int count=alarmInfoService.getAlarmInfoCount(alarmTime,alarmType,buildingId,dealState,page,limit); |
||||
return HttpResult.ok(count,list); |
||||
}catch (Exception e){ |
||||
e.printStackTrace(); |
||||
return HttpResult.error("查询出错!"); |
||||
} |
||||
} |
||||
|
||||
@SysLogger(title="报警设置",optDesc = "保存报警设置信息") |
||||
@PostMapping("/set") |
||||
public HttpResult saveAlarmValueSet(@RequestBody AlarmValueSetEntity alarmValueSetEntity){ |
||||
try{ |
||||
String type=alarmValueSetEntity.getType(); |
||||
String itemType=alarmValueSetEntity.getItemType(); |
||||
if (type==null || type.equals("") || type.equals("0")){ |
||||
String buildingId=alarmValueSetEntity.getBuildingId(); |
||||
alarmInfoService.delAlarmValueSet2(buildingId,itemType); //删除旧的记录
|
||||
alarmInfoService.saveAlarmValueSet(alarmValueSetEntity); |
||||
}else{ |
||||
List<BuildingModel> list=buildingService.selectBuildingName(); |
||||
for ( BuildingModel build:list){ |
||||
alarmInfoService.delAlarmValueSet2(String.valueOf(build.getBuildingId()),itemType); |
||||
alarmValueSetEntity.setBuildingId(String.valueOf(build.getBuildingId())); |
||||
alarmInfoService.saveAlarmValueSet(alarmValueSetEntity); |
||||
} |
||||
} |
||||
return HttpResult.ok(); |
||||
}catch (Exception e){ |
||||
return HttpResult.error(500,"保存出错!"); |
||||
} |
||||
} |
||||
|
||||
//修改处理状态
|
||||
@SysLogger(title="报警信息",optDesc = "修改处理状态") |
||||
@PostMapping("/dealState") |
||||
public HttpResult updateDealState(@RequestParam(value = "id",required = false) String id, |
||||
@RequestParam(value = "dealState",required = false) String dealState){ |
||||
try{ |
||||
alarmInfoService.updateDealState(id,dealState); |
||||
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd"); |
||||
Date dt=new Date(); |
||||
String curDate=sdf1.format(dt); |
||||
dealDataService.proAlarmInfoSum(curDate); //汇总相关警报数
|
||||
return HttpResult.ok(); |
||||
}catch (Exception e){ |
||||
return HttpResult.error(500,"修改出错!"); |
||||
} |
||||
} |
||||
|
||||
@SysLogger(title="报警设置",optDesc = "查询报警设置信息") |
||||
@PostMapping("/querySet") |
||||
public HttpResult queryAlarmValueSet(@RequestParam(value = "buildingId",required = false) String buildingId, |
||||
@RequestParam(value = "itemType",required = false) String itemType, |
||||
@RequestParam(value = "page",required = true) int page, |
||||
@RequestParam(value = "limit",required = true) int limit){ |
||||
try{ |
||||
List<AlarmValueSetEntity> list; |
||||
list=alarmInfoService.queryAlarmValueSet(buildingId,itemType,page,limit); |
||||
int count=alarmInfoService.getAlarmValueSetCount(buildingId,itemType); |
||||
return HttpResult.ok(count,list); |
||||
}catch (Exception e){ |
||||
e.printStackTrace(); |
||||
return HttpResult.error("查询出错!"); |
||||
} |
||||
} |
||||
|
||||
//删除设置记录
|
||||
@SysLogger(title="报警设置",optDesc = "删除报警设置信息") |
||||
@PostMapping("/delSet") |
||||
public HttpResult delAlarmValueSet(@RequestParam(value = "id",required = false) String id){ |
||||
try{ |
||||
alarmInfoService.delAlarmValueSet(id); |
||||
return HttpResult.ok(); |
||||
}catch (Exception e){ |
||||
return HttpResult.error(500,"删除出错!"); |
||||
} |
||||
|
||||
} |
||||
|
||||
//按楼栋编号删除设置记录
|
||||
@SysLogger(title="报警设置",optDesc = "删除报警设置信息") |
||||
@PostMapping("/del") |
||||
public HttpResult delAlarmValueSet2(@RequestParam(value = "buildingId",required = false) String buildingId, |
||||
@RequestParam(value = "itemType",required = false) String itemType){ |
||||
try{ |
||||
alarmInfoService.delAlarmValueSet2(buildingId,itemType); |
||||
return HttpResult.ok(); |
||||
}catch (Exception e){ |
||||
return HttpResult.error(500,"删除出错!"); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,55 @@
|
||||
package com.mh.user.controller; |
||||
|
||||
import com.mh.common.http.HttpResult; |
||||
import com.mh.user.entity.AnalysisMonthEntity; |
||||
import com.mh.user.entity.AnalysisYearEntity; |
||||
import com.mh.user.service.AnalysisService; |
||||
import com.mh.user.service.BuildingService; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.web.bind.annotation.PostMapping; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
@RestController |
||||
@RequestMapping("analysis") |
||||
public class AnalysisController { |
||||
|
||||
@Autowired |
||||
AnalysisService analysisService; |
||||
|
||||
@Autowired |
||||
BuildingService buildingService; |
||||
|
||||
@PostMapping("/queryYear") //type=1(水),2(电),3(能耗),4(维保)
|
||||
public HttpResult queryAnalysisYear(@RequestParam(value = "curDate",required = true) String curDate, |
||||
@RequestParam(value = "buildingId",required = true) String buildingId, |
||||
@RequestParam(value = "type",defaultValue = "3") int type) { |
||||
try{ |
||||
List<AnalysisYearEntity> list; |
||||
list=analysisService.queryAnalysisYear(curDate,buildingId,type); |
||||
return HttpResult.ok(list); |
||||
}catch (Exception e){ |
||||
e.printStackTrace(); |
||||
return HttpResult.error(); |
||||
} |
||||
|
||||
} |
||||
|
||||
@PostMapping("/queryMonth") //type=1(水),2(电),3(能耗)
|
||||
public HttpResult queryAnalysisMonth(@RequestParam(value = "curDate",required = true) String curDate, |
||||
@RequestParam(value = "buildingId",required = true) String buildingId, |
||||
@RequestParam(value = "type",defaultValue = "3") int type) { |
||||
try{ |
||||
List<AnalysisMonthEntity> list; |
||||
list=analysisService.queryAnalysisMonth(curDate,buildingId,type); |
||||
return HttpResult.ok(list); |
||||
}catch (Exception e){ |
||||
e.printStackTrace(); |
||||
return HttpResult.error(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,38 @@
|
||||
package com.mh.user.controller; |
||||
|
||||
import com.mh.common.http.HttpResult; |
||||
import com.mh.user.entity.AreaEntity; |
||||
import com.mh.user.entity.ExceptionTableData; |
||||
import com.mh.user.service.AreaService; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.security.access.prepost.PreAuthorize; |
||||
import org.springframework.web.bind.annotation.PostMapping; |
||||
import org.springframework.web.bind.annotation.RequestBody; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author nxr |
||||
* @title : 校区接口 |
||||
* @description : |
||||
* @updateTime 2022-06-09 |
||||
* @throws : |
||||
*/ |
||||
@RestController |
||||
@RequestMapping("area") |
||||
public class AreaController { |
||||
|
||||
@Autowired |
||||
private AreaService areaService; |
||||
|
||||
@PreAuthorize("hasAuthority('sys:area:view')") |
||||
@PostMapping(value = "/findArea") |
||||
public HttpResult findArea() { |
||||
List<AreaEntity> list=areaService.findAll(); |
||||
// System.out.println("test");
|
||||
return HttpResult.ok("500",list); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,227 @@
|
||||
package com.mh.user.controller; |
||||
|
||||
import com.mh.common.http.HttpResult; |
||||
import com.mh.user.annotation.SysLogger; |
||||
import com.mh.user.entity.BuildingEntity; |
||||
import com.mh.user.model.BuildingModel; |
||||
import com.mh.user.service.BuildingService; |
||||
import org.apache.poi.hssf.usermodel.HSSFCell; |
||||
import org.apache.poi.hssf.usermodel.HSSFSheet; |
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook; |
||||
import org.apache.poi.ss.usermodel.CellType; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.web.bind.annotation.*; |
||||
import org.springframework.web.multipart.MultipartFile; |
||||
import javax.servlet.http.HttpServletRequest; |
||||
import java.io.IOException; |
||||
import java.io.InputStream; |
||||
import java.text.SimpleDateFormat; |
||||
import java.util.ArrayList; |
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
@RestController |
||||
@RequestMapping("building") |
||||
public class BuildingController { |
||||
|
||||
@Autowired |
||||
private BuildingService buildingService; |
||||
|
||||
//保存
|
||||
@SysLogger(title="楼栋信息",optDesc = "保存楼栋信息") |
||||
@PostMapping(value="/save") |
||||
public HttpResult saveBuilding(@RequestBody BuildingEntity buildingEntity) { |
||||
try{ |
||||
return HttpResult.ok(buildingService.saveBuilding(buildingEntity)); |
||||
}catch (Exception e){ |
||||
e.printStackTrace(); |
||||
return HttpResult.error(); |
||||
} |
||||
} |
||||
|
||||
//修改
|
||||
@SysLogger(title="楼栋信息",optDesc = "修改楼栋信息") |
||||
@PostMapping(value="/update") |
||||
public HttpResult updateBuilding(@RequestBody BuildingEntity buildingEntity) { |
||||
return HttpResult.ok("success",buildingService.updateBuilding(buildingEntity)); |
||||
} |
||||
|
||||
//查询所有
|
||||
@SysLogger(title="楼栋信息",optDesc = "查询楼栋信息") |
||||
@PostMapping(value = "/query") |
||||
public HttpResult queryBuilding(@RequestParam(value = "buildingId", required = false)String buildingId, |
||||
@RequestParam(value= "page", required=true)Integer page, |
||||
@RequestParam(value= "limit", required=true)Integer limit) { |
||||
try{ |
||||
int count=buildingService.getCount(buildingId, page,limit); |
||||
List<BuildingEntity> records=buildingService.queryBuilding(buildingId, page,limit); |
||||
return HttpResult.ok(count,records); |
||||
}catch (Exception e){ |
||||
e.printStackTrace(); |
||||
return HttpResult.error(); |
||||
} |
||||
} |
||||
|
||||
//查询楼栋名称
|
||||
@PostMapping(value="/name") |
||||
public HttpResult selectBuildingName() { |
||||
try{ |
||||
List<BuildingModel> list=buildingService.selectBuildingName(); |
||||
return HttpResult.ok(list); |
||||
}catch (Exception e){ |
||||
e.printStackTrace(); |
||||
return HttpResult.error(); |
||||
} |
||||
|
||||
} |
||||
|
||||
// 删除多
|
||||
@PostMapping(value="/deletes") |
||||
public HttpResult delete(@RequestBody List<BuildingEntity> records) { |
||||
return HttpResult.ok(buildingService.deleteBuilding(records)); |
||||
} |
||||
|
||||
// 删除单个
|
||||
@SysLogger(title="楼栋信息",optDesc = "删除楼栋信息") |
||||
@PostMapping(value="/delete") |
||||
public HttpResult delete(@RequestParam String id ) { |
||||
return HttpResult.ok(buildingService.deleteBuilding(id)); |
||||
} |
||||
|
||||
// 查询编号
|
||||
@PostMapping(value="/selectBuildingId") |
||||
public HttpResult selectBuildingId(@RequestParam String buildingName ) { |
||||
String id=buildingService.selectBuildingId(buildingName); |
||||
return HttpResult.ok(id); |
||||
} |
||||
|
||||
// 资料批量上传
|
||||
@SysLogger(title="楼栋信息",optDesc = "批量导入楼栋信息") |
||||
@PostMapping("/import_building") |
||||
public HttpResult importExcel(@RequestParam(value = "file") MultipartFile file, HttpServletRequest req) { |
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
||||
HttpResult httpResult=new HttpResult(); |
||||
try { |
||||
int is=0; //判断是否有重复
|
||||
String msg=""; |
||||
List<String> a = new ArrayList(); |
||||
InputStream inputStream = file.getInputStream(); |
||||
//创建工作簿
|
||||
//如果是xls,使用HSSFWorkbook;如果是xlsx,使用XSSFWorkbook
|
||||
HSSFWorkbook hssfWorkbook = new HSSFWorkbook(inputStream); |
||||
System.out.println("xssfWorkbook对象:" + hssfWorkbook); |
||||
//读取第一个工作表
|
||||
HSSFSheet sheet = hssfWorkbook.getSheetAt(0); |
||||
System.out.println("sheet对象:" + sheet); |
||||
//获取最后一行的num,即总行数。此处从0开始计数
|
||||
int maxRow = sheet.getLastRowNum(); |
||||
System.out.println("总行数为:" + maxRow); |
||||
if (maxRow >= 500){ |
||||
msg = "总行数不能超出500行"; |
||||
httpResult.setMsg(msg); |
||||
httpResult.setCode(500); |
||||
return httpResult; |
||||
} |
||||
if (maxRow == 0){ |
||||
msg = "请先录入数据到excel文件"; |
||||
httpResult.setMsg(msg); |
||||
httpResult.setCode(500); |
||||
return httpResult; |
||||
} |
||||
|
||||
// 创建数组集合
|
||||
List<BuildingEntity> uploadEntityList = new ArrayList<>(); |
||||
List<String> deviceList = new ArrayList<>(); |
||||
for (int row = 1; row <= maxRow; row++) { |
||||
//获取最后单元格num,即总单元格数 ***注意:此处从1开始计数***
|
||||
int maxRol = sheet.getRow(row).getLastCellNum(); |
||||
System.out.println("总列数为:" + maxRol); |
||||
System.out.println("--------第" + row + "行的数据如下--------"); |
||||
for (int rol = 0; rol < maxRol; rol++){ |
||||
String sCell; |
||||
if (sheet.getRow(row).getCell(rol) == null){ |
||||
sCell=""; |
||||
}else{ |
||||
HSSFCell cell = sheet.getRow(row).getCell(rol); |
||||
cell.setCellType(CellType.STRING); |
||||
sCell = cell.getStringCellValue(); |
||||
} |
||||
sCell = sCell.trim(); //去首尾空格
|
||||
sCell = sCell.replaceAll(" ", ""); //去掉所有空格,包括首尾、中间
|
||||
sCell = sCell.replaceAll("\\s*", ""); //可以替换大部分空白字符, 不限于空格,\s 可以匹配空格、制表符、换页符等空白字符的其中任意一个
|
||||
System.out.print(sCell + " "); |
||||
deviceList.add(sCell); |
||||
String rolName = ""; |
||||
switch (rol){ |
||||
case 1 : |
||||
rolName = "楼栋名称"; |
||||
break; |
||||
case 2 : |
||||
rolName = "楼层数"; |
||||
break; |
||||
case 3 : |
||||
rolName = "起始楼层"; |
||||
break; |
||||
case 4 : |
||||
rolName = "每层宿舍数"; |
||||
break; |
||||
case 5 : |
||||
rolName = "床位数"; |
||||
break; |
||||
case 6 : |
||||
rolName = "实际入住数"; |
||||
break; |
||||
} |
||||
if ((rol >= 1)&&(rol <= 4)&&(sCell.equals(""))){ |
||||
msg = rolName + "不能为空" ; |
||||
httpResult.setMsg(msg); |
||||
httpResult.setCode(500); |
||||
return httpResult; |
||||
} |
||||
} |
||||
|
||||
// 创建实体类
|
||||
BuildingEntity uploadEntity = new BuildingEntity(); |
||||
uploadEntity.setBuildingName(deviceList.get(0));//楼栋名称
|
||||
uploadEntity.setLevelsCount(Integer.parseInt(deviceList.get(1))); //楼层数
|
||||
uploadEntity.setBeginLevel(Integer.parseInt(deviceList.get(2))); //起始楼层
|
||||
uploadEntity.setHouseCount(Integer.parseInt(deviceList.get(3))); //每层宿舍数
|
||||
uploadEntity.setBedCount(Integer.parseInt(deviceList.get(4))); //床位数
|
||||
uploadEntity.setCheckInCount(Integer.parseInt(deviceList.get(5))); //实际入住数
|
||||
|
||||
deviceList.clear(); |
||||
|
||||
uploadEntityList.add(uploadEntity); |
||||
is=buildingService.selectCount(uploadEntity.getBuildingName()); |
||||
if (is>0){ |
||||
httpResult.setMsg("楼栋名称有重复!"); |
||||
httpResult.setCode(500); |
||||
// return httpResult;
|
||||
} |
||||
} |
||||
|
||||
if (is==0){ |
||||
for (BuildingEntity buildingEntity:uploadEntityList){ |
||||
buildingService.saveBuilding(buildingEntity); |
||||
} |
||||
httpResult.setMsg("success"); |
||||
httpResult.setCode(200); |
||||
return httpResult; |
||||
} |
||||
|
||||
} catch (IOException e) { |
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace(); |
||||
} |
||||
return httpResult; |
||||
} |
||||
|
||||
// 查询楼栋热泵数目
|
||||
@PostMapping(value="/pumpCount") |
||||
public HttpResult selectPumpCount(@RequestParam String buildingId ) { |
||||
int count=buildingService.selectPumpCount(buildingId); |
||||
return HttpResult.ok("success",count); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,32 @@
|
||||
package com.mh.user.controller; |
||||
|
||||
import com.mh.common.http.HttpResult; |
||||
import com.mh.user.model.DeviceTypeModel; |
||||
import com.mh.user.service.CodeTableService; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.web.bind.annotation.PostMapping; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
@RestController |
||||
public class CodeTableController { |
||||
|
||||
@Autowired |
||||
CodeTableService codeTableService; |
||||
|
||||
@PostMapping("/deviceType") |
||||
public HttpResult queryDeviceType(){ |
||||
List<DeviceTypeModel> list; |
||||
list=codeTableService.queryDeviceType(); |
||||
return HttpResult.ok(list); |
||||
} |
||||
|
||||
@PostMapping("/brand") |
||||
public HttpResult queryBrand(){ |
||||
List<DeviceTypeModel> list; |
||||
list=codeTableService.queryBrand(); |
||||
return HttpResult.ok(list); |
||||
} |
||||
} |
@ -0,0 +1,60 @@
|
||||
package com.mh.user.controller; |
||||
|
||||
import com.mh.common.http.HttpResult; |
||||
import com.mh.user.annotation.SysLogger; |
||||
import com.mh.user.entity.ControlSetEntity; |
||||
import com.mh.user.entity.PumpSetEntity; |
||||
import com.mh.user.service.ControlSetService; |
||||
import com.mh.user.service.PumpSetService; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
@RestController |
||||
@RequestMapping("controller") |
||||
public class ControlSetController { |
||||
|
||||
@Autowired |
||||
ControlSetService controlSetService; |
||||
|
||||
@Autowired |
||||
PumpSetService pumpSetService; |
||||
|
||||
//保存控制设置值
|
||||
@SysLogger(title="控制设置",optDesc = "保存控制设置值") |
||||
@PostMapping(value="/save") |
||||
public HttpResult saveControlSet(@RequestBody ControlSetEntity controlSetEntity) { |
||||
try{ |
||||
controlSetService.saveControlSet(controlSetEntity); |
||||
return HttpResult.ok("保存成功!"); |
||||
}catch (Exception e){ |
||||
e.printStackTrace(); |
||||
return HttpResult.error(); |
||||
} |
||||
} |
||||
|
||||
//保存热泵设置值
|
||||
@SysLogger(title="控制设置",optDesc = "保存热泵设置值") |
||||
@PostMapping(value="/pumpSave") |
||||
public HttpResult saveControlSet(@RequestBody PumpSetEntity pumpSetEntity) { |
||||
try{ |
||||
pumpSetService.savePumpSet(pumpSetEntity); |
||||
return HttpResult.ok("保存成功!"); |
||||
}catch (Exception e){ |
||||
e.printStackTrace(); |
||||
return HttpResult.error(); |
||||
} |
||||
} |
||||
|
||||
//查询设置表
|
||||
@SysLogger(title="控制设置",optDesc = "查询设置值") |
||||
@PostMapping(value="/query") |
||||
public HttpResult queryControlSet(@RequestParam("buildingId") String buildingId) { |
||||
try{ |
||||
ControlSetEntity control=controlSetService.queryControlSet(buildingId); |
||||
return HttpResult.ok(control); |
||||
}catch (Exception e){ |
||||
// e.printStackTrace();
|
||||
return HttpResult.error(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,46 @@
|
||||
package com.mh.user.controller; |
||||
|
||||
|
||||
import com.mh.common.http.HttpResult; |
||||
import com.mh.user.annotation.SysLogger; |
||||
import com.mh.user.entity.BuildingEntity; |
||||
import com.mh.user.entity.DataResultEntity; |
||||
import com.mh.user.service.BuildingService; |
||||
import com.mh.user.service.DataResultService; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
@RestController |
||||
@RequestMapping("dataResult") |
||||
public class DataResultController { |
||||
|
||||
@Autowired |
||||
DataResultService dataResultService; |
||||
|
||||
@Autowired |
||||
BuildingService buildingService; |
||||
|
||||
@SysLogger(title="用能查询",optDesc = "查询抄表读数") |
||||
@PostMapping(value="/query") |
||||
public HttpResult queryDataResult(@RequestParam(value = "buildingId", required = false) String buildingId, |
||||
@RequestParam(value= "startDate", required=false)String startDate, |
||||
@RequestParam(value= "endDate", required=false)String endDate, |
||||
@RequestParam(value= "deviceType", required=false)String deviceType, |
||||
@RequestParam(value= "page", required=true)Integer page, |
||||
@RequestParam(value= "limit", required=true)Integer limit) { |
||||
|
||||
try{ |
||||
|
||||
int count=dataResultService.getDataResultCount(buildingId,startDate,endDate,deviceType,page,limit); |
||||
List<DataResultEntity> records=dataResultService.queryDataResult(buildingId,startDate,endDate,deviceType,page,limit); |
||||
return HttpResult.ok(count,records); |
||||
}catch (Exception e){ |
||||
// e.printStackTrace();
|
||||
return HttpResult.error(); |
||||
} |
||||
|
||||
} |
||||
} |
@ -0,0 +1,218 @@
|
||||
package com.mh.user.controller; |
||||
|
||||
|
||||
import com.mh.common.http.HttpResult; |
||||
import com.mh.user.annotation.SysLogger; |
||||
import com.mh.user.entity.*; |
||||
import com.mh.user.model.DeviceModel; |
||||
import com.mh.user.service.BuildingService; |
||||
import com.mh.user.service.DeviceFloorService; |
||||
import com.mh.user.service.DeviceInstallService; |
||||
import org.apache.poi.hssf.usermodel.HSSFCell; |
||||
import org.apache.poi.hssf.usermodel.HSSFSheet; |
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook; |
||||
import org.apache.poi.ss.usermodel.CellType; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.web.bind.annotation.*; |
||||
import org.springframework.web.multipart.MultipartFile; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import java.io.IOException; |
||||
import java.io.InputStream; |
||||
import java.text.ParseException; |
||||
import java.text.SimpleDateFormat; |
||||
import java.util.ArrayList; |
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
@RestController |
||||
@RequestMapping("floor") |
||||
public class DeviceFloorController { |
||||
|
||||
@Autowired |
||||
private DeviceFloorService deviceFloorService; |
||||
|
||||
@Autowired |
||||
BuildingService buildingService; |
||||
|
||||
//保存
|
||||
@SysLogger(title="楼面设备",optDesc = "保存楼面设备信息") |
||||
@PostMapping(value="/save") |
||||
public HttpResult saveDevice(@RequestBody DeviceFloorEntity deviceFloorEntity) { |
||||
return HttpResult.ok(deviceFloorService.saveDevice(deviceFloorEntity)); |
||||
} |
||||
|
||||
//修改
|
||||
@SysLogger(title="楼面设备",optDesc = "修改楼面设备信息") |
||||
@PostMapping(value="/update") |
||||
public HttpResult updateDevice(@RequestBody DeviceFloorEntity deviceFloorEntity) { |
||||
return HttpResult.ok(deviceFloorService.updateDevice(deviceFloorEntity)); |
||||
} |
||||
|
||||
//查询所有
|
||||
@PostMapping(value = "/query") |
||||
@SysLogger(title="楼面设备",optDesc = "查询楼面设备信息") |
||||
public HttpResult queryDeviceFloor(@RequestParam(value = "buildingId", required = false)String buildingId, |
||||
@RequestParam(value = "deviceType", required = false)String deviceType, |
||||
@RequestParam(value= "page", required=true)Integer page, |
||||
@RequestParam(value= "limit", required=true)Integer limit) { |
||||
try{ |
||||
int count=deviceFloorService.getCount(buildingId,deviceType, page,limit); |
||||
List<DeviceFloorEntity> records=deviceFloorService.queryDeviceFloor(buildingId,deviceType, page,limit); |
||||
return HttpResult.ok(count,records); |
||||
}catch (Exception e){ |
||||
e.printStackTrace(); |
||||
return HttpResult.error(); |
||||
} |
||||
} |
||||
|
||||
@PostMapping(value="/name") |
||||
public HttpResult selectDeviceName(@RequestParam(value = "buildingId", required = false)String buildingId, |
||||
@RequestParam(value = "deviceType", required = false)String deviceType) { |
||||
try{ |
||||
List<DeviceModel> list=deviceFloorService.selectDeviceName(buildingId,deviceType); |
||||
return HttpResult.ok(list); |
||||
}catch (Exception e){ |
||||
e.printStackTrace(); |
||||
return HttpResult.error(); |
||||
} |
||||
|
||||
} |
||||
|
||||
// 删除多
|
||||
@PostMapping(value="/deletes") |
||||
public HttpResult delete(@RequestBody List<DeviceFloorEntity> records) { |
||||
return HttpResult.ok(deviceFloorService.deleteDevice(records)); |
||||
} |
||||
|
||||
// 删除单个
|
||||
@SysLogger(title="楼面设备",optDesc = "删除楼面设备信息") |
||||
@PostMapping(value="/delete") |
||||
public HttpResult delete(@RequestParam String id ) { |
||||
return HttpResult.ok(deviceFloorService.deleteDevice(id)); |
||||
} |
||||
|
||||
// 资料批量上传
|
||||
@SysLogger(title="楼面设备",optDesc = "批量导入楼面设备信息") |
||||
@PostMapping("/import_devices") |
||||
public HttpResult importExcel(@RequestParam(value = "file") MultipartFile file, HttpServletRequest req) { |
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
||||
HttpResult httpResult=new HttpResult(); |
||||
try { |
||||
int is=0; //判断是否有重复表号
|
||||
String msg=""; |
||||
List<String> a = new ArrayList(); |
||||
InputStream inputStream = file.getInputStream(); |
||||
//创建工作簿
|
||||
HSSFWorkbook hssfWorkbook = new HSSFWorkbook(inputStream); |
||||
System.out.println("xssfWorkbook对象:" + hssfWorkbook); |
||||
//读取第一个工作表
|
||||
HSSFSheet sheet = hssfWorkbook.getSheetAt(0); |
||||
System.out.println("sheet对象:" + sheet); |
||||
//获取最后一行的num,即总行数。此处从0开始计数
|
||||
int maxRow = sheet.getLastRowNum(); |
||||
System.out.println("总行数为:" + maxRow); |
||||
if (maxRow >= 500){ |
||||
msg = "总行数不能超出500行"; |
||||
httpResult.setMsg(msg); |
||||
httpResult.setCode(500); |
||||
return httpResult; |
||||
} |
||||
if (maxRow == 0){ |
||||
msg = "请先录入数据到excel文件"; |
||||
httpResult.setMsg(msg); |
||||
httpResult.setCode(500); |
||||
return httpResult; |
||||
} |
||||
|
||||
// 创建数组集合
|
||||
List<DeviceFloorEntity> uploadEntityList = new ArrayList<>(); |
||||
List<String> deviceList = new ArrayList<>(); |
||||
for (int row = 1; row <= maxRow; row++) { |
||||
//获取最后单元格num,即总单元格数 ***注意:此处从1开始计数***
|
||||
int maxRol = sheet.getRow(row).getLastCellNum(); |
||||
System.out.println("总列数为:" + maxRol); |
||||
System.out.println("--------第" + row + "行的数据如下--------"); |
||||
for (int rol = 0; rol < maxRol; rol++){ |
||||
String sCell; |
||||
if (sheet.getRow(row).getCell(rol) == null){ |
||||
sCell=""; |
||||
}else{ |
||||
HSSFCell cell = sheet.getRow(row).getCell(rol); |
||||
cell.setCellType(CellType.STRING); |
||||
sCell = cell.getStringCellValue(); |
||||
} |
||||
sCell = sCell.trim(); //去首尾空格
|
||||
sCell = sCell.replaceAll(" ", ""); //去掉所有空格,包括首尾、中间
|
||||
sCell = sCell.replaceAll("\\s*", ""); //可以替换大部分空白字符, 不限于空格,\s 可以匹配空格、制表符、换页符等空白字符的其中任意一个
|
||||
System.out.print(sCell + " "); |
||||
deviceList.add(sCell); |
||||
String rolName = ""; |
||||
switch (rol){ |
||||
case 1 : |
||||
rolName = "设备名称"; |
||||
break; |
||||
case 2 : |
||||
rolName = "设备类型"; |
||||
break; |
||||
case 3 : |
||||
rolName = "品牌"; |
||||
break; |
||||
case 4 : |
||||
rolName = "规格"; |
||||
break; |
||||
case 5 : |
||||
rolName = "型号"; |
||||
break; |
||||
case 6 : |
||||
rolName = "安装人员"; |
||||
break; |
||||
case 7 : |
||||
rolName = "所属楼栋"; |
||||
break; |
||||
} |
||||
if ((rol >= 1)&&(rol <= 4)&&(sCell.equals(""))){ |
||||
msg = rolName + "不能为空" ; |
||||
httpResult.setMsg(msg); |
||||
httpResult.setCode(500); |
||||
return httpResult; |
||||
} |
||||
} |
||||
|
||||
// 创建实体类
|
||||
DeviceFloorEntity uploadEntity = new DeviceFloorEntity(); |
||||
uploadEntity.setDeviceName(deviceList.get(0));//设备名称
|
||||
uploadEntity.setDeviceType(deviceList.get(1));//设备类型
|
||||
uploadEntity.setBrand(deviceList.get(2));//品牌
|
||||
uploadEntity.setSpecs(deviceList.get(3));//规格
|
||||
uploadEntity.setModel(deviceList.get(4));//型号
|
||||
uploadEntity.setInstaller(deviceList.get(5));//安装人员
|
||||
uploadEntity.setBuildingId(deviceList.get(6));//所属楼栋
|
||||
deviceList.clear(); |
||||
uploadEntityList.add(uploadEntity); |
||||
is=deviceFloorService.selectDeviceCount(uploadEntity.getBuildingId(),uploadEntity.getDeviceType(),uploadEntity.getDeviceName()); |
||||
if (is>0){ |
||||
httpResult.setMsg("设备名称不能重复!"); |
||||
httpResult.setCode(500); |
||||
// return httpResult;
|
||||
} |
||||
// deviceFloorService.saveDevice(uploadEntity);
|
||||
} |
||||
|
||||
if (is==0){ |
||||
for (DeviceFloorEntity deviceFloorEntity:uploadEntityList){ |
||||
deviceFloorService.saveDevice(deviceFloorEntity); |
||||
} |
||||
httpResult.setMsg("success"); |
||||
httpResult.setCode(200); |
||||
return httpResult; |
||||
} |
||||
} catch (IOException e) { // IOException | ParseException e
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace(); |
||||
} |
||||
return httpResult; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,350 @@
|
||||
package com.mh.user.controller; |
||||
|
||||
import com.mh.common.http.HttpResult; |
||||
import com.mh.user.annotation.BusinessType; |
||||
import com.mh.user.annotation.SysLogger; |
||||
import com.mh.user.entity.BuildingEntity; |
||||
import com.mh.user.entity.DeviceInstallEntity; |
||||
import com.mh.user.model.DeviceModel; |
||||
import com.mh.user.service.BuildingService; |
||||
import com.mh.user.service.DealDataService; |
||||
import com.mh.user.service.DeviceInstallService; |
||||
import com.mh.user.service.SummaryService; |
||||
import org.apache.poi.hssf.usermodel.HSSFCell; |
||||
import org.apache.poi.hssf.usermodel.HSSFSheet; |
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook; |
||||
import org.apache.poi.ss.usermodel.CellType; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.web.bind.annotation.*; |
||||
import org.springframework.web.multipart.MultipartFile; |
||||
import javax.servlet.http.HttpServletRequest; |
||||
import java.io.IOException; |
||||
import java.io.InputStream; |
||||
import java.text.SimpleDateFormat; |
||||
import java.util.*; |
||||
|
||||
@RestController |
||||
@RequestMapping("device") |
||||
public class DeviceInstallController { |
||||
|
||||
@Autowired |
||||
private DeviceInstallService deviceInstallService; |
||||
|
||||
@Autowired |
||||
BuildingService buildingService; |
||||
|
||||
private final DealDataService dealDataService; |
||||
|
||||
public DeviceInstallController(DealDataService dealDataService) |
||||
{ |
||||
this.dealDataService = dealDataService; |
||||
} |
||||
|
||||
//保存
|
||||
@SysLogger(title="基表信息",optDesc = "保存基表信息") |
||||
@PostMapping(value="/save") |
||||
public HttpResult saveDevice(@RequestBody DeviceInstallEntity deviceInstallEntity) { |
||||
return HttpResult.ok(deviceInstallService.saveDevice(deviceInstallEntity)); |
||||
} |
||||
|
||||
//修改
|
||||
@SysLogger(title="基表信息",optDesc = "修改基表信息") |
||||
@PostMapping(value="/update") |
||||
public HttpResult updateDevice(@RequestBody DeviceInstallEntity deviceInstallEntity) { |
||||
deviceInstallService.updateDevice(deviceInstallEntity); |
||||
String isUse=""; |
||||
if (deviceInstallEntity.isUse()==true){ |
||||
isUse="1"; |
||||
}else{ |
||||
isUse="0"; |
||||
} |
||||
String deviceAddr=deviceInstallEntity.getDeviceAddr(); |
||||
String deviceType=deviceInstallEntity.getDeviceType(); |
||||
String buildingId=deviceInstallEntity.getBuildingId(); |
||||
deviceInstallService.updateIsUse(isUse,deviceAddr,deviceType,buildingId); |
||||
deviceInstallService.updateIsUse2(isUse,deviceAddr,deviceType,buildingId); |
||||
deviceInstallService.updateIsUse3(isUse,deviceAddr,deviceType,buildingId); |
||||
|
||||
return HttpResult.ok(); |
||||
} |
||||
|
||||
//查询所有
|
||||
@SysLogger(title="基表信息",optDesc = "查询基表信息") |
||||
@PostMapping(value = "/getAll") |
||||
public HttpResult getAllDevice(@RequestParam int page, @RequestParam int limit) { |
||||
Map<Object,Object> map=new HashMap<>(); |
||||
map.put("count",deviceInstallService.getAllCount()); //记录数
|
||||
map.put("data",deviceInstallService.getAllDevice(page,limit)); //数据集
|
||||
return HttpResult.ok(map); |
||||
} |
||||
|
||||
// 删除多
|
||||
@PostMapping(value="/deletes") |
||||
public HttpResult delete(@RequestBody List<DeviceInstallEntity> records) { |
||||
return HttpResult.ok(deviceInstallService.deleteDevice(records)); |
||||
} |
||||
|
||||
// 删除单个
|
||||
@SysLogger(title="基表信息",optDesc = "删除基表信息") |
||||
@PostMapping(value="/delete") |
||||
public HttpResult delete(@RequestParam String id ) { |
||||
return HttpResult.ok(deviceInstallService.deleteDevice(id)); |
||||
} |
||||
|
||||
// 按条件查询
|
||||
@SysLogger(title="基表信息",optDesc = "按条件查询基表信息") |
||||
@PostMapping(value="/query") |
||||
public HttpResult queryDevice( @RequestParam(value = "buildingId", required = false)String buildingId, |
||||
@RequestParam(value = "deviceType", required = false)String deviceType, |
||||
@RequestParam(value = "startDate", required = false)String startDate, |
||||
@RequestParam(value = "endDate", required = false)String endDate, |
||||
@RequestParam(value = "isOnline", required=false)String isOnline, |
||||
@RequestParam(value = "isUse", required=false)String isUse, |
||||
@RequestParam(value = "isFault", required=false)String isFault, |
||||
@RequestParam(value = "page", required=true)Integer page, |
||||
@RequestParam(value = "limit", required=true)Integer limit) { |
||||
try{ |
||||
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
||||
Date date = new Date(); |
||||
String curDate=sdf1.format(date); |
||||
dealDataService.proDeviceState(curDate); //刷新统计设备状态数据
|
||||
|
||||
int count=deviceInstallService.getCount(buildingId,deviceType, startDate, endDate,isOnline,isUse,isFault, page,limit); |
||||
List<DeviceInstallEntity> records=deviceInstallService.queryDevice(buildingId,deviceType, startDate, endDate,isOnline,isUse,isFault, page,limit); |
||||
return HttpResult.ok(count,records); |
||||
}catch (Exception e){ |
||||
//e.printStackTrace();
|
||||
return HttpResult.error(); |
||||
} |
||||
} |
||||
|
||||
//查询设备在线情况
|
||||
@PostMapping(value="/getIsOnline") |
||||
public HttpResult getIsOnlineCount(){ |
||||
try { |
||||
Map<Object, Object> map = new HashMap<>(); |
||||
int electCount = deviceInstallService.getIsOnlineCount("在线", "电表"); |
||||
int wtCount = deviceInstallService.getIsOnlineCount("在线", "水表"); |
||||
int pumpCount = deviceInstallService.getIsOnlineCount("在线", "热泵"); |
||||
int pressCount = deviceInstallService.getIsOnlineCount("在线", "压变"); |
||||
int deviceCount = deviceInstallService.getAllCount(); |
||||
|
||||
map.put("electCount", electCount); |
||||
map.put("wtCount", wtCount); |
||||
map.put("pumpCount", pumpCount); |
||||
map.put("pressCount", pressCount); |
||||
map.put("deviceCount", deviceCount); |
||||
|
||||
return HttpResult.ok(map); |
||||
} catch(Exception e){ |
||||
return HttpResult.error(); |
||||
} |
||||
} |
||||
|
||||
// 资料批量上传
|
||||
@PostMapping("/import_devices") |
||||
public HttpResult importExcel(@RequestParam(value = "file") MultipartFile file, HttpServletRequest req) { |
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
||||
HttpResult httpResult=new HttpResult(); |
||||
String token = req.getHeader("token"); |
||||
try { |
||||
int is=0; //判断是否有重复表号
|
||||
String msg=""; |
||||
List<String> a = new ArrayList(); |
||||
InputStream inputStream = file.getInputStream(); |
||||
//创建工作簿
|
||||
HSSFWorkbook hssfWorkbook = new HSSFWorkbook(inputStream); |
||||
System.out.println("xssfWorkbook对象:" + hssfWorkbook); |
||||
//读取第一个工作表
|
||||
HSSFSheet sheet = hssfWorkbook.getSheetAt(0); |
||||
System.out.println("sheet对象:" + sheet); |
||||
//获取最后一行的num,即总行数。此处从0开始计数
|
||||
int maxRow = sheet.getLastRowNum(); |
||||
System.out.println("总行数为:" + maxRow); |
||||
if (maxRow >= 500){ |
||||
msg = "总行数不能超出500行"; |
||||
httpResult.setMsg(msg); |
||||
httpResult.setCode(500); |
||||
return httpResult; |
||||
} |
||||
if (maxRow == 0){ |
||||
msg = "请先录入数据到excel文件"; |
||||
httpResult.setMsg(msg); |
||||
httpResult.setCode(500); |
||||
return httpResult; |
||||
} |
||||
//先清临时表
|
||||
// deviceInstallService.deleteDevice_install_temp();
|
||||
// 创建数组集合
|
||||
List<DeviceInstallEntity> uploadEntityList = new ArrayList<>(); |
||||
List<String> deviceList = new ArrayList<>(); |
||||
for (int row = 1; row <= maxRow; row++) { |
||||
//获取最后单元格num,即总单元格数 ***注意:此处从1开始计数***
|
||||
int maxRol = sheet.getRow(row).getLastCellNum(); |
||||
System.out.println("总列数为:" + maxRol); |
||||
System.out.println("--------第" + row + "行的数据如下--------"); |
||||
for (int rol = 0; rol < maxRol; rol++){ |
||||
String sCell; |
||||
if (sheet.getRow(row).getCell(rol) == null){ |
||||
sCell=""; |
||||
}else{ |
||||
HSSFCell cell = sheet.getRow(row).getCell(rol); |
||||
cell.setCellType(CellType.STRING); |
||||
sCell = cell.getStringCellValue(); |
||||
} |
||||
sCell = sCell.trim(); //去首尾空格
|
||||
sCell = sCell.replaceAll(" ", ""); //去掉所有空格,包括首尾、中间
|
||||
sCell = sCell.replaceAll("\\s*", ""); //可以替换大部分空白字符, 不限于空格,\s 可以匹配空格、制表符、换页符等空白字符的其中任意一个
|
||||
System.out.print(sCell + " "); |
||||
deviceList.add(sCell); |
||||
String rolName = ""; |
||||
switch (rol){ |
||||
case 1 : |
||||
rolName = "通讯编号"; |
||||
break; |
||||
case 2 : |
||||
rolName = "设备名称"; |
||||
break; |
||||
case 3 : |
||||
rolName = "设备类型"; |
||||
break; |
||||
case 4 : |
||||
rolName = "通讯端口"; |
||||
break; |
||||
case 5 : |
||||
rolName = "波特率"; |
||||
break; |
||||
case 6 : |
||||
rolName = "倍率"; |
||||
break; |
||||
case 7 : |
||||
rolName = "品牌"; |
||||
break; |
||||
case 8 : |
||||
rolName = "型号"; |
||||
break; |
||||
case 9 : |
||||
rolName = "安装人员"; |
||||
break; |
||||
case 10 : |
||||
rolName = "所属楼栋"; |
||||
break; |
||||
} |
||||
if ((rol >= 1)&&(rol <= 4)&&(sCell.equals(""))){ |
||||
msg = rolName + "不能为空" ; |
||||
httpResult.setMsg(msg); |
||||
httpResult.setCode(500); |
||||
return httpResult; |
||||
} |
||||
} |
||||
// 创建实体类
|
||||
DeviceInstallEntity uploadEntity=new DeviceInstallEntity(); |
||||
uploadEntity.setDeviceAddr(deviceList.get(0));//通讯编号
|
||||
uploadEntity.setDeviceName(deviceList.get(1));//设备名称
|
||||
uploadEntity.setDeviceType(deviceList.get(2));//设备类型
|
||||
uploadEntity.setDataCom(deviceList.get(3));//通讯端口
|
||||
uploadEntity.setBaudRate(Integer.parseInt(deviceList.get(4)));//波特率
|
||||
uploadEntity.setRatio(Double.parseDouble(deviceList.get(5)));//倍率
|
||||
uploadEntity.setBrand(deviceList.get(6));//品牌
|
||||
uploadEntity.setModel(deviceList.get(7));//型号
|
||||
uploadEntity.setInstaller(deviceList.get(8));//安装人员
|
||||
uploadEntity.setBuildingId(deviceList.get(9));//所属楼栋
|
||||
deviceList.clear(); |
||||
|
||||
uploadEntityList.add(uploadEntity); |
||||
is=deviceInstallService.selectDeviceCount(uploadEntity.getDeviceAddr(),uploadEntity.getDeviceType()); |
||||
if (is>0){ |
||||
httpResult.setMsg("通讯编号有重复!"); |
||||
httpResult.setCode(500); |
||||
// return httpResult;
|
||||
} |
||||
} |
||||
|
||||
if (is==0){ |
||||
for (DeviceInstallEntity deviceInstallEntity:uploadEntityList){ |
||||
deviceInstallService.saveDevice(deviceInstallEntity); |
||||
} |
||||
httpResult.setMsg("success"); |
||||
httpResult.setCode(200); |
||||
return httpResult; |
||||
} |
||||
} catch (IOException e) { |
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace(); |
||||
} |
||||
return httpResult; |
||||
} |
||||
|
||||
// 修改使用状态
|
||||
@PostMapping(value="/isUse") |
||||
public HttpResult updateDeviceIsUse(@RequestParam(value = "isUse") String isUse, |
||||
@RequestParam(value = "deviceAddr") String deviceAddr) { |
||||
deviceInstallService.updateDeviceIsUse(isUse,deviceAddr); |
||||
return HttpResult.ok(); |
||||
} |
||||
|
||||
@PostMapping(value="/name") |
||||
public HttpResult selectDevices(@RequestParam(value = "buildingId", required = false)String buildingId, |
||||
@RequestParam(value = "deviceType", required = false)String deviceType) { |
||||
try{ |
||||
List<DeviceModel> list; |
||||
if(deviceType.equals("热泵")){ |
||||
list=deviceInstallService.selectDevices(buildingId,deviceType); |
||||
if (list.size()==0){ |
||||
String addr; |
||||
String name; |
||||
for(int i=1;i<8;i++){ |
||||
DeviceModel d1=new DeviceModel(); |
||||
addr=String.valueOf(i); |
||||
name="热泵"+addr; |
||||
d1.setDeviceAddr(addr); |
||||
d1.setDeviceName(name); |
||||
list.add(d1); |
||||
} |
||||
//System.out.println(list);
|
||||
// DeviceModel d2=new DeviceModel();
|
||||
// d2.setDeviceAddr("2");
|
||||
// d2.setDeviceName("热泵2");
|
||||
// list.add(d2);
|
||||
//
|
||||
// DeviceModel d3=new DeviceModel();
|
||||
// d3.setDeviceAddr("3");
|
||||
// d3.setDeviceName("热泵3");
|
||||
// list.add(d3);
|
||||
//
|
||||
// DeviceModel d4=new DeviceModel();
|
||||
// d4.setDeviceAddr("4");
|
||||
// d4.setDeviceName("热泵4");
|
||||
// list.add(d4);
|
||||
//
|
||||
// DeviceModel d5=new DeviceModel();
|
||||
// d5.setDeviceAddr("5");
|
||||
// d5.setDeviceName("热泵5");
|
||||
// list.add(d5);
|
||||
} |
||||
}else{ |
||||
list=deviceInstallService.selectDevices(buildingId,deviceType); |
||||
} |
||||
|
||||
return HttpResult.ok(list); |
||||
}catch (Exception e){ |
||||
e.printStackTrace(); |
||||
return HttpResult.error(); |
||||
} |
||||
} |
||||
|
||||
// 查询品牌
|
||||
@PostMapping(value="/brand") |
||||
public HttpResult selectBrand(@RequestParam(value = "buildingId") String buildingId, |
||||
@RequestParam(value = "deviceAddr") String deviceAddr) { |
||||
return HttpResult.ok(deviceInstallService.selectBrand(buildingId,deviceAddr)); |
||||
} |
||||
|
||||
//判断楼栋是否有热泵设备
|
||||
@PostMapping(value="/pump") |
||||
public HttpResult judgePump(@RequestParam(value = "buildingId") String buildingId) { |
||||
int data=deviceInstallService.judgePump(buildingId); |
||||
return HttpResult.ok("success",data); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,215 @@
|
||||
package com.mh.user.controller; |
||||
|
||||
import com.mh.common.http.HttpResult; |
||||
import com.mh.user.annotation.SysLogger; |
||||
import com.mh.user.entity.EnergyEntity; |
||||
import com.mh.user.model.SumModel; |
||||
import com.mh.user.service.BuildingService; |
||||
import com.mh.user.service.EnergyService; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.web.bind.annotation.*; |
||||
import java.util.ArrayList; |
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
@RestController |
||||
@RequestMapping("energy") |
||||
public class EnergyController { |
||||
|
||||
@Autowired |
||||
EnergyService energyService; |
||||
|
||||
@Autowired |
||||
BuildingService buildingService; |
||||
|
||||
@SysLogger(title="用能分析",optDesc = "保存能耗信息") |
||||
@PostMapping("/save") |
||||
public HttpResult saveEnergy(@RequestBody EnergyEntity energyEntity, @RequestParam(value = "type") int type){ |
||||
try{ |
||||
energyService.saveEnergy(energyEntity,type); |
||||
return HttpResult.ok(); |
||||
}catch (Exception e){ |
||||
return HttpResult.error("保存出错!"); |
||||
} |
||||
|
||||
} |
||||
|
||||
@SysLogger(title="用能分析",optDesc = "修改能耗信息") |
||||
@PostMapping("/update") |
||||
public HttpResult updateEnergy(@RequestBody EnergyEntity energyEntity, @RequestParam(value = "type") int type){ |
||||
try{ |
||||
energyService.updateEnergy(energyEntity,type); |
||||
return HttpResult.ok(); |
||||
}catch (Exception e){ |
||||
return HttpResult.error("修改出错!"); |
||||
} |
||||
|
||||
} |
||||
|
||||
@PostMapping("/delete") |
||||
@SysLogger(title="用能分析",optDesc = "删除能耗信息") |
||||
public HttpResult deleteEnergy(@RequestParam(value = "curDate") String curDate, |
||||
@RequestParam(value = "buildingId") String buildingId, |
||||
@RequestParam(value = "type") int type){ |
||||
try{ |
||||
|
||||
energyService.deleteEnergy(curDate,buildingId,type); |
||||
return HttpResult.ok(); |
||||
}catch (Exception e){ |
||||
return HttpResult.error("删除出错!"); |
||||
} |
||||
|
||||
} |
||||
|
||||
@SysLogger(title="用能分析",optDesc = "查询能耗信息") |
||||
@PostMapping("/query") |
||||
public HttpResult queryEnergy(@RequestParam(value = "buildingId",required = false) String buildingId, |
||||
@RequestParam(value = "startDate",required = false) String startDate, |
||||
@RequestParam(value = "endDate",required = false) String endDate, |
||||
@RequestParam(value = "page") int page, |
||||
@RequestParam(value = "limit") int limit, |
||||
@RequestParam(value = "type") int type){ |
||||
try{ |
||||
String areaId=""; |
||||
if (buildingId!=null && buildingId.length()>0){ |
||||
if (!buildingId.equals("所有")){ |
||||
areaId=buildingService.queryAreaId(Integer.parseInt(buildingId)); |
||||
} |
||||
} |
||||
List<EnergyEntity> list=new ArrayList<>(); |
||||
int count=0; |
||||
if (areaId!=null && areaId.length()>0){ |
||||
list=energyService.queryEnergy(areaId,startDate,endDate,page,limit,type); |
||||
count=energyService.getEnergyCount(areaId,startDate,endDate,page,limit,type); |
||||
}else{ |
||||
list=energyService.queryEnergy(buildingId,startDate,endDate,page,limit,type); |
||||
count=energyService.getEnergyCount(buildingId,startDate,endDate,page,limit,type); |
||||
} |
||||
// System.out.println("返回前端数据:"+list);
|
||||
return HttpResult.ok(count,list); |
||||
}catch (Exception e){ |
||||
// e.printStackTrace();
|
||||
return HttpResult.error("查询出错!"); |
||||
} |
||||
|
||||
} |
||||
|
||||
//主界面水、电、单耗查询
|
||||
@SysLogger(title="项目概况",optDesc = "查询能耗信息") |
||||
@PostMapping("/queryGroup") |
||||
public HttpResult queryEnergyGroup(@RequestParam(value = "curDate",required = true) String curDate, |
||||
@RequestParam(value = "type",required = true,defaultValue = "1") int type){ |
||||
try{ |
||||
List<EnergyEntity> list=new ArrayList<EnergyEntity>(); |
||||
list=energyService.queryEnergyGroup(curDate,type); |
||||
return HttpResult.ok(list); |
||||
}catch (Exception e){ |
||||
e.printStackTrace(); |
||||
return HttpResult.error("查询出错!"); |
||||
} |
||||
|
||||
} |
||||
|
||||
//查询每天的用量
|
||||
@SysLogger(title="用能分析",optDesc = "查询每天的用量") |
||||
@PostMapping("/queryDay") |
||||
public HttpResult queryDayEnergy(@RequestParam(value = "buildingId",required = false) String buildingId, |
||||
@RequestParam(value = "startDate",required = false) String startDate, |
||||
@RequestParam(value = "endDate",required = false) String endDate, |
||||
@RequestParam(value = "page") int page, |
||||
@RequestParam(value = "limit") int limit){ |
||||
try{ |
||||
String areaId=""; |
||||
if (buildingId!=null && buildingId.length()>0){ |
||||
if (!buildingId.equals("所有")){ |
||||
areaId=buildingService.queryAreaId(Integer.parseInt(buildingId)); |
||||
} |
||||
} |
||||
List<EnergyEntity> list; |
||||
int count=0; |
||||
if (areaId!=null && areaId.length()>0){ |
||||
list=energyService.queryDayEnergy(areaId,startDate,endDate,page,limit); |
||||
count=energyService.getDayEnergyCount(areaId,startDate,endDate,page,limit); |
||||
}else{ |
||||
list=energyService.queryDayEnergy(buildingId,startDate,endDate,page,limit); |
||||
count=energyService.getDayEnergyCount(buildingId,startDate,endDate,page,limit); |
||||
} |
||||
|
||||
return HttpResult.ok(count,list); |
||||
}catch (Exception e){ |
||||
e.printStackTrace(); |
||||
return HttpResult.error("查询出错!"); |
||||
} |
||||
|
||||
} |
||||
|
||||
//查询小时的用量
|
||||
@SysLogger(title="用能分析",optDesc = "查询小时的用量") |
||||
@PostMapping("/queryHour") |
||||
public HttpResult queryHourEnergy(@RequestParam(value = "buildingId",required = false) String buildingId, |
||||
@RequestParam(value = "curDate",required = false) String curDate, |
||||
@RequestParam(value = "page") int page, |
||||
@RequestParam(value = "limit") int limit){ |
||||
try{ |
||||
String areaId=""; |
||||
if (buildingId!=null && buildingId.length()>0){ |
||||
if (!buildingId.equals("所有")){ |
||||
areaId=buildingService.queryAreaId(Integer.parseInt(buildingId)); |
||||
} |
||||
} |
||||
List<EnergyEntity> list; |
||||
int count=0; |
||||
if (areaId!=null && areaId.length()>0){ |
||||
list=energyService.queryHourEnergy(areaId,curDate,page,limit); |
||||
count=energyService.getHourEnergyCount(areaId,curDate); |
||||
}else{ |
||||
list=energyService.queryHourEnergy(buildingId,curDate,page,limit); |
||||
count=energyService.getHourEnergyCount(buildingId,curDate); |
||||
} |
||||
|
||||
return HttpResult.ok(count,list); |
||||
}catch (Exception e){ |
||||
e.printStackTrace(); |
||||
return HttpResult.error("查询出错!"); |
||||
} |
||||
|
||||
} |
||||
|
||||
//查询楼栋时段用量对比
|
||||
@SysLogger(title="用能分析",optDesc = "查询楼栋时段用量对比") |
||||
@PostMapping("/queryBuild") |
||||
public HttpResult queryEnergyBuilding(@RequestParam(value = "curDate",required = false) String curDate, |
||||
@RequestParam(value = "endDate",required = false) String endDate, |
||||
@RequestParam(value = "type",required = false) int type, |
||||
@RequestParam(value = "page") int page, |
||||
@RequestParam(value = "limit") int limit){ |
||||
try{ |
||||
energyService.proEnergyBuilding(curDate,endDate,type); |
||||
List<EnergyEntity> list=energyService.queryEnergyBuilding(page,limit); |
||||
SumModel list2=energyService.queryEnergySum(); |
||||
Map map=new HashMap<>(); |
||||
map.put("a",list); |
||||
map.put("b",list2); |
||||
int count=energyService.getEnergyBuildingCount(); |
||||
return HttpResult.ok(count,map); |
||||
}catch (Exception e){ |
||||
e.printStackTrace(); |
||||
return HttpResult.error("查询出错!"); |
||||
} |
||||
} |
||||
|
||||
//查询合计
|
||||
@SysLogger(title="用能分析",optDesc = "查询合计") |
||||
@PostMapping("/querySum") |
||||
public HttpResult queryEnergySum(){ |
||||
try{ |
||||
SumModel list=energyService.queryEnergySum(); |
||||
return HttpResult.ok(list); |
||||
}catch (Exception e){ |
||||
e.printStackTrace(); |
||||
return HttpResult.error("查询出错!"); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,62 @@
|
||||
package com.mh.user.controller; |
||||
|
||||
import com.mh.common.http.HttpResult; |
||||
import com.mh.user.entity.GatewayManageEntity; |
||||
import com.mh.user.service.impl.DeviceDisplayServiceImpl; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import java.util.List; |
||||
|
||||
@RestController |
||||
@RequestMapping("gateway") |
||||
public class GatewayManageController { |
||||
|
||||
@Autowired |
||||
private DeviceDisplayServiceImpl.GatewayManageService gatewayManageService; |
||||
|
||||
//保存
|
||||
@PostMapping(value="/save") |
||||
public HttpResult addOrUpdateGateWayInfo(@RequestBody GatewayManageEntity gatewayManageEntity) { |
||||
// try{
|
||||
// gatewayManageService.addOrUpdateGateWayInfo(gatewayManageEntity);
|
||||
// return HttpResult.ok();
|
||||
// }catch (Exception e){
|
||||
// return HttpResult.error();
|
||||
// }
|
||||
|
||||
gatewayManageService.addOrUpdateGateWayInfo(gatewayManageEntity); |
||||
return HttpResult.ok(); |
||||
} |
||||
|
||||
// 按条件查询
|
||||
@PostMapping(value="/query") |
||||
public HttpResult queryAll( @RequestParam(value = "gatewayID", required = false)String gatewayID, |
||||
@RequestParam(value = "operator", required = false)String operator, |
||||
@RequestParam(value = "grade", required = false)String grade, |
||||
@RequestParam(value= "page", required=true)Integer page, |
||||
@RequestParam(value= "limit", required=true)Integer limit) { |
||||
try{ |
||||
int count=gatewayManageService.queryCount(gatewayID,operator,grade); |
||||
List<GatewayManageEntity> records=gatewayManageService.queryAll(gatewayID,operator, grade,page,limit); |
||||
return HttpResult.ok(count,records); |
||||
}catch (Exception e){ |
||||
e.printStackTrace(); |
||||
return HttpResult.error(); |
||||
} |
||||
|
||||
} |
||||
|
||||
// 删除
|
||||
@PostMapping(value="/delete") |
||||
public HttpResult deleteGatewayManageByID( @RequestParam(value = "gatewayID")String gatewayID){ |
||||
try{ |
||||
gatewayManageService.deleteGatewayManageByID(Integer.parseInt(gatewayID)); |
||||
return HttpResult.ok(); |
||||
}catch (Exception e){ |
||||
e.printStackTrace(); |
||||
return HttpResult.error(); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,75 @@
|
||||
package com.mh.user.controller; |
||||
|
||||
import com.mh.common.http.HttpResult; |
||||
import com.mh.user.annotation.SysLogger; |
||||
import com.mh.user.entity.EnergyEntity; |
||||
import com.mh.user.entity.MaintainInfoEntity; |
||||
import com.mh.user.service.BuildingService; |
||||
import com.mh.user.service.MaintainInfoService; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
@RestController |
||||
@RequestMapping("maintain") |
||||
public class MaintainInfoController { |
||||
|
||||
@Autowired |
||||
MaintainInfoService maintainInfoService; |
||||
|
||||
@Autowired |
||||
BuildingService buildingService; |
||||
|
||||
@SysLogger(title="维修保养",optDesc = "保存维修保养记录") |
||||
@PostMapping("/save") |
||||
public HttpResult saveMaintainInfo(@RequestBody MaintainInfoEntity maintainInfoEntity){ |
||||
try{ |
||||
maintainInfoService.saveMaintainInfo(maintainInfoEntity); |
||||
return HttpResult.ok(); |
||||
}catch (Exception e){ |
||||
return HttpResult.error(); |
||||
} |
||||
} |
||||
|
||||
@SysLogger(title="维修保养",optDesc = "修改维修保养记录") |
||||
@PostMapping("/update") |
||||
public HttpResult updateMaintainInfo(@RequestBody MaintainInfoEntity maintainInfoEntity){ |
||||
try{ |
||||
maintainInfoService.updateMaintainInfo(maintainInfoEntity); |
||||
return HttpResult.ok(); |
||||
}catch (Exception e){ |
||||
return HttpResult.error(); |
||||
} |
||||
} |
||||
|
||||
@SysLogger(title="维修保养",optDesc = "查询维修保养记录") |
||||
@PostMapping("/query") |
||||
public HttpResult queryMaintainInfo(@RequestParam(value = "curDate",required = false) String curDate, |
||||
@RequestParam(value = "buildingId",required = false) String buildingId, |
||||
@RequestParam(value = "deviceType",required = false) String deviceType, |
||||
@RequestParam(value = "page") int page, |
||||
@RequestParam(value = "limit") int limit){ |
||||
try{ |
||||
List<MaintainInfoEntity> list=maintainInfoService.queryMaintainInfo(curDate,buildingId,deviceType,page,limit); |
||||
int count=maintainInfoService.getMaintainInfoCount(curDate,buildingId,deviceType,page,limit); |
||||
return HttpResult.ok(count,list); |
||||
}catch (Exception e){ |
||||
e.printStackTrace(); |
||||
return HttpResult.error(); |
||||
} |
||||
} |
||||
|
||||
@SysLogger(title="维修保养",optDesc = "删除维修保养记录") |
||||
@PostMapping("/delete") |
||||
public HttpResult deleteMaintainInfo(@RequestParam(value = "id") String id){ |
||||
try{ |
||||
maintainInfoService.deleteMaintainInfo(id); |
||||
return HttpResult.ok(); |
||||
}catch (Exception e){ |
||||
return HttpResult.error(); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,231 @@
|
||||
package com.mh.user.controller; |
||||
|
||||
import com.mh.common.http.HttpResult; |
||||
import com.mh.user.annotation.BusinessType; |
||||
import com.mh.user.annotation.SysLogger; |
||||
import com.mh.user.entity.*; |
||||
import com.mh.user.model.DeviceModel; |
||||
import com.mh.user.model.PumpModel; |
||||
import com.mh.user.model.WaterLevelModel; |
||||
import com.mh.user.service.*; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.web.bind.annotation.PostMapping; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
import java.text.SimpleDateFormat; |
||||
import java.util.ArrayList; |
||||
import java.util.Date; |
||||
import java.util.List; |
||||
|
||||
@RestController |
||||
@RequestMapping("monitor") |
||||
public class NowDataController { |
||||
|
||||
@Autowired |
||||
NowDataService nowDataService; |
||||
|
||||
@Autowired |
||||
BuildingService buildingService; |
||||
|
||||
@Autowired |
||||
NowPublicDataService nowPublicDataService; |
||||
|
||||
@Autowired |
||||
DeviceInstallService deviceInstallService; |
||||
|
||||
@Autowired |
||||
DeviceFloorService deviceFloorService; |
||||
|
||||
@SysLogger(title="实时监控",optDesc = "实时查看每楼栋热水运行情况") |
||||
@PostMapping("/queryNow") |
||||
public HttpResult queryNowData(@RequestParam(value = "buildingId") String buildingId){ |
||||
try{ |
||||
//把热泵的水温保存到公共信息中中的用水温度和回水温度
|
||||
String avgWaterTemp=nowDataService.selectAve(buildingId); |
||||
String buildingName=buildingService.queryBuildingName(buildingId);//获取楼栋名称
|
||||
|
||||
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
||||
Date date=new Date(); |
||||
String curDate=sdf1.format(date); |
||||
curDate=curDate.substring(0,13)+":00:00"; |
||||
|
||||
NowPublicDataEntity nowPublicData=new NowPublicDataEntity(); |
||||
nowPublicData.setBuildingId(buildingId); |
||||
nowPublicData.setBuildingName(buildingName); |
||||
if (avgWaterTemp!=null){ |
||||
nowPublicData.setBackWaterTemp(avgWaterTemp); |
||||
nowPublicData.setUseWaterTemp(avgWaterTemp); |
||||
}else{ |
||||
nowPublicData.setBackWaterTemp("0"); |
||||
nowPublicData.setUseWaterTemp("0"); |
||||
} |
||||
nowPublicDataService.saveNowHistoryPublicData(nowPublicData); |
||||
|
||||
//监视表生成初始记录
|
||||
List<NowDataEntity> list=nowDataService.queryNowData(buildingId); |
||||
if (list.size()==0){//实时表生成记录
|
||||
List<DeviceModel> deviceList=deviceInstallService.selectDevices(buildingId,"热泵"); |
||||
if (deviceList.size()>0){ |
||||
for (DeviceModel list2:deviceList){ |
||||
NowDataEntity nowData=new NowDataEntity(); |
||||
nowData.setPumpId(list2.getDeviceAddr()); |
||||
nowData.setPumpName(list2.getDeviceName()); |
||||
nowData.setBuildingId(buildingId); |
||||
nowData.setBuildingName(buildingName); |
||||
nowData.setCurDate(curDate); |
||||
nowDataService.saveNowData(nowData); //当前状态表
|
||||
nowDataService.saveHistoryData(nowData); //历史状态表
|
||||
} |
||||
}else{ |
||||
NowDataEntity nowData=new NowDataEntity(); |
||||
PumpModel pump=deviceFloorService.selectDeviceId2("热泵",buildingId); |
||||
if (pump!=null){ |
||||
nowData.setPumpId(pump.getPumpId()); |
||||
nowData.setPumpName(pump.getPumpName()); |
||||
nowData.setBuildingId(buildingId); |
||||
nowData.setBuildingName(buildingName); |
||||
nowData.setCurDate(curDate); |
||||
nowDataService.saveNowData(nowData); |
||||
nowDataService.saveHistoryData(nowData); |
||||
} |
||||
} |
||||
} |
||||
list=nowDataService.queryNowData(buildingId); |
||||
return HttpResult.ok(list); |
||||
}catch (Exception e){ |
||||
// e.printStackTrace();
|
||||
return HttpResult.error("查询当前监控状态出错!"); |
||||
} |
||||
} |
||||
|
||||
@SysLogger(title="实时监控",optDesc = "分别查看热泵运行情况") |
||||
@PostMapping("/queryNowByPump") |
||||
public HttpResult queryNowByPump(@RequestParam(value = "buildingId") String buildingId,@RequestParam(value = "pumpId") String pumpId){ |
||||
try{ |
||||
NowDataEntity nowDataEntity=nowDataService.queryNowDataByPump(buildingId,pumpId); |
||||
return HttpResult.ok(nowDataEntity); |
||||
}catch (Exception e){ |
||||
e.printStackTrace(); |
||||
return HttpResult.error("按热泵查询当前监控状态出错!"); |
||||
} |
||||
|
||||
} |
||||
|
||||
@SysLogger(title="运行信息",optDesc = "热泵历史状态查询") |
||||
@PostMapping("/query") |
||||
public HttpResult queryHistoryData(@RequestParam(value = "curDate") String curDate, |
||||
@RequestParam(value = "buildingId") String buildingId, |
||||
@RequestParam(value = "pumpId",required = false) String pumpId, |
||||
@RequestParam(value = "tankId",required = false) String tankId, |
||||
@RequestParam(value = "page") int page, |
||||
@RequestParam(value = "limit") int limit){ |
||||
try{ |
||||
List<NowDataEntity> list; |
||||
list=nowDataService.queryHistoryData(curDate,buildingId,pumpId,tankId,page,limit); |
||||
int count=nowDataService.getHistoryDataCount(curDate,buildingId,pumpId,tankId,page,limit); |
||||
return HttpResult.ok(count,list); |
||||
}catch (Exception e){ |
||||
// e.printStackTrace();
|
||||
return HttpResult.error("查询出错!"); |
||||
} |
||||
} |
||||
|
||||
//查询水位开始
|
||||
@SysLogger(title="水位变化表",optDesc = "水位变化查询") |
||||
@PostMapping("/waterLevel") |
||||
public HttpResult queryWaterLevel(@RequestParam(value = "curDate") String curDate, |
||||
@RequestParam(value = "buildingID") String buildingID, |
||||
@RequestParam(value = "page") int page, |
||||
@RequestParam(value = "limit") int limit){ |
||||
try{ |
||||
if (buildingID==null || buildingID.equals("") || buildingID.equals("所有楼栋")){ |
||||
List<WaterLevelEntity> list=nowDataService.queryBuildWaterLevel(curDate, page, limit); |
||||
int count=nowDataService.buildWaterLevelCount(curDate); |
||||
return HttpResult.ok(count,list); |
||||
}else{ |
||||
List<WaterLevelEntity> list=nowDataService.queryWaterLevel(curDate,buildingID,page,limit); |
||||
int count=nowDataService.getWaterLevelCount(curDate,buildingID); |
||||
return HttpResult.ok(count,list); |
||||
} |
||||
|
||||
}catch (Exception e){ |
||||
// e.printStackTrace();
|
||||
return HttpResult.error("查询出错!"); |
||||
} |
||||
} |
||||
|
||||
@PostMapping("/levelByTime") |
||||
public HttpResult queryWaterLevelByTime(@RequestParam(value = "curDate") String curDate, |
||||
@RequestParam(value = "page") int page, |
||||
@RequestParam(value = "limit") int limit){ |
||||
try{ |
||||
int count=nowDataService.waterLevelByTimeCount(curDate); |
||||
List<WaterLevelModel> list=nowDataService.queryWaterLevelByTime(curDate,page,limit); |
||||
return HttpResult.ok(count,list); |
||||
}catch (Exception e){ |
||||
// e.printStackTrace();
|
||||
return HttpResult.error("查询出错!"); |
||||
} |
||||
} |
||||
|
||||
//查询水位结束
|
||||
//查询水温,每天24小时情况
|
||||
@SysLogger(title="温度变化表",optDesc = "温度变化查询") |
||||
@PostMapping("/waterTemp") |
||||
public HttpResult queryWaterTemp(@RequestParam(value = "buildingID") String buildingID, |
||||
@RequestParam(value = "curDate") String curDate, |
||||
@RequestParam(value = "page") int page, |
||||
@RequestParam(value = "limit") int limit){ |
||||
try{ |
||||
List<WaterTempEntity> list; |
||||
int count; |
||||
if (buildingID==null || buildingID.equals("") || buildingID.equals("所有楼栋")){ |
||||
list=nowDataService.queryWaterTemp2(curDate,page,limit); |
||||
count=nowDataService.queryWaterTempCount2(curDate); |
||||
}else{ |
||||
list=nowDataService.queryWaterTemp(buildingID,curDate,page,limit); |
||||
count=nowDataService.queryWaterTempCount(buildingID,curDate); |
||||
} |
||||
return HttpResult.ok(count,list); |
||||
}catch (Exception e){ |
||||
// e.printStackTrace();
|
||||
return HttpResult.error("查询出错!"); |
||||
} |
||||
} |
||||
|
||||
//查询运行时长
|
||||
@SysLogger(title="运行时长",optDesc = "热泵运行时长查询") |
||||
@PostMapping("/minutes") |
||||
public HttpResult pumpMinutes(@RequestParam(value = "startDate") String startDate, |
||||
@RequestParam(value = "endDate") String endDate, |
||||
@RequestParam(value = "buildingId",required = false) String buildingId, |
||||
@RequestParam(value = "pumpId",required = false) String pumpId, |
||||
@RequestParam(value = "type") int type, |
||||
@RequestParam(value = "page") int page, |
||||
@RequestParam(value = "limit") int limit){ |
||||
try{ |
||||
int count=0; |
||||
List<PumpMinutesEntity> list; |
||||
if(type==1){ |
||||
list=nowDataService.pumpMinutes(startDate,endDate,buildingId,pumpId,page,limit); |
||||
count=nowDataService.pumpMinutesCount(startDate,endDate,buildingId,pumpId); |
||||
}else if(type==2){ |
||||
list=nowDataService.pumpWeekMinutes(startDate,endDate,buildingId,pumpId,page,limit); |
||||
count=nowDataService.pumpWeekMinutesCount(startDate,endDate,buildingId,pumpId); |
||||
}else if(type==3){ |
||||
list=nowDataService.pumpMonthMinutes(startDate,endDate,buildingId,pumpId,page,limit); |
||||
count=nowDataService.pumpMonthMinutesCount(startDate,endDate,buildingId,pumpId); |
||||
}else{ |
||||
list=nowDataService.pumpMinutes(startDate,endDate,buildingId,pumpId,page,limit); |
||||
count=nowDataService.pumpMinutesCount(startDate,endDate,buildingId,pumpId); |
||||
} |
||||
|
||||
return HttpResult.ok(count,list); |
||||
}catch (Exception e){ |
||||
// e.printStackTrace();
|
||||
return HttpResult.error("查询出错!"); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,92 @@
|
||||
package com.mh.user.controller; |
||||
|
||||
import com.mh.common.http.HttpResult; |
||||
import com.mh.user.annotation.BusinessType; |
||||
import com.mh.user.annotation.SysLogger; |
||||
import com.mh.user.entity.NowDataEntity; |
||||
import com.mh.user.entity.NowPublicDataEntity; |
||||
import com.mh.user.model.TempModel; |
||||
import com.mh.user.service.BuildingService; |
||||
import com.mh.user.service.NowDataService; |
||||
import com.mh.user.service.NowPublicDataService; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.web.bind.annotation.PostMapping; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
@RestController |
||||
@RequestMapping("monitor_public") |
||||
public class NowPublicDataController { |
||||
|
||||
@Autowired |
||||
NowPublicDataService nowPublicDataService; |
||||
|
||||
@Autowired |
||||
BuildingService buildingService; |
||||
|
||||
@Autowired |
||||
NowDataService nowDataService; |
||||
|
||||
@PostMapping("/queryNow") |
||||
public HttpResult queryNowData(@RequestParam(value = "buildingId") String buildingId){ |
||||
try{ |
||||
NowPublicDataEntity nowPublicDataEntity=nowPublicDataService.queryNowPublicData(buildingId); |
||||
return HttpResult.ok(nowPublicDataEntity); |
||||
}catch (Exception e){ |
||||
//e.printStackTrace();
|
||||
return HttpResult.error("查询公共信息出错!"); |
||||
} |
||||
} |
||||
|
||||
@PostMapping("/query") |
||||
public HttpResult queryHistoryData(@RequestParam(value = "curDate") String curDate, |
||||
@RequestParam(value = "buildingId") String buildingId, |
||||
@RequestParam(value = "page") int page, |
||||
@RequestParam(value = "limit") int limit){ |
||||
try{ |
||||
List<NowPublicDataEntity> list=new ArrayList<NowPublicDataEntity>(); |
||||
list=nowPublicDataService.queryHistoryPublicData(curDate,buildingId,page,limit); |
||||
int count=nowPublicDataService.getHistoryPublicDataCount(curDate,buildingId,page,limit); |
||||
return HttpResult.ok(count,list); |
||||
}catch (Exception e){ |
||||
//e.printStackTrace();
|
||||
return HttpResult.error("查询出错!"); |
||||
} |
||||
} |
||||
|
||||
@PostMapping("/temp") |
||||
public HttpResult buildWaterTemp(@RequestParam(value = "buildingName",required = false) String buildingName){ |
||||
try{ |
||||
if (buildingName!=null && !buildingName.equals("")){ |
||||
String buildingId=buildingService.selectBuildingId(buildingName); |
||||
TempModel tempModel=nowPublicDataService.queryWtTemp2(buildingId); |
||||
return HttpResult.ok(1,tempModel); |
||||
}else{ |
||||
List<TempModel> list=nowPublicDataService.queryWtTemp(); //楼栋所有水箱平均温度
|
||||
int count=list.size(); |
||||
return HttpResult.ok(count,list); |
||||
} |
||||
}catch (Exception e){ |
||||
// e.printStackTrace();
|
||||
return HttpResult.error(500,"查询楼栋水温异常!"); |
||||
} |
||||
} |
||||
|
||||
// @PostMapping("/temp")
|
||||
// public HttpResult buildWaterTemp2(@RequestParam(value = "buildingName") String buildingName){
|
||||
// try{
|
||||
// String buildingId=buildingService.selectBuildingId(buildingName);
|
||||
// TempModel tempModel=nowPublicDataService.queryWtTemp2(buildingId);
|
||||
// return HttpResult.ok("success",tempModel);
|
||||
// }catch (Exception e){
|
||||
//// e.printStackTrace();
|
||||
// return HttpResult.error(500,"查询楼栋水温异常!");
|
||||
// }
|
||||
// }
|
||||
} |
@ -0,0 +1,67 @@
|
||||
package com.mh.user.controller; |
||||
|
||||
import com.alibaba.fastjson2.JSONObject; |
||||
import com.mh.common.http.HttpResult; |
||||
import com.mh.user.entity.ReportParamEntity; |
||||
import com.mh.user.service.ReportService; |
||||
import org.springframework.util.CollectionUtils; |
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
import java.util.List; |
||||
import java.util.stream.Collectors; |
||||
|
||||
/** |
||||
* @author ljf |
||||
* @title :报表查询接口 |
||||
* @description : |
||||
* @updateTime 2020-07-03 |
||||
* @throws : |
||||
*/ |
||||
@RestController |
||||
@RequestMapping("/report") |
||||
public class ReportController { |
||||
|
||||
private final ReportService reportService; |
||||
|
||||
public ReportController(ReportService reportService) { |
||||
this.reportService = reportService; |
||||
} |
||||
|
||||
@GetMapping("/indexInfo") |
||||
public HttpResult queryAllTarget(@RequestParam(value = "type",required = false) String type) { |
||||
List<ReportParamEntity> reportParamEntities = reportService.queryAllTarget(type); |
||||
List<ReportParamEntity> firstLevel = reportParamEntities.stream().filter(p -> String.valueOf(p.getParentId()).equals("0")).collect(Collectors.toList()); |
||||
System.out.println(firstLevel.toString()); |
||||
firstLevel.parallelStream().forEach(p -> { |
||||
setChild(p, reportParamEntities); |
||||
}); |
||||
JSONObject menuListJson = new JSONObject(); |
||||
menuListJson.put("indexInfo",firstLevel); |
||||
System.out.println(menuListJson.toJSONString()); |
||||
return HttpResult.ok("success", menuListJson); |
||||
|
||||
} |
||||
|
||||
/** |
||||
* 设置子元素 |
||||
* 2018.06.09 |
||||
* |
||||
* @param p |
||||
* @param reportParamEntities |
||||
*/ |
||||
private void setChild(ReportParamEntity p, List<ReportParamEntity> reportParamEntities) { |
||||
// System.out.println(p.getId());
|
||||
List<ReportParamEntity> child = reportParamEntities.parallelStream().filter(a -> String.valueOf(a.getParentId()).equals(String.valueOf(p.getId()))).collect(Collectors.toList()); |
||||
p.setChildren(child); |
||||
if (!CollectionUtils.isEmpty(child)) { |
||||
child.parallelStream().forEach(c -> { |
||||
//递归设置子元素,多级菜单支持
|
||||
setChild(c, reportParamEntities); |
||||
}); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,423 @@
|
||||
package com.mh.user.controller; |
||||
|
||||
import com.alibaba.fastjson2.JSONObject; |
||||
import com.mh.common.http.HttpResult; |
||||
import com.mh.user.annotation.SysLogger; |
||||
import com.mh.user.constants.Constant; |
||||
import com.mh.user.entity.ControlSetEntity; |
||||
import com.mh.user.entity.DeviceCodeParamEntity; |
||||
import com.mh.user.entity.DeviceInstallEntity; |
||||
import com.mh.user.entity.PumpSetEntity; |
||||
import com.mh.user.model.DeviceModel; |
||||
import com.mh.user.model.SerialPortModel; |
||||
import com.mh.user.serialport.SerialPortSendReceive; |
||||
import com.mh.user.serialport.SerialPortSingle; |
||||
import com.mh.user.service.ControlSetService; |
||||
import com.mh.user.service.DeviceInstallService; |
||||
import com.mh.user.service.NowDataService; |
||||
import com.mh.user.service.PumpSetService; |
||||
import com.mh.user.utils.ExchangeStringUtil; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
@Slf4j |
||||
@RestController |
||||
@RequestMapping("serial") |
||||
public class SerialPortController { |
||||
|
||||
@Autowired |
||||
DeviceInstallService deviceInstallService; |
||||
|
||||
@Autowired |
||||
PumpSetService pumpSetService; |
||||
|
||||
@Autowired |
||||
ControlSetService controlSetService; |
||||
|
||||
@Autowired |
||||
NowDataService nowDataService; |
||||
|
||||
//操作设备
|
||||
@SysLogger(title="控制管理",optDesc = "设置设备参数值") |
||||
@PostMapping(value="/operate") |
||||
public HttpResult operateDevice(@RequestBody List<SerialPortModel> params){ |
||||
try{ |
||||
SerialPortSingle serialPortSingle = new SerialPortSingle(); //发送接收类
|
||||
DeviceCodeParamEntity deviceCodeParam=new DeviceCodeParamEntity();//参数实体类
|
||||
|
||||
Constant.WEB_FLAG=true; //单抄,暂时停止采集
|
||||
for (SerialPortModel serialPortModel : |
||||
params) { |
||||
String deviceAddr=serialPortModel.getDeviceAddr();//设备通讯地址
|
||||
String deviceType=serialPortModel.getDeviceType();//设备类型
|
||||
String buildingId=serialPortModel.getBuildingId();//楼栋
|
||||
String param=serialPortModel.getParam();//操作参数
|
||||
if (deviceAddr==null || deviceAddr=="" ){ |
||||
List<DeviceModel> list=deviceInstallService.selectDevices(buildingId,deviceType); |
||||
deviceAddr=list.get(0).getDeviceAddr(); |
||||
} |
||||
if(deviceAddr!=null && deviceAddr.length()>0){ |
||||
DeviceInstallEntity deviceInstallEntity=deviceInstallService.selectDevice(deviceAddr,deviceType,buildingId); |
||||
//发送指令实体类
|
||||
deviceCodeParam.setDeviceAddr(deviceAddr); //传入通讯编号
|
||||
deviceCodeParam.setDeviceType(deviceType); |
||||
deviceCodeParam.setDataCom(deviceInstallEntity.getDataCom()); |
||||
deviceCodeParam.setBaudrate(deviceInstallEntity.getBaudRate()); |
||||
deviceCodeParam.setParity(deviceInstallEntity.getParity()); |
||||
deviceCodeParam.setDataValue(serialPortModel.getDataValue());//传入相关参数值
|
||||
deviceCodeParam.setBuildingId(buildingId); |
||||
String brand=deviceInstallEntity.getBrand();//品牌
|
||||
deviceCodeParam.setBrand(brand); |
||||
|
||||
ControlSetEntity controlData=new ControlSetEntity(); |
||||
//设置设备实体对象
|
||||
controlData.setBuildingId(deviceInstallEntity.getBuildingId()); |
||||
|
||||
if (deviceType==null || deviceType.equals("") || deviceType.equals("热泵")){ |
||||
//设置热泵实体对象
|
||||
PumpSetEntity pumpData=new PumpSetEntity(); |
||||
pumpData.setBuildingId(deviceInstallEntity.getBuildingId()); |
||||
pumpData.setPumpId(deviceAddr); |
||||
if (param==null || param.equals("") || param.equals("温度设定")){ |
||||
//发送指令
|
||||
if (brand.equals("美的")){ |
||||
deviceCodeParam.setRegisterAddr("0642"); //寄存器地址
|
||||
deviceCodeParam.setFunCode("10"); //功能码写数据
|
||||
}else{ |
||||
deviceCodeParam.setRegisterAddr("0003"); //寄存器地址
|
||||
deviceCodeParam.setFunCode("06"); //功能码写数据
|
||||
} |
||||
//保存数据
|
||||
pumpData.setTempSet(serialPortModel.getDataValue()); |
||||
pumpSetService.savePumpSet(pumpData);//热泵信息保存数据库
|
||||
|
||||
nowDataService.upTempSet2(buildingId,serialPortModel.getDataValue(),deviceAddr);//更新实时状态表
|
||||
log.info("楼栋编号:"+buildingId+",设定温度:"+serialPortModel.getDataValue()+",热泵编号:"+deviceAddr); |
||||
}else if(param.equals("时段1")){ |
||||
if (brand.equals("美的")) { |
||||
//发送指令
|
||||
deviceCodeParam.setRegisterAddr("0656"); //寄存器地址
|
||||
deviceCodeParam.setFunCode("10"); //功能码写数据
|
||||
//保存数据
|
||||
String time=serialPortModel.getDataValue(); |
||||
if (time.length()==8){ |
||||
String statTime=time.substring(0,2)+":"+time.substring(2,4); |
||||
String closeTime=time.substring(4,6)+":"+time.substring(6,8); |
||||
pumpData.setStartTime1(statTime); |
||||
pumpData.setCloseTime1(closeTime); |
||||
} |
||||
pumpSetService.savePumpSet(pumpData);//热泵信息保存数据库
|
||||
} |
||||
}else if(param.equals("时段2")){ |
||||
if (brand.equals("美的")) { |
||||
//发送指令
|
||||
deviceCodeParam.setRegisterAddr("065A"); //寄存器地址
|
||||
deviceCodeParam.setFunCode("10"); //功能码写数据
|
||||
//保存数据
|
||||
String time=serialPortModel.getDataValue(); |
||||
if (time.length()==8){ |
||||
String statTime=time.substring(0,2)+":"+time.substring(2,4); |
||||
String closeTime=time.substring(4,6)+":"+time.substring(6,8); |
||||
pumpData.setStartTime2(statTime); |
||||
pumpData.setCloseTime2(closeTime); |
||||
} |
||||
pumpSetService.savePumpSet(pumpData);//热泵信息保存数据库
|
||||
} |
||||
} |
||||
}else if (deviceType.equals("时控")){ |
||||
deviceCodeParam.setFunCode("10"); //功能码写数据
|
||||
String time=serialPortModel.getDataValue(); |
||||
if (time.length()==16){ |
||||
//时段1 HHmmHHmm
|
||||
String statTime1=time.substring(0,2)+":"+time.substring(2,4); //HH:mm
|
||||
String closeTime1=time.substring(4,6)+":"+time.substring(6,8); //HH:mm
|
||||
//时段2
|
||||
String statTime2=time.substring(8,10)+":"+time.substring(10,12); |
||||
String closeTime2=time.substring(12,14)+":"+time.substring(14,16); |
||||
if(param.equals("L1")){ |
||||
deviceCodeParam.setRegisterAddr("0009"); //寄存器地址,L3路,L1(0009),L2(000D)
|
||||
controlData.setUseStartTime1(statTime1); |
||||
controlData.setUseCloseTime1(closeTime1); |
||||
controlData.setUseStartTime2(statTime2); |
||||
controlData.setUseCloseTime2(closeTime2); |
||||
}else if(param.equals("L2")){ |
||||
deviceCodeParam.setRegisterAddr("000D"); |
||||
controlData.setUseStartTime3(statTime1); |
||||
controlData.setUseCloseTime3(closeTime1); |
||||
controlData.setUseStartTime4(statTime2); |
||||
controlData.setUseCloseTime4(closeTime2); |
||||
}else{ |
||||
deviceCodeParam.setRegisterAddr("0011"); |
||||
controlData.setUseStartTime5(statTime1); |
||||
controlData.setUseCloseTime5(closeTime1); |
||||
controlData.setUseStartTime6(statTime2); |
||||
controlData.setUseCloseTime6(closeTime2); |
||||
} |
||||
} |
||||
controlSetService.saveControlSet(controlData); //保存设置内容
|
||||
}else if (deviceType.equals("水位开关")){ |
||||
if (brand==null || brand.equals("") || brand.equals("中凯")){//品牌
|
||||
deviceCodeParam.setFunCode("12"); //功能码写数据
|
||||
if (!serialPortModel.getDataValue().equals("100%")){ |
||||
deviceCodeParam.setDataValue("100%"); |
||||
serialPortSingle.serialPortSend(deviceCodeParam);//生成并发送指令
|
||||
Thread.sleep(1500); |
||||
} |
||||
}else if(brand.equals("远向")){ |
||||
deviceCodeParam.setFunCode("06"); //功能码写数据
|
||||
if (!serialPortModel.getDataValue().equals("100%")){ |
||||
deviceCodeParam.setDataValue("100%"); |
||||
serialPortSingle.serialPortSend(deviceCodeParam);//生成并发送指令
|
||||
Thread.sleep(1500); |
||||
} |
||||
}else if(brand.equals("顶威")){ |
||||
deviceCodeParam.setFunCode("0407"); //功能码写数据
|
||||
} |
||||
deviceCodeParam.setDataValue(serialPortModel.getDataValue()); |
||||
//controlData.setLevelSet(serialPortModel.getDataValue());
|
||||
//controlSetService.saveControlSet(controlData);
|
||||
nowDataService.upLevelSet(buildingId,serialPortModel.getDataValue());//更新实时状态表
|
||||
} |
||||
serialPortSingle.serialPortSend(deviceCodeParam);//生成并发送指令
|
||||
}else{ |
||||
return HttpResult.error("通讯ID为空!"); |
||||
} |
||||
} |
||||
Constant.WEB_FLAG=false; //单抄,恢复采集
|
||||
return HttpResult.ok(); |
||||
}catch(Exception e){ |
||||
// e.printStackTrace();
|
||||
Constant.WEB_FLAG=false; //单抄,恢复采集
|
||||
return HttpResult.error(500,"fail"); |
||||
} |
||||
} |
||||
|
||||
//读数据
|
||||
@SysLogger(title="控制管理",optDesc = "读设备数据") |
||||
@PostMapping(value="/read") |
||||
public HttpResult readData(@RequestBody List<SerialPortModel> params){ |
||||
try{ |
||||
SerialPortSingle serialPortSingle = new SerialPortSingle(); |
||||
DeviceCodeParamEntity deviceCodeParam=new DeviceCodeParamEntity(); |
||||
String rtData=""; //返回值
|
||||
Constant.WEB_FLAG=true; //单抄,暂时停止采集
|
||||
for (SerialPortModel serialPortModel : |
||||
params) { |
||||
String deviceAddr=serialPortModel.getDeviceAddr();//设备通讯地址
|
||||
String deviceType=serialPortModel.getDeviceType();//设备类型
|
||||
String buildingId=serialPortModel.getBuildingId();//楼栋
|
||||
String param=serialPortModel.getParam();//操作参数
|
||||
if (deviceAddr==null || deviceAddr=="" ){ |
||||
List<DeviceModel> list=deviceInstallService.selectDevices(buildingId,deviceType); |
||||
deviceAddr=list.get(0).getDeviceAddr(); |
||||
} |
||||
if(deviceAddr!=null && deviceAddr.length()>0){ |
||||
DeviceInstallEntity deviceInstallEntity=deviceInstallService.selectDevice(deviceAddr,deviceType,buildingId); |
||||
//发送指令实体类
|
||||
deviceCodeParam.setDeviceAddr(deviceAddr); |
||||
deviceCodeParam.setDeviceType(deviceType); |
||||
deviceCodeParam.setDataCom(deviceInstallEntity.getDataCom()); |
||||
deviceCodeParam.setBaudrate(deviceInstallEntity.getBaudRate()); |
||||
deviceCodeParam.setParity(deviceInstallEntity.getParity()); |
||||
deviceCodeParam.setDataValue(serialPortModel.getDataValue());//传入相关参数值
|
||||
deviceCodeParam.setBuildingId(buildingId); |
||||
String brand=deviceInstallEntity.getBrand();//品牌
|
||||
deviceCodeParam.setBrand(brand); |
||||
//设置设备实体对象
|
||||
ControlSetEntity controlData=new ControlSetEntity(); |
||||
controlData.setBuildingId(deviceInstallEntity.getBuildingId()); |
||||
if (deviceType==null || deviceType.equals("") || deviceType.equals("热泵")){ |
||||
//设置热泵实体对象
|
||||
PumpSetEntity pumpData=new PumpSetEntity(); |
||||
pumpData.setBuildingId(deviceInstallEntity.getBuildingId()); |
||||
pumpData.setPumpId(deviceAddr); |
||||
if (param==null || param.equals("") || param.equals("读温度设定")){ |
||||
deviceCodeParam.setFunCode("03"); //功能码读数据
|
||||
if (brand.equals("美的")){ |
||||
deviceCodeParam.setRegisterAddr("0642"); //寄存器地址
|
||||
}else{ |
||||
deviceCodeParam.setRegisterAddr("0003"); //寄存器地址
|
||||
} |
||||
rtData=serialPortSingle.serialPortSend(deviceCodeParam);//生成并发送指令
|
||||
if (!rtData.equals("")){ |
||||
pumpData.setTempSet(rtData); |
||||
pumpSetService.savePumpSet(pumpData);//热泵信息保存数据库
|
||||
} |
||||
} else if (param.equals("实际温度")){ |
||||
deviceCodeParam.setFunCode("03"); //功能码读数据
|
||||
if (brand.equals("美的")){ |
||||
deviceCodeParam.setRegisterAddr("0007"); //寄存器地址
|
||||
}else{ |
||||
deviceCodeParam.setRegisterAddr("0064"); //寄存器地址
|
||||
} |
||||
rtData=serialPortSingle.serialPortSend(deviceCodeParam);//生成并发送指令
|
||||
if (!rtData.equals("")){ |
||||
pumpData.setWaterTemp(rtData); |
||||
pumpSetService.savePumpSet(pumpData);//热泵信息保存数据库
|
||||
} |
||||
} else if (param.equals("运行状态")){ |
||||
deviceCodeParam.setFunCode("03"); //功能码读数据
|
||||
if (brand.equals("美的")){ |
||||
deviceCodeParam.setRegisterAddr("0641"); //寄存器地址
|
||||
}else{ |
||||
deviceCodeParam.setRegisterAddr("0BBD"); //寄存器地址
|
||||
} |
||||
rtData=serialPortSingle.serialPortSend(deviceCodeParam);//生成并发送指令
|
||||
//pumpData(rtData);
|
||||
//pumpSetService.savePumpSet(pumpData);//热泵信息保存数据库
|
||||
} else if(param.equals("时段1")){ |
||||
if (brand.equals("美的")) { |
||||
//发送指令
|
||||
deviceCodeParam.setRegisterAddr("0656"); //寄存器地址
|
||||
deviceCodeParam.setFunCode("03"); //功能码读数据
|
||||
//保存数据
|
||||
rtData=serialPortSingle.serialPortSend(deviceCodeParam);//生成并发送指令
|
||||
String time=rtData; |
||||
if (time.length()==8){ |
||||
String statTime=time.substring(0,2)+":"+time.substring(2,4); |
||||
String closeTime=time.substring(4,6)+":"+time.substring(6,8); |
||||
pumpData.setStartTime1(statTime); |
||||
pumpData.setCloseTime1(closeTime); |
||||
} |
||||
pumpSetService.savePumpSet(pumpData);//热泵信息保存数据库
|
||||
} |
||||
}else if(param.equals("时段2")){ |
||||
if (brand.equals("美的")) { |
||||
//发送指令
|
||||
deviceCodeParam.setRegisterAddr("065A"); //寄存器地址
|
||||
deviceCodeParam.setFunCode("03"); //功能码读数据
|
||||
//保存数据
|
||||
rtData=serialPortSingle.serialPortSend(deviceCodeParam);//生成并发送指令
|
||||
String time=rtData; |
||||
if (time.length()==8){ |
||||
String statTime=time.substring(0,2)+":"+time.substring(2,4); |
||||
String closeTime=time.substring(4,6)+":"+time.substring(6,8); |
||||
pumpData.setStartTime2(statTime); |
||||
pumpData.setCloseTime2(closeTime); |
||||
} |
||||
pumpSetService.savePumpSet(pumpData);//热泵信息保存数据库
|
||||
} |
||||
} |
||||
}else if (deviceType.equals("时控")){ |
||||
if(param.equals("L1")){ |
||||
deviceCodeParam.setRegisterAddr("0009"); //寄存器地址,L3路,L1(0009),L2(000D)
|
||||
}else if(param.equals("L2")){ |
||||
deviceCodeParam.setRegisterAddr("000D"); |
||||
}else{ |
||||
deviceCodeParam.setRegisterAddr("0011"); |
||||
} |
||||
deviceCodeParam.setFunCode("03"); //功能码读数据
|
||||
rtData=serialPortSingle.serialPortSend(deviceCodeParam);//生成并发送指令
|
||||
|
||||
String time=rtData; |
||||
if (time.length()==16){ |
||||
//时段1
|
||||
String statTime1=time.substring(0,2)+":"+time.substring(2,4); |
||||
String closeTime1=time.substring(4,6)+":"+time.substring(6,8); |
||||
//时段2
|
||||
String statTime2=time.substring(8,10)+":"+time.substring(10,12); |
||||
String closeTime2=time.substring(12,14)+":"+time.substring(14,16); |
||||
|
||||
if(param.equals("L1")){ |
||||
controlData.setUseStartTime1(statTime1); |
||||
controlData.setUseCloseTime1(closeTime1); |
||||
controlData.setUseStartTime2(statTime2); |
||||
controlData.setUseCloseTime2(closeTime2); |
||||
}else if(param.equals("L2")){ |
||||
controlData.setUseStartTime3(statTime1); |
||||
controlData.setUseCloseTime3(closeTime1); |
||||
controlData.setUseStartTime4(statTime2); |
||||
controlData.setUseCloseTime4(closeTime2); |
||||
}else{ |
||||
controlData.setUseStartTime5(statTime1); |
||||
controlData.setUseCloseTime5(closeTime1); |
||||
controlData.setUseStartTime6(statTime2); |
||||
controlData.setUseCloseTime6(closeTime2); |
||||
} |
||||
} |
||||
controlSetService.saveControlSet(controlData); //保存设置内容
|
||||
}else if (deviceType.equals("水位开关") && !param.equals("状态")){ |
||||
if (brand==null || brand.equals("") || brand.equals("中凯")){//品牌
|
||||
deviceCodeParam.setFunCode("17"); //功能码读
|
||||
deviceCodeParam.setRegisterAddr("0017"); |
||||
}else if(brand.equals("远向")){ |
||||
deviceCodeParam.setFunCode("03"); //功能码读
|
||||
deviceCodeParam.setRegisterAddr("0018"); |
||||
}else if(brand.equals("顶威")){ |
||||
deviceCodeParam.setFunCode("0102"); //功能码读
|
||||
deviceCodeParam.setRegisterAddr("0102"); |
||||
} |
||||
rtData=serialPortSingle.serialPortSend(deviceCodeParam);//生成并发送指令
|
||||
deviceCodeParam.setDataValue(rtData); |
||||
//controlData.setLevelSet(serialPortModel.getDataValue());
|
||||
//controlSetService.saveControlSet(controlData);
|
||||
log.info("--------------读取返回数据:"+rtData+"------------------"); |
||||
}else if (deviceType.equals("水位开关") && param.equals("状态")){ |
||||
if(brand.equals("远向")){ |
||||
deviceCodeParam.setFunCode("03"); //功能码读
|
||||
deviceCodeParam.setRegisterAddr("0010"); |
||||
} |
||||
rtData=serialPortSingle.serialPortSend(deviceCodeParam);//生成并发送指令
|
||||
|
||||
}else if (deviceType.equals("温度变送器")){ |
||||
deviceCodeParam.setFunCode("03"); //功能码读
|
||||
deviceCodeParam.setRegisterAddr("0028"); |
||||
rtData=serialPortSingle.serialPortSend(deviceCodeParam);//生成并发送指令
|
||||
}else if (deviceType.equals("压变")){ |
||||
deviceCodeParam.setFunCode("03"); //功能码读
|
||||
deviceCodeParam.setRegisterAddr("0004"); |
||||
rtData=serialPortSingle.serialPortSend(deviceCodeParam);//生成并发送指令
|
||||
}else if (deviceType.equals("水表")){ |
||||
rtData=serialPortSingle.serialPortSend(deviceCodeParam); |
||||
}else if (deviceType.equals("电表")){ |
||||
rtData=serialPortSingle.serialPortSend(deviceCodeParam); |
||||
} |
||||
}else{ |
||||
return HttpResult.error(500,"fail"); |
||||
} |
||||
} |
||||
Constant.WEB_FLAG=false; //单抄,恢复采集
|
||||
if(ExchangeStringUtil.getJSONType(rtData)){ |
||||
Map map = JSONObject.parseObject(rtData); |
||||
return HttpResult.ok("success",map); |
||||
}else{ |
||||
if(rtData.equals("fail")){ |
||||
return HttpResult.error(500,"fail"); |
||||
}else{ |
||||
return HttpResult.ok(rtData,rtData); |
||||
} |
||||
} |
||||
}catch (Exception e){ |
||||
Constant.WEB_FLAG=false; //单抄,恢复采集
|
||||
return HttpResult.error(500,"fail"); |
||||
} |
||||
} |
||||
|
||||
@PostMapping(value="/pump") |
||||
public HttpResult queryPumpSet(@RequestParam(value = "pumpId",defaultValue = "2") String pumpId, |
||||
@RequestParam(value = "buildingId") String buildingId){ |
||||
try{ |
||||
PumpSetEntity list=pumpSetService.queryPumpSet(pumpId,buildingId); |
||||
return HttpResult.ok(list); |
||||
}catch (Exception e){ |
||||
//e.printStackTrace();
|
||||
return HttpResult.error(); |
||||
} |
||||
|
||||
} |
||||
|
||||
@PostMapping(value="/control") |
||||
public HttpResult queryControlSet(@RequestParam(value = "buildingId") String buildingId){ |
||||
try{ |
||||
ControlSetEntity list=controlSetService.queryControlSet(buildingId); |
||||
return HttpResult.ok(list); |
||||
}catch (Exception e){ |
||||
// e.printStackTrace();
|
||||
return HttpResult.error(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,97 @@
|
||||
package com.mh.user.controller; |
||||
|
||||
import com.mh.common.http.HttpResult; |
||||
import com.mh.user.entity.AlarmInfoSumEntity; |
||||
import com.mh.user.entity.DeviceStateEntity; |
||||
import com.mh.user.entity.EnergySumEntity; |
||||
import com.mh.user.entity.MaintainSumEntity; |
||||
import com.mh.user.service.BuildingService; |
||||
import com.mh.user.service.SummaryService; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.web.bind.annotation.PostMapping; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
@RestController |
||||
@RequestMapping("sum") |
||||
public class SummaryController { |
||||
|
||||
@Autowired |
||||
SummaryService summaryService; |
||||
|
||||
@Autowired |
||||
BuildingService buildingService; |
||||
|
||||
//查询运行状态页面设备状态汇总
|
||||
@PostMapping(value="/deviceState") |
||||
public HttpResult queryDeviceState() { |
||||
try{ |
||||
DeviceStateEntity record=summaryService.queryDeviceState(); |
||||
return HttpResult.ok(record); |
||||
}catch (Exception e){ |
||||
//e.printStackTrace();
|
||||
return HttpResult.error(); |
||||
} |
||||
|
||||
} |
||||
|
||||
//查询日月年用量汇总
|
||||
@PostMapping(value="/energySum") |
||||
public HttpResult queryEnergySum(@RequestParam(value= "buildingId", required=false)String buildingId, |
||||
@RequestParam(value= "curDate", required=false)String curDate, |
||||
@RequestParam(value= "type", required=true)Integer type) { |
||||
try{ |
||||
String areaId=""; |
||||
if (buildingId!=null && buildingId.length()>0){ |
||||
if (!buildingId.equals("所有")){ |
||||
areaId=buildingService.queryAreaId(Integer.parseInt(buildingId)); |
||||
} |
||||
} |
||||
EnergySumEntity record; |
||||
if (areaId!=null && areaId.length()>0){ |
||||
record=summaryService.queryEnergySum(areaId,curDate,type); |
||||
}else{ |
||||
record=summaryService.queryEnergySum(buildingId,curDate,type); |
||||
} |
||||
return HttpResult.ok(record); |
||||
}catch (Exception e){ |
||||
//e.printStackTrace();
|
||||
return HttpResult.error(); |
||||
} |
||||
} |
||||
|
||||
//查询维修量汇总
|
||||
@PostMapping(value="/maintainSum") |
||||
public HttpResult queryMaintainSum(@RequestParam(value= "buildingId", required=false)String buildingId, |
||||
@RequestParam(value= "curDate", required=false)String curDate) { |
||||
try{ |
||||
MaintainSumEntity record; |
||||
if(buildingId==null || buildingId.equals("")){ |
||||
record=summaryService.queryMaintainSum("所有",curDate); |
||||
}else { |
||||
record=summaryService.queryMaintainSum(buildingId,curDate); |
||||
} |
||||
|
||||
return HttpResult.ok(record); |
||||
}catch (Exception e){ |
||||
//e.printStackTrace();
|
||||
return HttpResult.error(); |
||||
} |
||||
} |
||||
|
||||
//警报管理汇总查询
|
||||
@PostMapping(value="/alarmInfoSum") |
||||
public HttpResult queryAlarmInfoSum(@RequestParam(value= "buildingId", required=false)String buildingId, |
||||
@RequestParam(value= "curDate", required=false)String curDate) { |
||||
try{ |
||||
|
||||
AlarmInfoSumEntity record=summaryService.queryAlarmInfoSum(buildingId,curDate); |
||||
return HttpResult.ok(record); |
||||
}catch (Exception e){ |
||||
//e.printStackTrace();
|
||||
return HttpResult.error(); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,46 @@
|
||||
package com.mh.user.controller; |
||||
|
||||
import com.mh.common.http.HttpResult; |
||||
import com.mh.user.model.SysDept; |
||||
import com.mh.user.service.SysDeptService; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.security.access.prepost.PreAuthorize; |
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
import org.springframework.web.bind.annotation.PostMapping; |
||||
import org.springframework.web.bind.annotation.RequestBody; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 机构控制器 |
||||
* @author ljf |
||||
* @date 2020-04-25 |
||||
*/ |
||||
@RestController |
||||
@RequestMapping("dept") |
||||
public class SysDeptController { |
||||
|
||||
@Autowired |
||||
private SysDeptService sysDeptService; |
||||
|
||||
@PreAuthorize("hasAuthority('sys:dept:add') AND hasAuthority('sys:dept:edit')") |
||||
@PostMapping(value="/save") |
||||
public HttpResult save(@RequestBody SysDept record) { |
||||
return HttpResult.ok(sysDeptService.save(record)); |
||||
} |
||||
|
||||
@PreAuthorize("hasAuthority('sys:dept:delete')") |
||||
@PostMapping(value="/delete") |
||||
public HttpResult delete(@RequestBody List<SysDept> records) { |
||||
return HttpResult.ok(sysDeptService.delete(records)); |
||||
} |
||||
|
||||
@PreAuthorize("hasAuthority('sys:dept:view')") |
||||
@GetMapping(value="/findTree") |
||||
public HttpResult findTree() { |
||||
return HttpResult.ok(sysDeptService.findTree()); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,54 @@
|
||||
package com.mh.user.controller; |
||||
|
||||
import com.mh.common.http.HttpResult; |
||||
import com.mh.common.page.PageRequest; |
||||
import com.mh.user.model.SysDict; |
||||
import com.mh.user.service.SysDictService; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.security.access.prepost.PreAuthorize; |
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
import org.springframework.web.bind.annotation.PostMapping; |
||||
import org.springframework.web.bind.annotation.RequestBody; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
import java.util.List; |
||||
|
||||
|
||||
/** |
||||
* 字典控制器 |
||||
* @author ljf |
||||
* @date 2020-04-25 |
||||
*/ |
||||
@RestController |
||||
@RequestMapping("dict") |
||||
public class SysDictController { |
||||
|
||||
@Autowired |
||||
private SysDictService sysDictService; |
||||
|
||||
@PreAuthorize("hasAuthority('sys:dict:add') AND hasAuthority('sys:dict:edit')") |
||||
@PostMapping(value="/save") |
||||
public HttpResult save(@RequestBody SysDict record) { |
||||
return HttpResult.ok(sysDictService.save(record)); |
||||
} |
||||
|
||||
@PreAuthorize("hasAuthority('sys:dict:delete')") |
||||
@PostMapping(value="/delete") |
||||
public HttpResult delete(@RequestBody List<SysDict> records) { |
||||
return HttpResult.ok(sysDictService.delete(records)); |
||||
} |
||||
|
||||
@PreAuthorize("hasAuthority('sys:dict:view')") |
||||
@PostMapping(value="/findPage") |
||||
public HttpResult findPage(@RequestBody PageRequest pageRequest) { |
||||
return HttpResult.ok(sysDictService.findPage(pageRequest)); |
||||
} |
||||
|
||||
@PreAuthorize("hasAuthority('sys:dict:view')") |
||||
@GetMapping(value="/findByLable") |
||||
public HttpResult findByLable(@RequestParam String lable) { |
||||
return HttpResult.ok(sysDictService.findByLable(lable)); |
||||
} |
||||
} |
@ -0,0 +1,75 @@
|
||||
package com.mh.user.controller; |
||||
|
||||
import com.mh.common.http.HttpResult; |
||||
import com.mh.common.page.PageRequest; |
||||
import com.mh.user.annotation.SysLogger; |
||||
import com.mh.user.entity.SysParamEntity; |
||||
import com.mh.user.model.SysLog; |
||||
import com.mh.user.service.SysLogService; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.security.access.prepost.PreAuthorize; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 日志控制器 |
||||
* @author ljf |
||||
* @date 2020-04-25 |
||||
*/ |
||||
@RestController |
||||
@RequestMapping("log") |
||||
public class SysLogController { |
||||
|
||||
@Autowired |
||||
private SysLogService sysLogService; |
||||
|
||||
@PostMapping(value="/findPage") |
||||
public HttpResult findPage(@RequestBody PageRequest pageRequest) { |
||||
return HttpResult.ok(sysLogService.findPage(pageRequest)); |
||||
} |
||||
|
||||
@SysLogger(title="日志",optDesc = "按操作员查询对应的操作日志") |
||||
@PostMapping(value="/findLogs") |
||||
public HttpResult findLogs(@RequestParam(value = "userName", required = false)String userName, |
||||
@RequestParam int page, |
||||
@RequestParam int limit) { |
||||
try{ |
||||
List<SysLog> list=new ArrayList<SysLog>(); |
||||
list=sysLogService.findLogs(userName,page,limit); |
||||
int count=sysLogService.findCount(userName,page,limit); |
||||
|
||||
return HttpResult.ok(count,list); |
||||
}catch (Exception e){ |
||||
e.printStackTrace(); |
||||
return HttpResult.error(); |
||||
} |
||||
|
||||
} |
||||
|
||||
// 查询日志详情
|
||||
@SysLogger(title="日志",optDesc = "查询日志详情") |
||||
@PostMapping(value="/logInfo") |
||||
public HttpResult logInfo(@RequestParam int id){ |
||||
try{ |
||||
SysLog sysLog=sysLogService.logInfo(id); |
||||
return HttpResult.ok(sysLog); |
||||
}catch (Exception e){ |
||||
e.printStackTrace(); |
||||
return HttpResult.error(); |
||||
} |
||||
} |
||||
|
||||
// 查询系统参数
|
||||
@PostMapping(value="/sysParam") |
||||
public HttpResult selectSysParam(){ |
||||
try{ |
||||
SysParamEntity sysParam=sysLogService.selectSysParam(); |
||||
return HttpResult.ok(sysParam); |
||||
}catch (Exception e){ |
||||
e.printStackTrace(); |
||||
return HttpResult.error(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,109 @@
|
||||
package com.mh.user.controller; |
||||
|
||||
import java.awt.image.BufferedImage; |
||||
import java.io.IOException; |
||||
|
||||
import javax.imageio.ImageIO; |
||||
import javax.servlet.ServletException; |
||||
import javax.servlet.ServletOutputStream; |
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
|
||||
import com.mh.common.http.HttpResult; |
||||
import com.mh.common.utils.IOUtils; |
||||
import com.mh.user.dynamic.datasource.DataSourceContextHolder; |
||||
import com.mh.user.dynamic.datasource.DataSourceObject; |
||||
import com.mh.user.entity.DBEntity; |
||||
import com.mh.user.model.SysUser; |
||||
import com.mh.user.security.JwtAuthenticatioToken; |
||||
import com.mh.user.service.SysUserService; |
||||
import com.mh.user.utils.AESUtil; |
||||
import com.mh.user.utils.PasswordUtils; |
||||
import com.mh.user.utils.SecurityUtils; |
||||
import com.mh.user.vo.LoginBean; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.security.authentication.AuthenticationManager; |
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
import org.springframework.web.bind.annotation.PostMapping; |
||||
import org.springframework.web.bind.annotation.RequestBody; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
import com.google.code.kaptcha.Constants; |
||||
import com.google.code.kaptcha.Producer; |
||||
|
||||
/** |
||||
* 登录控制器 |
||||
* @author ljf |
||||
* @date 2020-04-25 |
||||
*/ |
||||
@RestController |
||||
public class SysLoginController { |
||||
|
||||
@Autowired |
||||
private Producer producer; |
||||
@Autowired |
||||
private SysUserService sysUserService; |
||||
@Autowired |
||||
private AuthenticationManager authenticationManager; |
||||
|
||||
@GetMapping("captcha.jpg") |
||||
public void captcha(HttpServletResponse response, HttpServletRequest request) throws ServletException, IOException { |
||||
response.setHeader("Cache-Control", "no-store, no-cache"); |
||||
response.setContentType("image/jpeg"); |
||||
|
||||
// 生成文字验证码
|
||||
String text = producer.createText(); |
||||
// 生成图片验证码
|
||||
BufferedImage image = producer.createImage(text); |
||||
// 保存到验证码到 session
|
||||
request.getSession().setAttribute(Constants.KAPTCHA_SESSION_KEY, text); |
||||
|
||||
ServletOutputStream out = response.getOutputStream(); |
||||
ImageIO.write(image, "jpg", out); |
||||
IOUtils.closeQuietly(out); |
||||
} |
||||
|
||||
/** |
||||
* 登录接口 |
||||
*/ |
||||
@PostMapping(value = "/login") |
||||
public HttpResult login(@RequestBody LoginBean loginBean, HttpServletRequest request) throws Exception { |
||||
String username = loginBean.getAccount(); |
||||
String password = loginBean.getPassword(); |
||||
String captcha = loginBean.getCaptcha(); |
||||
|
||||
// 用户信息
|
||||
SysUser user = sysUserService.findByName(username); |
||||
|
||||
// 账号不存在、密码错误
|
||||
if (user == null) { |
||||
return HttpResult.error("账号不存在"); |
||||
} |
||||
|
||||
if (!PasswordUtils.matches(user.getSalt(), password, user.getPassword())) { |
||||
return HttpResult.error("密码不正确"); |
||||
} |
||||
|
||||
// 账号锁定
|
||||
if (user.getStatus() == 0) { |
||||
return HttpResult.error("账号已被锁定,请联系管理员"); |
||||
} |
||||
|
||||
// 系统登录认证
|
||||
JwtAuthenticatioToken token = SecurityUtils.login(request, username, password, authenticationManager); |
||||
|
||||
//更新登录日期
|
||||
sysUserService.updateLoginTime(username); |
||||
|
||||
// DBEntity dbEntity = sysUserService.queryDBInfo(username);
|
||||
// dbEntity.setDB_Pwd(AESUtil.AESdecrypt(dbEntity.getDB_Pwd()));
|
||||
// // 切换数据源
|
||||
// DataSourceObject dataSourceObject = new DataSourceObject();
|
||||
// String SourceName = "sqlServer-"+dbEntity.getDB_Names();
|
||||
// dataSourceObject.SwitchSQLServerDataSource(dbEntity,SourceName);
|
||||
// DataSourceContextHolder.setDBType(SourceName);
|
||||
|
||||
return HttpResult.ok(token); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,54 @@
|
||||
package com.mh.user.controller; |
||||
|
||||
import com.mh.common.http.HttpResult; |
||||
import com.mh.user.model.SysMenu; |
||||
import com.mh.user.service.SysMenuService; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.security.access.prepost.PreAuthorize; |
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
import org.springframework.web.bind.annotation.PostMapping; |
||||
import org.springframework.web.bind.annotation.RequestBody; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 菜单控制器 |
||||
* @author ljf |
||||
* @date 2020-04-25 |
||||
*/ |
||||
@RestController |
||||
@RequestMapping("menu") |
||||
public class SysMenuController { |
||||
|
||||
@Autowired |
||||
private SysMenuService sysMenuService; |
||||
|
||||
@PreAuthorize("hasAuthority('sys:menu:add') AND hasAuthority('sys:menu:edit')") |
||||
@PostMapping(value="/save") |
||||
public HttpResult save(@RequestBody SysMenu record) { |
||||
|
||||
return HttpResult.ok(sysMenuService.save(record)); |
||||
} |
||||
|
||||
@PreAuthorize("hasAuthority('sys:menu:delete')") |
||||
@PostMapping(value="/delete") |
||||
public HttpResult delete(@RequestBody List<SysMenu> records) { |
||||
return HttpResult.ok(sysMenuService.delete(records)); |
||||
} |
||||
|
||||
//查询菜单树,用户ID和用户名为空则查询全部,获取菜单类型,0:获取所有菜单,包含按钮,1:获取所有菜单,不包含按钮
|
||||
@PreAuthorize("hasAuthority('sys:menu:view')") |
||||
@GetMapping(value="/findNavTree") |
||||
public HttpResult findNavTree(@RequestParam String userName) { |
||||
return HttpResult.ok(sysMenuService.findTree(userName, 1)); |
||||
} |
||||
|
||||
@PreAuthorize("hasAuthority('sys:menu:view')") |
||||
@GetMapping(value="/findMenuTree") |
||||
public HttpResult findMenuTree() { |
||||
return HttpResult.ok(sysMenuService.findTree(null, 0)); |
||||
} |
||||
} |
@ -0,0 +1,127 @@
|
||||
package com.mh.user.controller; |
||||
|
||||
import com.mh.common.http.HttpResult; |
||||
import com.mh.common.page.PageRequest; |
||||
import com.mh.user.annotation.SysLogger; |
||||
import com.mh.user.constants.SysConstants; |
||||
import com.mh.user.mapper.SysRoleMapper; |
||||
import com.mh.user.model.SysRole; |
||||
import com.mh.user.model.SysRoleMenu; |
||||
import com.mh.user.service.SysRoleService; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.security.access.prepost.PreAuthorize; |
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
import org.springframework.web.bind.annotation.PostMapping; |
||||
import org.springframework.web.bind.annotation.RequestBody; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
import java.util.Date; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 角色控制器 |
||||
* @author ljf |
||||
* @date 2020-04-25 |
||||
*/ |
||||
@RestController |
||||
@RequestMapping("role") |
||||
public class SysRoleController { |
||||
|
||||
@Autowired |
||||
private SysRoleService sysRoleService; |
||||
@Autowired |
||||
private SysRoleMapper sysRoleMapper; |
||||
|
||||
@SysLogger(title="角色管理",optDesc = "保存或者编辑角色信息") |
||||
@PostMapping(value="/save") |
||||
public HttpResult save(@RequestBody SysRole record) { |
||||
SysRole role = sysRoleService.findById(record.getId()); |
||||
if(role != null) { |
||||
if(SysConstants.ADMIN.equalsIgnoreCase(role.getName())) { |
||||
return HttpResult.error("超级管理员不允许修改!"); |
||||
} |
||||
List<SysRole> role1=sysRoleService.findByName(record.getName()); |
||||
if (role1!=null && role1.size()>0){ |
||||
if(role.getId()!=role1.get(0).getId()){ |
||||
return HttpResult.error("角色名不能重复!"); |
||||
} |
||||
} |
||||
} |
||||
// 新增角色
|
||||
if((record.getId() == null || record.getId() ==0) && !sysRoleService.findByName(record.getName()).isEmpty()) { |
||||
return HttpResult.error("角色名已存在!"); |
||||
} |
||||
record.setCreateBy("admin"); |
||||
Date date=new Date(); |
||||
record.setCreateTime(date); //创建日期
|
||||
record.setLastUpdateTime(date); //更新日期
|
||||
return HttpResult.ok(sysRoleService.save(record)); |
||||
} |
||||
|
||||
// 删除多个
|
||||
@SysLogger(title="角色管理",optDesc = "删除角色信息") |
||||
@PostMapping(value="/delete") |
||||
public HttpResult delete(@RequestBody List<SysRole> records) { |
||||
|
||||
return HttpResult.ok(sysRoleService.delete(records)); |
||||
} |
||||
|
||||
// 删除单个
|
||||
@PostMapping(value="/deleteById") |
||||
public HttpResult deleteById(@RequestBody SysRole record) { |
||||
|
||||
return HttpResult.ok(sysRoleService.delete(record)); |
||||
} |
||||
|
||||
@PreAuthorize("hasAuthority('sys:role:view')") |
||||
@PostMapping(value="/findPage") |
||||
public HttpResult findPage(@RequestBody PageRequest pageRequest) { |
||||
return HttpResult.ok(sysRoleService.findPage(pageRequest)); |
||||
} |
||||
|
||||
@PreAuthorize("hasAuthority('sys:role:view')") |
||||
@GetMapping(value="/findAll") |
||||
public HttpResult findAll() { |
||||
return HttpResult.ok(sysRoleService.findAll()); |
||||
} |
||||
|
||||
@PreAuthorize("hasAuthority('sys:role:view')") |
||||
@GetMapping(value="/findRoleMenus") |
||||
public HttpResult findRoleMenus(@RequestParam Long roleId) { |
||||
return HttpResult.ok(sysRoleService.findRoleMenus(roleId)); |
||||
} |
||||
|
||||
@PreAuthorize("hasAuthority('sys:role:view')") |
||||
@PostMapping(value="/saveRoleMenus") |
||||
public HttpResult saveRoleMenus(@RequestBody List<SysRoleMenu> records) { |
||||
for(SysRoleMenu record:records) { |
||||
SysRole sysRole = sysRoleMapper.selectByPrimaryKey(record.getRoleId()); |
||||
if(SysConstants.ADMIN.equalsIgnoreCase(sysRole.getName())) { |
||||
// 如果是超级管理员,不允许修改
|
||||
return HttpResult.error("超级管理员拥有所有菜单权限,不允许修改!"); |
||||
} |
||||
} |
||||
return HttpResult.ok(sysRoleService.saveRoleMenus(records)); |
||||
} |
||||
|
||||
@PostMapping(value="/findId") |
||||
public HttpResult findByName(@RequestParam String name) { |
||||
return HttpResult.ok(sysRoleService.findByName(name)); |
||||
} |
||||
|
||||
@SysLogger(title="角色管理",optDesc = "查询角色信息") |
||||
@PostMapping(value="/queryRoles") |
||||
public HttpResult queryRoles(@RequestParam(value = "roleName", required = false) String roleName, |
||||
@RequestParam(value = "page", required = false, defaultValue = "1") int page, |
||||
@RequestParam(value = "limit", required = false, defaultValue = "1000") int limit) { |
||||
try{ |
||||
List<SysRole> list=sysRoleService.queryRoles(roleName,page,limit); |
||||
int count=sysRoleService.getCount(roleName,page,limit); |
||||
return HttpResult.ok(count,list); |
||||
}catch (Exception e){ |
||||
return HttpResult.error(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,177 @@
|
||||
package com.mh.user.controller; |
||||
|
||||
import com.mh.common.http.HttpResult; |
||||
import com.mh.common.page.PageRequest; |
||||
import com.mh.user.annotation.SysLogger; |
||||
import com.mh.user.constants.SysConstants; |
||||
import com.mh.user.mapper.SysUserRoleMapper; |
||||
import com.mh.user.model.SysRole; |
||||
import com.mh.user.model.SysUser; |
||||
import com.mh.user.model.SysUserRole; |
||||
import com.mh.user.service.SysRoleService; |
||||
import com.mh.user.service.SysUserService; |
||||
import com.mh.user.utils.PasswordUtils; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.security.access.prepost.PreAuthorize; |
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
import org.springframework.web.bind.annotation.PostMapping; |
||||
import org.springframework.web.bind.annotation.RequestBody; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
import java.text.SimpleDateFormat; |
||||
import java.util.Date; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 用户控制器 |
||||
* @author ljf |
||||
* @date 2020-04-25 |
||||
*/ |
||||
@RestController |
||||
@RequestMapping("user") |
||||
public class SysUserController { |
||||
|
||||
@Autowired |
||||
private SysUserService sysUserService; |
||||
|
||||
@Autowired |
||||
private SysRoleService sysRoleService; |
||||
|
||||
@Autowired |
||||
private SysUserRoleMapper sysUserRoleMapper; |
||||
|
||||
@SysLogger(title="用户管理",optDesc = "保存或者编辑用户信息") |
||||
@PostMapping(value="/save") |
||||
public HttpResult save(@RequestBody SysUser record) { |
||||
SysUser user = sysUserService.findById(record.getId()); |
||||
if(user != null) { |
||||
if(SysConstants.ADMIN.equalsIgnoreCase(user.getUserName())) { |
||||
return HttpResult.error("超级管理员不允许修改!"); |
||||
} |
||||
} |
||||
if(record.getPassword() != null) { |
||||
|
||||
String salt = PasswordUtils.getSalt();//生成盐值
|
||||
|
||||
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
||||
Date date=new Date(); |
||||
String curDate=sdf1.format(date); |
||||
|
||||
if(user == null) { |
||||
// 新增用户
|
||||
if(sysUserService.findByName(record.getUserName()) != null) { |
||||
return HttpResult.error("用户名已存在!"); |
||||
} |
||||
String password = PasswordUtils.encode(record.getPassword(), salt); |
||||
Byte Status=1; |
||||
Byte delFlag=1; |
||||
record.setSalt(salt); |
||||
record.setPassword(password); |
||||
record.setStatus(Status); |
||||
record.setDelFlag(delFlag); |
||||
try{ |
||||
record.setCreateTime(sdf1.parse(curDate)); //创建日期
|
||||
}catch (Exception e){ |
||||
|
||||
} |
||||
|
||||
} else { |
||||
SysUser user1=sysUserService.findByName(record.getUserName()); |
||||
if(user1!=null && user1.getId()!=record.getId()){ |
||||
return HttpResult.error("修改的用户名不能与存在的用户名相同!"); |
||||
} |
||||
// 修改用户, 且修改了密码
|
||||
if(!record.getPassword().equals(user.getPassword())) { //有问题
|
||||
String password = PasswordUtils.encode(record.getPassword(), salt); |
||||
record.setSalt(salt); |
||||
record.setPassword(password); |
||||
} |
||||
} |
||||
} |
||||
return HttpResult.ok(sysUserService.save(record)); |
||||
} |
||||
|
||||
@SysLogger(title="用户管理",optDesc = "删除用户信息") |
||||
@PostMapping(value="/delete") |
||||
public HttpResult delete(@RequestBody List<SysUser> records) { |
||||
for(SysUser record:records) { |
||||
SysUser sysUser = sysUserService.findById(record.getId()); |
||||
if(sysUser != null && SysConstants.ADMIN.equalsIgnoreCase(sysUser.getUserName())) { |
||||
return HttpResult.error("超级管理员不允许删除!"); |
||||
} |
||||
} |
||||
return HttpResult.ok(sysUserService.delete(records)); |
||||
} |
||||
|
||||
@PostMapping(value="/deleteById") |
||||
public HttpResult deleteById(@RequestBody SysUser record) { |
||||
SysUser sysUser = sysUserService.findById(record.getId()); |
||||
if(sysUser != null && SysConstants.ADMIN.equalsIgnoreCase(sysUser.getUserName())) { |
||||
return HttpResult.error("超级管理员不允许删除!"); |
||||
}else{ |
||||
return HttpResult.ok(sysUserService.delete(record)); |
||||
} |
||||
} |
||||
|
||||
// @PreAuthorize("hasAuthority('sys:user:view')")
|
||||
@GetMapping(value="/findByName") |
||||
public HttpResult findByUserName(@RequestParam String name) { |
||||
|
||||
return HttpResult.ok(sysUserService.findByName(name)); |
||||
} |
||||
|
||||
@PreAuthorize("hasAuthority('sys:user:view')") |
||||
@GetMapping(value="/findPermissions") |
||||
public HttpResult findPermissions(@RequestParam String name) { |
||||
return HttpResult.ok(sysUserService.findPermissions(name)); |
||||
} |
||||
|
||||
@PreAuthorize("hasAuthority('sys:user:view')") |
||||
@GetMapping(value="/findUserRoles") |
||||
public HttpResult findUserRoles(@RequestParam Long userId) { |
||||
return HttpResult.ok(sysUserService.findUserRoles(userId)); |
||||
} |
||||
|
||||
@PreAuthorize("hasAuthority('sys:user:view')") |
||||
@PostMapping(value="/findPage") |
||||
public HttpResult findPage(@RequestBody PageRequest pageRequest) { |
||||
return HttpResult.ok(sysUserService.findPage(pageRequest)); |
||||
} |
||||
|
||||
@SysLogger(title="用户管理",optDesc = "查询用户信息") |
||||
@PostMapping(value="/queryUsers") |
||||
public HttpResult queryUsers(@RequestParam(value = "userName", required = false) String userName, |
||||
@RequestParam(value = "page", required = false, defaultValue = "1") int page, |
||||
@RequestParam(value = "limit", required = false, defaultValue = "1000") int limit){ |
||||
try{ |
||||
List<SysUser> list=sysUserService.queryUsers(userName,page,limit); |
||||
int count=sysUserService.getCount(userName,page,limit); |
||||
return HttpResult.ok(count,list); |
||||
}catch (Exception e){ |
||||
return HttpResult.error(); |
||||
} |
||||
|
||||
} |
||||
|
||||
@PostMapping(value="/password") |
||||
public HttpResult updatePassword(@RequestParam String oldPassword, |
||||
@RequestParam String newPassword, |
||||
@RequestParam String id) { |
||||
try{ |
||||
SysUser user = sysUserService.findById(Long.valueOf(id)); |
||||
|
||||
if (!PasswordUtils.matches(user.getSalt(), oldPassword, user.getPassword())) { |
||||
return HttpResult.error("原密码不正确"); |
||||
}else{ |
||||
String salt = PasswordUtils.getSalt(); |
||||
String password = PasswordUtils.encode(newPassword, salt); |
||||
sysUserService.updatePassword(password,salt,id); |
||||
return HttpResult.ok(); |
||||
} |
||||
}catch (Exception e){ |
||||
return HttpResult.error(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,91 @@
|
||||
package com.mh.user.controller; |
||||
|
||||
import com.mh.user.constants.Constant; |
||||
import com.mh.user.dynamic.datasource.DataSourceContextHolder; |
||||
import com.mh.user.dynamic.datasource.DataSourceObject; |
||||
import com.mh.user.entity.DBEntity; |
||||
import com.mh.user.manage.QuartzManager; |
||||
import com.mh.user.mapper.NowDataMapper; |
||||
import com.mh.user.service.NowDataService; |
||||
import com.mh.user.service.SysUserService; |
||||
import com.mh.user.utils.AESUtil; |
||||
import com.mh.user.utils.AnalysisReceiveOrder485; |
||||
import com.mh.user.utils.GetReadOrder485; |
||||
import com.mh.user.utils.TimedTask2; |
||||
import org.quartz.SchedulerException; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.security.authentication.AuthenticationManager; |
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
import org.springframework.web.bind.annotation.PostMapping; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
import javax.annotation.Resource; |
||||
|
||||
@RestController |
||||
public class TestController { |
||||
|
||||
@Autowired |
||||
private SysUserService sysUserService; |
||||
|
||||
@Autowired |
||||
NowDataService nowDataService; |
||||
|
||||
@Resource |
||||
QuartzManager quartzManager; |
||||
|
||||
@RequestMapping("/hello") |
||||
public String HelloWord() throws SchedulerException, InterruptedException { |
||||
// 停止JobTest
|
||||
quartzManager.pauseAllJob(); |
||||
Constant.FLAG = true; |
||||
Thread.sleep(2000); |
||||
// 开始JobTest
|
||||
// quartzManager.resumeAllJob();
|
||||
Constant.FLAG = false; |
||||
return "user hello word."; |
||||
} |
||||
|
||||
@RequestMapping("/startHello") |
||||
public String startHelloWord() throws SchedulerException, InterruptedException { |
||||
// 停止JobTest
|
||||
// quartzManager.pauseAllJob();
|
||||
// Constant.FLAG = true;
|
||||
// Thread.sleep(2000);
|
||||
// 开始JobTest
|
||||
// quartzManager.resumeAllJob();
|
||||
// Thread.sleep(2000);
|
||||
// Constant.FLAG = false;
|
||||
return "user hello word."; |
||||
} |
||||
|
||||
@GetMapping("/testQuery") |
||||
public void testQuery(){ |
||||
// try{
|
||||
// DBEntity dbEntity = sysUserService.queryDBInfo("admin");
|
||||
// dbEntity.setDB_Pwd(AESUtil.AESdecrypt(dbEntity.getDB_Pwd()));
|
||||
// DataSourceObject dataSourceObject = new DataSourceObject();
|
||||
// String SourceName = "sqlServer-"+dbEntity.getDB_Names();
|
||||
// dataSourceObject.SwitchSQLServerDataSource(dbEntity,SourceName);
|
||||
// DataSourceContextHolder.setDBType(SourceName);
|
||||
// }catch (Exception e){
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
|
||||
AnalysisReceiveOrder485 analysis=new AnalysisReceiveOrder485(); |
||||
GetReadOrder485 getReadOrder485=new GetReadOrder485(); |
||||
// analysis.analysisWtMeterOrder485("5103040003141D953F","","","48");
|
||||
//analysis.analysisPumpOrder485("05030200004984","0BBD","美的2","80");
|
||||
// analysis.analysisMeterOrder485("6824095005000068810643C36B7A67335E16","","","63");
|
||||
// analysis.analysisRelayOrder485("12031000000001000000000000000000000000665F","0010","远向","34");
|
||||
// analysis.analysisMulTempOrder4852("010310013601290192018F0180F800F800F800AC21","","","1");
|
||||
// analysis.analysisPressureOrder485("150304400F1ABE00E1","","","22");
|
||||
// analysis.analysisStateOrder485("6874100000000068810358F3395C16","","","41");
|
||||
// analysis.analysisTempOrder485("020304013000010900","","","23");
|
||||
nowDataService.saveNowHistoryData("3","热泵","运行","runState","62"); |
||||
// nowDataService.updateRunState("70","2","离线");
|
||||
|
||||
|
||||
} |
||||
|
||||
} |
@ -0,0 +1,67 @@
|
||||
package com.mh.user.controller; |
||||
|
||||
import com.mh.common.http.HttpResult; |
||||
import com.mh.user.entity.UseForecastEntity; |
||||
import com.mh.user.service.BuildingService; |
||||
import com.mh.user.service.DeviceFloorService; |
||||
import com.mh.user.service.UseForecastService; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.web.bind.annotation.*; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
@RestController |
||||
@RequestMapping("forecast") |
||||
public class UseForecastController { |
||||
|
||||
@Autowired |
||||
UseForecastService useForecastService; |
||||
|
||||
@Autowired |
||||
BuildingService buildingService; |
||||
|
||||
@Autowired |
||||
DeviceFloorService deviceFloorService; |
||||
|
||||
@PostMapping("/save") |
||||
public HttpResult saveUseForecast(@RequestBody UseForecastEntity useForecastEntity){ |
||||
try{ |
||||
useForecastService.saveUseForecast(useForecastEntity); |
||||
return HttpResult.ok(); |
||||
}catch (Exception e){ |
||||
return HttpResult.error("保存出错!"); |
||||
} |
||||
} |
||||
|
||||
@PostMapping("/update") |
||||
public HttpResult updateUseForecast(@RequestBody UseForecastEntity useForecastEntity){ |
||||
try{ |
||||
useForecastService.updateUseForecast(useForecastEntity); |
||||
return HttpResult.ok(); |
||||
}catch (Exception e){ |
||||
e.printStackTrace(); |
||||
return HttpResult.error("修改出错!"); |
||||
} |
||||
|
||||
} |
||||
|
||||
@PostMapping("/query") |
||||
public HttpResult queryUseForecast(@RequestParam(value = "buildingId",required = true) String buildingId, |
||||
@RequestParam(value = "deviceName",required = true) String deviceName, |
||||
@RequestParam(value = "curDate",required =true) String curDate, |
||||
@RequestParam(value = "page",required = true) int page, |
||||
@RequestParam(value = "limit",required = true) int limit){ |
||||
try{ |
||||
List<UseForecastEntity> list=new ArrayList<UseForecastEntity>(); |
||||
// String buildingId=buildingService.selectBuildingId(buildingName);
|
||||
String deviceId=deviceFloorService.selectDeviceId(deviceName,"水箱",buildingId); |
||||
list=useForecastService.queryUseForecast(buildingId,deviceId,curDate,page,limit); |
||||
int count=useForecastService.getCount(buildingId,deviceId,curDate,page,limit); |
||||
return HttpResult.ok(count,list); |
||||
}catch (Exception e){ |
||||
e.printStackTrace(); |
||||
return HttpResult.error("查询出错!"); |
||||
} |
||||
|
||||
} |
||||
} |
@ -0,0 +1,33 @@
|
||||
package com.mh.user.dto; |
||||
|
||||
import lombok.Getter; |
||||
import lombok.Setter; |
||||
|
||||
/** |
||||
* @author ljf |
||||
* @title : |
||||
* @description : 设备信息状态 |
||||
* @updateTime 2020-05-29 |
||||
* @throws : |
||||
*/ |
||||
@Setter |
||||
@Getter |
||||
public class DeviceMessageDTO { |
||||
|
||||
private String label; |
||||
private int spanLength; |
||||
private boolean openState; |
||||
private String deviceId; |
||||
private int grade; // 0:A区 1:B区
|
||||
|
||||
@Override |
||||
public String toString() { |
||||
return "DeviceMessageDTO{" + |
||||
"label='" + label + '\'' + |
||||
", spanLength=" + spanLength + |
||||
", openState=" + openState + |
||||
", deviceId='" + deviceId + '\'' + |
||||
", grade=" + grade + |
||||
'}'; |
||||
} |
||||
} |
@ -0,0 +1,35 @@
|
||||
package com.mh.user.dto; |
||||
|
||||
import lombok.Getter; |
||||
import lombok.Setter; |
||||
|
||||
/** |
||||
* @author ljf |
||||
* @title : |
||||
* @description : 设备数据显示框 |
||||
* @updateTime 2020-05-29 |
||||
* @throws : |
||||
*/ |
||||
@Setter |
||||
@Getter |
||||
public class DisplayBoxDataDTO { |
||||
|
||||
private String title; |
||||
private String secContent1; |
||||
private String secContent2; |
||||
private String firstDivClass; |
||||
private String deviceId; |
||||
private int grade; |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return "DisplayBoxDataDTO{" + |
||||
"title='" + title + '\'' + |
||||
", secContent1='" + secContent1 + '\'' + |
||||
", secContent2='" + secContent2 + '\'' + |
||||
", firstDivClass='" + firstDivClass + '\'' + |
||||
", deviceId='" + deviceId + '\'' + |
||||
", grade=" + grade + |
||||
'}'; |
||||
} |
||||
} |
@ -0,0 +1,21 @@
|
||||
package com.mh.user.dto; |
||||
|
||||
import lombok.Getter; |
||||
import lombok.Setter; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author ljf |
||||
* @title : |
||||
* @description : |
||||
* @updateTime 2020-05-25 |
||||
* @throws : |
||||
*/ |
||||
@Setter |
||||
@Getter |
||||
public class TableInfoDTO<T> { |
||||
|
||||
private List<T> tableInfo; |
||||
|
||||
} |
@ -0,0 +1,77 @@
|
||||
package com.mh.user.dynamic.config; |
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource; |
||||
import com.mh.user.dynamic.datasource.DynamicDataSource; |
||||
import org.apache.ibatis.session.SqlSessionFactory; |
||||
import org.mybatis.spring.SqlSessionFactoryBean; |
||||
import org.mybatis.spring.SqlSessionTemplate; |
||||
import org.mybatis.spring.annotation.MapperScan; |
||||
import org.springframework.beans.factory.annotation.Qualifier; |
||||
import org.springframework.beans.factory.annotation.Value; |
||||
import org.springframework.context.annotation.Bean; |
||||
import org.springframework.context.annotation.Configuration; |
||||
import org.springframework.core.io.support.PathMatchingResourcePatternResolver; |
||||
|
||||
import javax.sql.DataSource; |
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @author chison |
||||
* @date 2020-04-02 09:39 |
||||
* @Description |
||||
*/ |
||||
@Configuration |
||||
@MapperScan("com.mh.*.mapper") // 扫描DAO
|
||||
public class DataSourceConfig { |
||||
|
||||
@Value("${spring.datasource.druid.url}") |
||||
private String defaultDBUrl; |
||||
@Value("${spring.datasource.druid.username}") |
||||
private String defaultDBUser; |
||||
@Value("${spring.datasource.druid.password}") |
||||
private String defaultDBPassword; |
||||
@Value("${spring.datasource.druid.driver-class-name}") |
||||
private String defaultDBDreiverName; |
||||
|
||||
|
||||
@Bean |
||||
public DynamicDataSource dynamicDataSource() { |
||||
DynamicDataSource dynamicDataSource = DynamicDataSource.getInstance(); |
||||
|
||||
DruidDataSource defaultDataSource = new DruidDataSource(); |
||||
defaultDataSource.setUrl(defaultDBUrl); |
||||
defaultDataSource.setUsername(defaultDBUser); |
||||
defaultDataSource.setPassword(defaultDBPassword); |
||||
defaultDataSource.setDriverClassName(defaultDBDreiverName); |
||||
|
||||
Map<Object,Object> map = new HashMap<>(); |
||||
map.put("default", defaultDataSource); |
||||
dynamicDataSource.setTargetDataSources(map); |
||||
dynamicDataSource.setDefaultTargetDataSource(defaultDataSource); |
||||
|
||||
return dynamicDataSource; |
||||
} |
||||
|
||||
@Bean |
||||
public SqlSessionFactory sqlSessionFactory( |
||||
@Qualifier("dynamicDataSource") DataSource dynamicDataSource) |
||||
throws Exception { |
||||
SqlSessionFactoryBean bean = new SqlSessionFactoryBean(); |
||||
bean.setDataSource(dynamicDataSource); |
||||
bean.setTypeAliasesPackage("com.mh.*.model"); // 扫描Model
|
||||
|
||||
bean.setMapperLocations(new PathMatchingResourcePatternResolver() |
||||
.getResources("classpath*:**/sqlmapper/*.xml")); |
||||
return bean.getObject(); |
||||
|
||||
} |
||||
|
||||
@Bean(name = "sqlSessionTemplate") |
||||
public SqlSessionTemplate sqlSessionTemplate( |
||||
@Qualifier("sqlSessionFactory") SqlSessionFactory sqlSessionFactory) |
||||
throws Exception { |
||||
return new SqlSessionTemplate(sqlSessionFactory); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,28 @@
|
||||
package com.mh.user.dynamic.config; |
||||
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; |
||||
import org.springframework.context.annotation.Bean; |
||||
import tk.mybatis.spring.mapper.MapperScannerConfigurer; |
||||
|
||||
import java.util.Properties; |
||||
|
||||
/** |
||||
* @author chison |
||||
* @date 2020-04-02 09:40 |
||||
* @Description |
||||
*/ |
||||
@EnableAutoConfiguration |
||||
public class MyBatisMapperScannerConfig { |
||||
@Bean |
||||
public MapperScannerConfigurer mapperScannerConfigurer() { |
||||
MapperScannerConfigurer mapperScannerConfigurer = new MapperScannerConfigurer(); |
||||
mapperScannerConfigurer.setSqlSessionFactoryBeanName("sqlSessionFactory"); |
||||
mapperScannerConfigurer.setBasePackage("com.mh.user.mapper"); |
||||
Properties properties = new Properties(); |
||||
properties.setProperty("notEmpty", "false"); |
||||
properties.setProperty("IDENTITY", "MYSQL"); |
||||
mapperScannerConfigurer.setProperties(properties); |
||||
return mapperScannerConfigurer; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,23 @@
|
||||
package com.mh.user.dynamic.datasource; |
||||
|
||||
/** |
||||
* @author chison |
||||
* @date 2020-04-02 09:40 |
||||
* @Description 通过ThreadLocal维护一个全局唯一的map来实现数据源的动态切换 |
||||
*/ |
||||
public class DataSourceContextHolder { |
||||
|
||||
private static final ThreadLocal<String> contextHolder = new ThreadLocal<String>(); |
||||
|
||||
public static synchronized void setDBType(String dbType){ |
||||
contextHolder.set(dbType); |
||||
} |
||||
|
||||
public static String getDBType(){ |
||||
return contextHolder.get(); |
||||
} |
||||
|
||||
public static void clearDBType(){ |
||||
contextHolder.remove(); |
||||
} |
||||
} |
@ -0,0 +1,71 @@
|
||||
package com.mh.user.dynamic.datasource; |
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource; |
||||
import com.mh.user.entity.DBEntity; |
||||
|
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @author chison |
||||
* @date 2020-04-02 09:40 |
||||
* @Description |
||||
*/ |
||||
public class DataSourceObject { |
||||
|
||||
private Long MaxWait=6000L; |
||||
private Integer maxActive=10; |
||||
private Long timeBetweenEvictionRunsMillis=6000L; |
||||
|
||||
/** |
||||
* 切换sqlserver数据库,并动态赋值 |
||||
* @param dbInfo |
||||
* @param SourceName |
||||
*/ |
||||
public void SwitchMySQLDataSource(DBEntity dbInfo, String SourceName) { |
||||
System.out.println("mysql进入数据源切换"); |
||||
System.out.println("MaxWait:"+MaxWait); |
||||
DruidDataSource dynamicDataSource = new DruidDataSource(); |
||||
dynamicDataSource.setDriverClassName("com.mysql.cj.jdbc.Driver"); |
||||
dynamicDataSource.setUrl("jdbc:mysql://"+dbInfo.getDB_IP()+":"+dbInfo.getDB_Port()+"/"+dbInfo.getDB_Names()+"?serverTimezone=UTC&useUnicode=true&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&autoReconnect=true"); |
||||
dynamicDataSource.setUsername(dbInfo.getDB_UserName()); |
||||
dynamicDataSource.setPassword(dbInfo.getDB_Pwd()); |
||||
dynamicDataSource.setMaxWait(MaxWait); |
||||
dynamicDataSource.setMaxActive(maxActive); |
||||
dynamicDataSource.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis); |
||||
|
||||
DynamicDataSource dataSource = DynamicDataSource.getInstance(); |
||||
Map<Object, Object> map=new HashMap<Object, Object>(); |
||||
map.put(SourceName, dynamicDataSource); |
||||
dataSource.setTargetDataSources(map); |
||||
System.out.println(dynamicDataSource.getUrl()); |
||||
System.out.println(SourceName); |
||||
} |
||||
/** |
||||
* 第二个sqlserver数据库 |
||||
* @param dbInfo |
||||
* @param SourceName |
||||
*/ |
||||
public void SwitchSQLServerDataSource(DBEntity dbInfo,String SourceName) { |
||||
System.out.println("进入数据源切换"); |
||||
System.out.println("MaxWait:"+MaxWait); |
||||
DruidDataSource dynamicDataSource = new DruidDataSource(); |
||||
dynamicDataSource.setDriverClassName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); |
||||
dynamicDataSource.setUrl("jdbc:sqlserver://"+dbInfo.getDB_IP()+":"+dbInfo.getDB_Port()+";Databasename="+dbInfo.getDB_Names()); |
||||
dynamicDataSource.setUsername(dbInfo.getDB_UserName()); |
||||
dynamicDataSource.setPassword(dbInfo.getDB_Pwd()); |
||||
System.out.println(dbInfo.getDB_UserName()); |
||||
System.out.println(dbInfo.getDB_Pwd()); |
||||
dynamicDataSource.setMaxWait(MaxWait); |
||||
dynamicDataSource.setMaxActive(maxActive); |
||||
dynamicDataSource.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis); |
||||
|
||||
DynamicDataSource dataSource = DynamicDataSource.getInstance(); |
||||
Map<Object, Object> map=new HashMap<Object, Object>(); |
||||
map.put(SourceName, dynamicDataSource); |
||||
dataSource.setTargetDataSources(map); |
||||
|
||||
System.out.println(dynamicDataSource.getUrl()); |
||||
System.out.println(SourceName); |
||||
} |
||||
} |
@ -0,0 +1,44 @@
|
||||
package com.mh.user.dynamic.datasource; |
||||
|
||||
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource; |
||||
|
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @author chison |
||||
* @date 2020-04-02 09:41 |
||||
* @Description |
||||
*/ |
||||
public class DynamicDataSource extends AbstractRoutingDataSource { |
||||
|
||||
private static DynamicDataSource instance; |
||||
private static byte[] lock=new byte[0]; |
||||
private static Map<Object,Object> dataSourceMap=new HashMap<Object, Object>(); |
||||
|
||||
@Override |
||||
public void setTargetDataSources(Map<Object, Object> targetDataSources) { |
||||
super.setTargetDataSources(targetDataSources); |
||||
dataSourceMap.putAll(targetDataSources); |
||||
super.afterPropertiesSet();// 必须添加该句,否则新添加数据源无法识别到
|
||||
} |
||||
|
||||
public Map<Object, Object> getDataSourceMap() { |
||||
return dataSourceMap; |
||||
} |
||||
|
||||
public static synchronized DynamicDataSource getInstance(){ |
||||
if(instance==null){ |
||||
synchronized (lock){ |
||||
if(instance==null){ |
||||
instance=new DynamicDataSource(); |
||||
} |
||||
} |
||||
} |
||||
return instance; |
||||
} |
||||
//必须实现其方法
|
||||
protected Object determineCurrentLookupKey() { |
||||
return DataSourceContextHolder.getDBType(); |
||||
} |
||||
} |
@ -0,0 +1,34 @@
|
||||
package com.mh.user.entity; |
||||
|
||||
import lombok.Getter; |
||||
import lombok.Setter; |
||||
|
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @author ljf |
||||
* @title : |
||||
* @description : 定时任务请求类 |
||||
* @updateTime 2020-04-03 |
||||
* @throws : |
||||
*/ |
||||
@Setter |
||||
@Getter |
||||
public class AddCronJobReq { |
||||
|
||||
private String jobName; |
||||
|
||||
private String jobGroupName; |
||||
|
||||
private String triggerName; |
||||
|
||||
private String triggerGroupName; |
||||
|
||||
private String jobClass; |
||||
|
||||
private String date; |
||||
|
||||
private Map<String, String> params = new HashMap<>(); |
||||
|
||||
} |
@ -0,0 +1,27 @@
|
||||
package com.mh.user.entity; |
||||
|
||||
import lombok.Getter; |
||||
import lombok.Setter; |
||||
|
||||
import java.util.Date; |
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @author ljf |
||||
* @title : |
||||
* @description : 新增Simple定时任务请求实体类 |
||||
* @updateTime 2020-04-03 |
||||
* @throws : |
||||
*/ |
||||
@Setter |
||||
@Getter |
||||
public class AddSimpleJobReq { |
||||
|
||||
private String jobClass; |
||||
|
||||
private Date date; |
||||
|
||||
private Map<String, String> params = new HashMap<>(); |
||||
|
||||
} |
@ -0,0 +1,21 @@
|
||||
package com.mh.user.entity; |
||||
|
||||
|
||||
import lombok.Data; |
||||
|
||||
import java.util.Date; |
||||
|
||||
@Data |
||||
public class AlarmInfoEntity { |
||||
|
||||
private Long id; |
||||
private String alarmId; |
||||
private String buildingId; |
||||
private String buildingName; |
||||
private Date alarmTime; |
||||
private String deviceAddr; |
||||
private String deviceType; |
||||
private String alarmType; |
||||
private String dealState; |
||||
|
||||
} |
@ -0,0 +1,20 @@
|
||||
package com.mh.user.entity; |
||||
|
||||
import lombok.Data; |
||||
|
||||
@Data |
||||
public class AlarmInfoSumEntity { |
||||
|
||||
private long id; |
||||
private String curDate; |
||||
private String buildingId; |
||||
private int deviceNum; |
||||
private int faultNum; |
||||
private String waterLevel; |
||||
private int waterLevelNum; |
||||
private String waterTemp; |
||||
private int waterTempNum; |
||||
private String electWater; |
||||
private int electWaterNum; |
||||
|
||||
} |
@ -0,0 +1,22 @@
|
||||
package com.mh.user.entity; |
||||
|
||||
import lombok.Data; |
||||
|
||||
@Data |
||||
public class AlarmValueSetEntity { |
||||
|
||||
private long id; |
||||
private String buildingId; |
||||
private String buildingName; |
||||
private String startTime; |
||||
private String endTime; |
||||
private String lowValue; |
||||
private String startTime2; |
||||
private String endTime2; |
||||
private String lowValue2; |
||||
private String startTime3; |
||||
private String endTime3; |
||||
private String lowValue3; |
||||
private String itemType; |
||||
private String type; |
||||
} |
@ -0,0 +1,46 @@
|
||||
package com.mh.user.entity; |
||||
|
||||
import lombok.Data; |
||||
|
||||
@Data |
||||
public class AnalysisMonthEntity { |
||||
|
||||
private Long id; |
||||
private String curDate; |
||||
private String itemType; |
||||
private String day01; |
||||
private String day02; |
||||
private String day03; |
||||
private String day04; |
||||
private String day05; |
||||
private String day06; |
||||
private String day07; |
||||
private String day08; |
||||
private String day09; |
||||
private String day10; |
||||
private String day11; |
||||
private String day12; |
||||
private String day13; |
||||
private String day14; |
||||
private String day15; |
||||
private String day16; |
||||
private String day17; |
||||
private String day18; |
||||
private String day19; |
||||
private String day20; |
||||
private String day21; |
||||
private String day22; |
||||
private String day23; |
||||
private String day24; |
||||
private String day25; |
||||
private String day26; |
||||
private String day27; |
||||
private String day28; |
||||
private String day29; |
||||
private String day30; |
||||
private String day31; |
||||
private String day32; |
||||
private String totalValue; |
||||
private String buildingId; |
||||
private String buildingName; |
||||
} |
@ -0,0 +1,27 @@
|
||||
package com.mh.user.entity; |
||||
|
||||
import lombok.Data; |
||||
|
||||
@Data |
||||
public class AnalysisYearEntity { |
||||
|
||||
private Long id; |
||||
private String curDate; |
||||
private String itemType; |
||||
private String month01; |
||||
private String month02; |
||||
private String month03; |
||||
private String month04; |
||||
private String month05; |
||||
private String month06; |
||||
private String month07; |
||||
private String month08; |
||||
private String month09; |
||||
private String month10; |
||||
private String month11; |
||||
private String month12; |
||||
private String totalValue; |
||||
private String buildingId; |
||||
private String buildingName; |
||||
|
||||
} |
@ -0,0 +1,32 @@
|
||||
package com.mh.user.entity; |
||||
|
||||
public class AreaEntity { |
||||
|
||||
private String areaId; |
||||
|
||||
private String areaName; |
||||
|
||||
public String getAreaId() { |
||||
return areaId; |
||||
} |
||||
|
||||
public void setAreaId(String areaId) { |
||||
this.areaId = areaId; |
||||
} |
||||
|
||||
public String getAreaName() { |
||||
return areaName; |
||||
} |
||||
|
||||
public void setAreaName(String areaName) { |
||||
this.areaName = areaName; |
||||
} |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return "AreaEntity{" + |
||||
"areaId='" + areaId + '\'' + |
||||
", areaName='" + areaName + '\'' + |
||||
'}'; |
||||
} |
||||
} |
@ -0,0 +1,41 @@
|
||||
package com.mh.user.entity; |
||||
|
||||
|
||||
import lombok.Getter; |
||||
import lombok.Setter; |
||||
import org.springframework.format.annotation.DateTimeFormat; |
||||
|
||||
import java.io.Serializable; |
||||
import java.util.Date; |
||||
|
||||
/** |
||||
* @author ljf |
||||
* @title : |
||||
* @description : 基础实体类 |
||||
* @updateTime 2020-05-14 |
||||
* @throws : |
||||
*/ |
||||
@Setter |
||||
@Getter |
||||
public class BaseEntity implements Serializable { |
||||
|
||||
static final long serialVersionUID = 42L; |
||||
|
||||
private Long id; |
||||
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||
private Date createTime; |
||||
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||
private Date updateTime; |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return "BaseEntity{" + |
||||
"id=" + id + |
||||
", createTime=" + createTime + |
||||
", updateTime=" + updateTime + |
||||
'}'; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,20 @@
|
||||
package com.mh.user.entity; |
||||
|
||||
import lombok.Data; |
||||
|
||||
@Data |
||||
public class BuildingEntity { |
||||
|
||||
private Long id; |
||||
private String buildingId; |
||||
private String buildingName; |
||||
private int levelsCount; |
||||
private int beginLevel; |
||||
private int houseCount; |
||||
private int bedCount; |
||||
private int checkInCount; |
||||
private String areaId; |
||||
private String remarks; |
||||
private Double tankHeight; |
||||
|
||||
} |
@ -0,0 +1,61 @@
|
||||
package com.mh.user.entity; |
||||
|
||||
import lombok.Getter; |
||||
import lombok.Setter; |
||||
import org.springframework.format.annotation.DateTimeFormat; |
||||
|
||||
import java.util.Date; |
||||
|
||||
/** |
||||
* @author ljf |
||||
* @title : |
||||
* @description :冷水机组设备实体类 |
||||
* @updateTime 2020-05-20 |
||||
* @throws : |
||||
*/ |
||||
@Setter |
||||
@Getter |
||||
public class ChillersEntity extends BaseEntity { |
||||
|
||||
private String deviceCode; // 设备代码
|
||||
private String deviceNum; // 设备码
|
||||
private String collectionNum; // 冷水机组采集地址
|
||||
private String registerAddress; // 寄存器地址
|
||||
private String registerName; // 寄存器名称
|
||||
private String funCode; // 功能码
|
||||
private int digit; // 保留位数
|
||||
private String otherName; // 别名
|
||||
private int grade; // 标志 1:冷水机组设备 2:ddc设备采集参数 3:控制指令类型 4:故障类型
|
||||
private String lastValue; // 最新采集数据
|
||||
// @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private String lastTime; // 最新采集时间
|
||||
// @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
// private Date localTime; // 本地采集时间
|
||||
private String dataCom; // 采集端口号
|
||||
private String ddcAddr; // DDC地址
|
||||
|
||||
// update by ljf on 2020-05-26 添加网络管理器的IP和采集的端口号
|
||||
private String IP; // IP地址
|
||||
private int port; // 端口号
|
||||
|
||||
@Override |
||||
public String toString() { |
||||
return "ChillersEntity{" + |
||||
"deviceCode='" + deviceCode + '\'' + |
||||
", deviceNum='" + deviceNum + '\'' + |
||||
", collectionNum='" + collectionNum + '\'' + |
||||
", registerAddress='" + registerAddress + '\'' + |
||||
", registerName='" + registerName + '\'' + |
||||
", funCode='" + funCode + '\'' + |
||||
", digit=" + digit + |
||||
", otherName='" + otherName + '\'' + |
||||
", grade=" + grade + |
||||
", lastValue='" + lastValue + '\'' + |
||||
", lastTime=" + lastTime + |
||||
", dataCom='" + dataCom + '\'' + |
||||
", ddcAddr='" + ddcAddr + '\'' + |
||||
", IP='" + IP + '\'' + |
||||
", port=" + port + |
||||
'}'; |
||||
} |
||||
} |
@ -0,0 +1,24 @@
|
||||
package com.mh.user.entity; |
||||
|
||||
import lombok.Data; |
||||
|
||||
@Data |
||||
public class ControlSetEntity { |
||||
|
||||
private String buildingId; |
||||
private String levelSet; |
||||
private String useStartTime1; |
||||
private String useCloseTime1; |
||||
private String useStartTime2; |
||||
private String useCloseTime2; |
||||
private String useStartTime3; |
||||
private String useCloseTime3; |
||||
private String useStartTime4; |
||||
private String useCloseTime4; |
||||
private String useStartTime5; |
||||
private String useCloseTime5; |
||||
private String useStartTime6; |
||||
private String useCloseTime6; |
||||
private String backWaterTemp; |
||||
private String upWaterTemp; |
||||
} |
@ -0,0 +1,91 @@
|
||||
package com.mh.user.entity; |
||||
|
||||
/** |
||||
* @author chison |
||||
* @date 2020-09-02 13:37 |
||||
* @Description |
||||
*/ |
||||
public class DBEntity { |
||||
|
||||
private String DB_Names; |
||||
private String DB_UserName; |
||||
private String DB_Pwd; |
||||
private String DB_Port; |
||||
private Integer DB_Type; //0:sqlserver,1:oracle,2:mysql
|
||||
private String DB_IP; |
||||
private String Project_Name; |
||||
private String Project_No; |
||||
private Integer DB_IsStatus; |
||||
|
||||
public String getDB_Names() { |
||||
return DB_Names; |
||||
} |
||||
|
||||
public void setDB_Names(String DB_Names) { |
||||
this.DB_Names = DB_Names; |
||||
} |
||||
|
||||
public String getDB_UserName() { |
||||
return DB_UserName; |
||||
} |
||||
|
||||
public void setDB_UserName(String DB_UserName) { |
||||
this.DB_UserName = DB_UserName; |
||||
} |
||||
|
||||
public String getDB_Pwd() { |
||||
return DB_Pwd; |
||||
} |
||||
|
||||
public void setDB_Pwd(String DB_Pwd) { |
||||
this.DB_Pwd = DB_Pwd; |
||||
} |
||||
|
||||
public String getDB_Port() { |
||||
return DB_Port; |
||||
} |
||||
|
||||
public void setDB_Port(String DB_Port) { |
||||
this.DB_Port = DB_Port; |
||||
} |
||||
|
||||
public Integer getDB_Type() { |
||||
return DB_Type; |
||||
} |
||||
|
||||
public void setDB_Type(Integer DB_Type) { |
||||
this.DB_Type = DB_Type; |
||||
} |
||||
|
||||
public String getDB_IP() { |
||||
return DB_IP; |
||||
} |
||||
|
||||
public void setDB_IP(String DB_IP) { |
||||
this.DB_IP = DB_IP; |
||||
} |
||||
|
||||
public String getProject_Name() { |
||||
return Project_Name; |
||||
} |
||||
|
||||
public void setProject_Name(String project_Name) { |
||||
Project_Name = project_Name; |
||||
} |
||||
|
||||
public String getProject_No() { |
||||
return Project_No; |
||||
} |
||||
|
||||
public void setProject_No(String project_No) { |
||||
Project_No = project_No; |
||||
} |
||||
|
||||
public Integer getDB_IsStatus() { |
||||
return DB_IsStatus; |
||||
} |
||||
|
||||
public void setDB_IsStatus(Integer DB_IsStatus) { |
||||
this.DB_IsStatus = DB_IsStatus; |
||||
} |
||||
} |
@ -0,0 +1,21 @@
|
||||
package com.mh.user.entity; |
||||
|
||||
import lombok.Data; |
||||
|
||||
import java.util.Date; |
||||
|
||||
@Data |
||||
public class DataResultEntity { |
||||
|
||||
private Long id; |
||||
private String deviceAddr; |
||||
private String deviceType; |
||||
private String buildingId; |
||||
private String buildingName; |
||||
private double lastValue; |
||||
private Date lastDate; |
||||
private double curValue; |
||||
private Date curDate; |
||||
private double ratio; |
||||
private double calcValue; |
||||
} |
@ -0,0 +1,25 @@
|
||||
package com.mh.user.entity; |
||||
|
||||
import lombok.Getter; |
||||
import lombok.Setter; |
||||
|
||||
/** |
||||
* @author ljf |
||||
* @title : |
||||
* @description : 定时任务删除类 |
||||
* @updateTime 2020-04-03 |
||||
* @throws : |
||||
*/ |
||||
@Setter |
||||
@Getter |
||||
public class DeleteJobReq { |
||||
|
||||
private String jobName; |
||||
|
||||
private String jobGroupName; |
||||
|
||||
private String triggerName; |
||||
|
||||
private String triggerGroupName; |
||||
|
||||
} |
@ -0,0 +1,23 @@
|
||||
package com.mh.user.entity; |
||||
|
||||
import lombok.Data; |
||||
import java.util.Date; |
||||
|
||||
@Data |
||||
public class DeviceCodeParamEntity { |
||||
|
||||
private Long id; |
||||
private String deviceAddr; |
||||
private String deviceName; |
||||
private String deviceType; |
||||
private String dataCom; |
||||
private int baudrate; |
||||
private String parity; |
||||
private String brand; |
||||
private String funCode; |
||||
private String registerAddr; |
||||
private String dataValue; //传入值
|
||||
private Date createTime; |
||||
private String buildingId; |
||||
|
||||
} |
@ -0,0 +1,22 @@
|
||||
package com.mh.user.entity; |
||||
|
||||
import lombok.Data; |
||||
|
||||
import java.util.Date; |
||||
|
||||
@Data |
||||
public class DeviceFloorEntity { |
||||
|
||||
private Long id; |
||||
private String deviceName; |
||||
private String deviceType; |
||||
private String brand; |
||||
private String model; |
||||
private String specs; |
||||
private String buildingId; |
||||
private String buildingName; |
||||
private String installer; |
||||
private Date installDate; |
||||
private boolean use; |
||||
|
||||
} |
@ -0,0 +1,18 @@
|
||||
package com.mh.user.entity; |
||||
|
||||
import lombok.Data; |
||||
|
||||
import java.util.Date; |
||||
|
||||
@Data |
||||
public class DeviceFloorTempEntity { |
||||
|
||||
private String deviceName; |
||||
private String deviceType; |
||||
private String buildingId; |
||||
private Date installDate; |
||||
private String model; |
||||
private String specs; |
||||
private String remarks; |
||||
private String rowId; //行号
|
||||
} |
@ -0,0 +1,34 @@
|
||||
package com.mh.user.entity; |
||||
|
||||
import lombok.Data; |
||||
import java.util.Date; |
||||
|
||||
@Data |
||||
public class DeviceInstallEntity { |
||||
|
||||
private Long id; |
||||
private String deviceAddr; |
||||
private String deviceName; |
||||
private String deviceType; |
||||
private String dataCom; |
||||
private int baudRate; |
||||
private String parity; |
||||
private double ratio; |
||||
private double initValue; |
||||
private double lastValue; |
||||
private Date lastDate; |
||||
private String supDeviceAddr; |
||||
private String isOnline; |
||||
private String grade; |
||||
private boolean use; |
||||
private boolean fault; |
||||
private String faultState; |
||||
private String brand; |
||||
private String model; |
||||
private String buildingId; |
||||
private String buildingName; |
||||
private String installer; |
||||
private Date installDate; |
||||
private String remarks; |
||||
private double dayValue; |
||||
} |
@ -0,0 +1,113 @@
|
||||
package com.mh.user.entity; |
||||
|
||||
import java.util.Date; |
||||
|
||||
public class DeviceInstallTempEntity { |
||||
|
||||
private String deviceAddr; |
||||
private String deviceName; |
||||
private String deviceType; |
||||
private int baudRate; |
||||
private String dataCom; |
||||
private double ratio; |
||||
private String buildingId; |
||||
private Date installDate; |
||||
private String remarks; |
||||
private String rowId; //行号
|
||||
|
||||
public String getDeviceAddr() { |
||||
return deviceAddr; |
||||
} |
||||
|
||||
public void setDeviceAddr(String deviceAddr) { |
||||
this.deviceAddr = deviceAddr; |
||||
} |
||||
|
||||
public String getDeviceName() { |
||||
return deviceName; |
||||
} |
||||
|
||||
public void setDeviceName(String deviceName) { |
||||
this.deviceName = deviceName; |
||||
} |
||||
|
||||
public String getDeviceType() { |
||||
return deviceType; |
||||
} |
||||
|
||||
public void setDeviceType(String deviceType) { |
||||
this.deviceType = deviceType; |
||||
} |
||||
|
||||
public int getBaudRate() { |
||||
return baudRate; |
||||
} |
||||
|
||||
public void setBaudRate(int baudRate) { |
||||
this.baudRate = baudRate; |
||||
} |
||||
|
||||
public String getDataCom() { |
||||
return dataCom; |
||||
} |
||||
|
||||
public void setDataCom(String dataCom) { |
||||
this.dataCom = dataCom; |
||||
} |
||||
|
||||
public double getRatio() { |
||||
return ratio; |
||||
} |
||||
|
||||
public void setRatio(double ratio) { |
||||
this.ratio = ratio; |
||||
} |
||||
|
||||
public String getBuildingId() { |
||||
return buildingId; |
||||
} |
||||
|
||||
public void setBuildingId(String buildingId) { |
||||
this.buildingId = buildingId; |
||||
} |
||||
|
||||
public Date getInstallDate() { |
||||
return installDate; |
||||
} |
||||
|
||||
public void setInstallDate(Date installDate) { |
||||
this.installDate = installDate; |
||||
} |
||||
|
||||
public String getRemarks() { |
||||
return remarks; |
||||
} |
||||
|
||||
public void setRemarks(String remarks) { |
||||
this.remarks = remarks; |
||||
} |
||||
|
||||
public String getRowId() { |
||||
return rowId; |
||||
} |
||||
|
||||
public void setRowId(String rowId) { |
||||
this.rowId = rowId; |
||||
} |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return "DeviceInstallTempEntity{" + |
||||
"deviceAddr='" + deviceAddr + '\'' + |
||||
", deviceName='" + deviceName + '\'' + |
||||
", deviceType='" + deviceType + '\'' + |
||||
", baudRate=" + baudRate + |
||||
", dataCom='" + dataCom + '\'' + |
||||
", ratio=" + ratio + |
||||
", buildingId='" + buildingId + '\'' + |
||||
", installDate=" + installDate + |
||||
", remarks='" + remarks + '\'' + |
||||
", rowId='" + rowId + '\'' + |
||||
'}'; |
||||
} |
||||
} |
@ -0,0 +1,66 @@
|
||||
package com.mh.user.entity; |
||||
|
||||
import lombok.Getter; |
||||
import lombok.Setter; |
||||
import org.springframework.format.annotation.DateTimeFormat; |
||||
|
||||
import java.util.Date; |
||||
|
||||
/** |
||||
* @author ljf |
||||
* @title : |
||||
* @description :设备管理实体类 |
||||
* @updateTime 2020-05-14 |
||||
* @throws : |
||||
*/ |
||||
@Setter |
||||
@Getter |
||||
public class DeviceManageEntity extends BaseEntity { |
||||
|
||||
private String deviceCode; |
||||
private String deviceNum; |
||||
private String collectionNum; |
||||
private String dataCom; |
||||
private String initialValue; |
||||
private String deviceRate; |
||||
private String price; |
||||
private int paramId; |
||||
private String paramName; |
||||
private String lastValue; |
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||
private Date lastDate; |
||||
private String lastDates; |
||||
private String communicationType; |
||||
private String deviceType; |
||||
private String remark; |
||||
private int grade; |
||||
private String deviceCaliber; |
||||
private String type; |
||||
private String createTimes; |
||||
private String updateTimes; |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return "DeviceManageEntity{" + |
||||
"deviceCode='" + deviceCode + '\'' + |
||||
", deviceNum='" + deviceNum + '\'' + |
||||
", collectionNum='" + collectionNum + '\'' + |
||||
", dataCom='" + dataCom + '\'' + |
||||
", initialValue='" + initialValue + '\'' + |
||||
", deviceRate='" + deviceRate + '\'' + |
||||
", price='" + price + '\'' + |
||||
", paramId=" + paramId + |
||||
", paramName='" + paramName + '\'' + |
||||
", lastValue='" + lastValue + '\'' + |
||||
", lastDate=" + lastDate + |
||||
", communicationType='" + communicationType + '\'' + |
||||
", deviceType='" + deviceType + '\'' + |
||||
", remark='" + remark + '\'' + |
||||
", grade=" + grade + |
||||
", deviceCaliber=" + deviceCaliber + |
||||
", type=" + type + |
||||
", createTime=" + createTimes + |
||||
", updateTime=" + updateTimes + |
||||
'}'; |
||||
} |
||||
} |
@ -0,0 +1,35 @@
|
||||
package com.mh.user.entity; |
||||
|
||||
import lombok.Getter; |
||||
import lombok.Setter; |
||||
|
||||
/** |
||||
* @author ljf |
||||
* @title : |
||||
* @description :设备参数管理实体类 |
||||
* @updateTime 2020-05-14 |
||||
* @throws : |
||||
*/ |
||||
@Setter |
||||
@Getter |
||||
public class DeviceParameterEntity extends BaseEntity { |
||||
|
||||
private int paramId; // 参数编号
|
||||
private String paramName; // 参数名称,及设备类型
|
||||
private int paramBaudrate; // 采集波特率
|
||||
private String checks; // 校验位
|
||||
private int grade; // 波特率
|
||||
private String type; //操作类型
|
||||
|
||||
@Override |
||||
public String toString() { |
||||
return "DeviceParameterEntity{" + |
||||
"paramId=" + paramId + |
||||
", paramName='" + paramName + '\'' + |
||||
", paramBaudrate=" + paramBaudrate + |
||||
", checks='" + checks + '\'' + |
||||
", grade=" + grade + |
||||
", type=" + type + |
||||
'}'; |
||||
} |
||||
} |
@ -0,0 +1,26 @@
|
||||
package com.mh.user.entity; |
||||
|
||||
import lombok.Data; |
||||
|
||||
import java.util.Date; |
||||
|
||||
@Data |
||||
public class DeviceStateEntity { |
||||
|
||||
private Date curDate; |
||||
private int deviceNum; |
||||
private int electNum; |
||||
private int waterNum; |
||||
private int pumpNum; |
||||
private int PressureNum; |
||||
private int runNum; |
||||
private int lastRunNum; |
||||
private String runP; |
||||
private int onlineNum; |
||||
private int offlineNum; |
||||
private int faultNum; |
||||
private int lastFaultNum; |
||||
private String faultP; |
||||
private int pumpOnline; |
||||
|
||||
} |
@ -0,0 +1,26 @@
|
||||
package com.mh.user.entity; |
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
||||
import com.mh.user.utils.Double2Serializer; |
||||
import lombok.Data; |
||||
|
||||
@Data |
||||
public class EnergyEntity { |
||||
|
||||
private Long id; |
||||
private String curDate; //时间
|
||||
private String buildingId; //楼栋编号
|
||||
private String buildingName; //楼栋名称
|
||||
private double hotWaterValue; //热水产量
|
||||
private double useHotWater; //热水消耗
|
||||
private double electValue; //用电量
|
||||
private double electWater; //单耗
|
||||
private int checkInCount; //楼栋人数
|
||||
@JsonSerialize(using = Double2Serializer.class) |
||||
private double perElect; //平均用电
|
||||
@JsonSerialize(using = Double2Serializer.class) |
||||
private double perWater; //平均用水
|
||||
private String electCurValue; //电表读数
|
||||
private String wtCurValue; //水表读数
|
||||
|
||||
} |
@ -0,0 +1,18 @@
|
||||
package com.mh.user.entity; |
||||
|
||||
import lombok.Data; |
||||
|
||||
@Data |
||||
public class EnergySumEntity { |
||||
private Long id; //序号
|
||||
private String curDate; //日期
|
||||
private String buildingId; //楼栋编号
|
||||
private String fillWater; //补水
|
||||
private String fillWaterP; //补水与昨日比
|
||||
private String waterValue; //用水
|
||||
private String waterP; //用水与昨日比
|
||||
private String electValue; //用电
|
||||
private String electP; //用电与昨日比
|
||||
private String electWater; //单耗
|
||||
private String electWaterP; //单耗与昨日比
|
||||
} |
@ -0,0 +1,33 @@
|
||||
package com.mh.user.entity; |
||||
|
||||
import lombok.Getter; |
||||
import lombok.Setter; |
||||
|
||||
/** |
||||
* @author ljf |
||||
* @title : |
||||
* @description : |
||||
* @updateTime 2020-07-31 |
||||
* @throws : |
||||
*/ |
||||
@Setter |
||||
@Getter |
||||
public class ExceptionEntity { |
||||
|
||||
private Integer page; |
||||
private Integer limit; |
||||
private String beginTime; |
||||
private String endTime; |
||||
private Integer process; |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return "ExceptionEntity{" + |
||||
"page=" + page + |
||||
", limit=" + limit + |
||||
", beginTime='" + beginTime + '\'' + |
||||
", endTime='" + endTime + '\'' + |
||||
", process=" + process + |
||||
'}'; |
||||
} |
||||
} |
@ -0,0 +1,35 @@
|
||||
package com.mh.user.entity; |
||||
|
||||
import lombok.Getter; |
||||
import lombok.Setter; |
||||
|
||||
/** |
||||
* @author ljf |
||||
* @title : |
||||
* @description : |
||||
* @updateTime 2020-07-31 |
||||
* @throws : |
||||
*/ |
||||
@Getter |
||||
@Setter |
||||
public class ExceptionTableData { |
||||
|
||||
private int deviceId; |
||||
private String deviceName; |
||||
private int info; |
||||
private String timeStamp; |
||||
private String remark; |
||||
private int process; // 0(正常),1(处理中),2(异常)
|
||||
|
||||
@Override |
||||
public String toString() { |
||||
return "TableData{" + |
||||
"deviceId=" + deviceId + |
||||
", deviceName='" + deviceName + '\'' + |
||||
", info=" + info + |
||||
", timeStamp='" + timeStamp + '\'' + |
||||
", remark='" + remark + '\'' + |
||||
", process=" + process + |
||||
'}'; |
||||
} |
||||
} |
@ -0,0 +1,29 @@
|
||||
package com.mh.user.entity; |
||||
|
||||
import lombok.Getter; |
||||
import lombok.Setter; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author ljf |
||||
* @title : |
||||
* @description : |
||||
* @updateTime 2020-05-25 |
||||
* @throws : |
||||
*/ |
||||
@Setter |
||||
@Getter |
||||
public class FirstTableEntity extends BaseEntity { |
||||
|
||||
private String type; |
||||
private List<TableInfoEntity> tableInfo; |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return "FirstTableEntity{" + |
||||
"type='" + type + '\'' + |
||||
", tableInfo=" + tableInfo + |
||||
'}'; |
||||
} |
||||
} |
@ -0,0 +1,32 @@
|
||||
package com.mh.user.entity; |
||||
|
||||
import lombok.Data; |
||||
import lombok.Getter; |
||||
import lombok.Setter; |
||||
import org.springframework.format.annotation.DateTimeFormat; |
||||
|
||||
import java.util.Date; |
||||
|
||||
/** |
||||
* @author ljf |
||||
* @title : |
||||
* @description :网关管理实体类 |
||||
* @updateTime 2020-05-21 |
||||
* @throws : |
||||
*/ |
||||
@Data |
||||
public class GatewayManageEntity { |
||||
|
||||
private Long id; //id
|
||||
private String gatewayName; //网关名称
|
||||
private String gatewayIP; //网关IP地址
|
||||
private String gatewayAddress; //网关安装地址
|
||||
private String gatewayPort; //串口号或者端口号
|
||||
private String grade; //标志位(连接状态) 0:不在线;1:在线;2:异常
|
||||
private String internetCard; //物联网卡号
|
||||
private String operator; //0:中国移动 1:中国联通 2:中国电信
|
||||
private String createDate; //安装时间
|
||||
private String connectDate; //最新上线连接时间
|
||||
private String remarks; //备注
|
||||
private String type; //操作类型
|
||||
} |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue