From c1d31e9dc0716e3d870624b53f968c8bb1af0036 Mon Sep 17 00:00:00 2001 From: wangbing Date: Wed, 18 Nov 2020 09:17:57 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E5=9B=BE=E8=A1=A8=E5=BC=80?= =?UTF-8?q?=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../manger/callable/SpringBootCallable.java | 4 +- .../java/action/ajax/wsys/DataAjax.java | 35 ++ .../java/frame/validation/Number.java | 25 + .../frame/validation/NumberValidator.java | 48 ++ .../java/module/wsys/ent/DataCount.java | 29 ++ .../java/module/wsys/ent/DataTotal.java | 61 +++ .../java/module/wsys/mgr/DataManager.java | 29 ++ .../java/module/wsys/mgr/DataManagerImpl.java | 176 +++++++ .../java/module/wsys/mpr/DataMapper.java | 49 ++ .../module/wsys/mpr/SQLite_DataMapper.xml | 31 ++ .../module/wsys/req/DataErrorRequest.java | 46 ++ .../module/wsys/req/DataLoginRequest.java | 46 ++ .../java/module/wsys/req/DataTaskRequest.java | 14 + .../module/wsys/req/DataTotalRequest.java | 14 + .../module/wsys/rsp/DataErrorResponse.java | 7 + .../module/wsys/rsp/DataLoginResponse.java | 7 + .../module/wsys/rsp/DataTaskResponse.java | 25 + .../module/wsys/rsp/DataTotalResponse.java | 17 + .../resources/templates/layout/home.ftl | 2 + .../resources/templates/screen/home.ftl | 464 ++++++++++-------- 20 files changed, 931 insertions(+), 198 deletions(-) create mode 100644 src/main/resources/modules/SpringBoot/java/action/ajax/wsys/DataAjax.java create mode 100644 src/main/resources/modules/SpringBoot/java/frame/validation/Number.java create mode 100644 src/main/resources/modules/SpringBoot/java/frame/validation/NumberValidator.java create mode 100644 src/main/resources/modules/SpringBoot/java/module/wsys/ent/DataCount.java create mode 100644 src/main/resources/modules/SpringBoot/java/module/wsys/ent/DataTotal.java create mode 100644 src/main/resources/modules/SpringBoot/java/module/wsys/mgr/DataManager.java create mode 100644 src/main/resources/modules/SpringBoot/java/module/wsys/mgr/DataManagerImpl.java create mode 100644 src/main/resources/modules/SpringBoot/java/module/wsys/mpr/DataMapper.java create mode 100644 src/main/resources/modules/SpringBoot/java/module/wsys/mpr/SQLite_DataMapper.xml create mode 100644 src/main/resources/modules/SpringBoot/java/module/wsys/req/DataErrorRequest.java create mode 100644 src/main/resources/modules/SpringBoot/java/module/wsys/req/DataLoginRequest.java create mode 100644 src/main/resources/modules/SpringBoot/java/module/wsys/req/DataTaskRequest.java create mode 100644 src/main/resources/modules/SpringBoot/java/module/wsys/req/DataTotalRequest.java create mode 100644 src/main/resources/modules/SpringBoot/java/module/wsys/rsp/DataErrorResponse.java create mode 100644 src/main/resources/modules/SpringBoot/java/module/wsys/rsp/DataLoginResponse.java create mode 100644 src/main/resources/modules/SpringBoot/java/module/wsys/rsp/DataTaskResponse.java create mode 100644 src/main/resources/modules/SpringBoot/java/module/wsys/rsp/DataTotalResponse.java diff --git a/src/main/java/xyz/wbsite/dbtool/javafx/manger/callable/SpringBootCallable.java b/src/main/java/xyz/wbsite/dbtool/javafx/manger/callable/SpringBootCallable.java index a56a513a..32523f41 100644 --- a/src/main/java/xyz/wbsite/dbtool/javafx/manger/callable/SpringBootCallable.java +++ b/src/main/java/xyz/wbsite/dbtool/javafx/manger/callable/SpringBootCallable.java @@ -648,7 +648,7 @@ public class SpringBootCallable implements Callable { File css = Tool.createPath(static_, "css"); File img = Tool.createPath(static_, "img"); File dist = Tool.createPath(static_, "dist"); - File echarts = Tool.createPath(static_, "echarts"); + File echarts = Tool.createPath(dist, "echarts"); Tool.outputResource("SpringBoot/resources/static/favicon.ico", Tool.createFile(static_, "favicon.ico")); //css文件 @@ -666,7 +666,7 @@ public class SpringBootCallable implements Callable { //element-ui Tool.outputResource("SpringBoot/resources/static/dist/echarts/echarts.js", Tool.createFile(echarts, "echarts.js")); - Tool.outputResource("SpringBoot/resources/static/dist/echarts/echarts.min.js", Tool.createFile(echarts, "echarts.min.css")); + Tool.outputResource("SpringBoot/resources/static/dist/echarts/echarts.min.js", Tool.createFile(echarts, "echarts.min.js")); File fonts = Tool.createPath(dist, "fonts"); // Tool.outputResource("SpringBoot/resources/static/dist/fonts/w-e-icon.woff", Tool.createFile(fonts, "w-e-icon.woff")); diff --git a/src/main/resources/modules/SpringBoot/java/action/ajax/wsys/DataAjax.java b/src/main/resources/modules/SpringBoot/java/action/ajax/wsys/DataAjax.java new file mode 100644 index 00000000..623b6793 --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/action/ajax/wsys/DataAjax.java @@ -0,0 +1,35 @@ +package ${domain}.action.ajax.wsys; + +import org.springframework.beans.factory.annotation.Autowired; +import ${domain}.frame.auth.LocalData; +import ${domain}.module.wsys.mgr.DataManager; +import ${domain}.module.wsys.req.DataErrorRequest; +import ${domain}.module.wsys.req.DataLoginRequest; +import ${domain}.module.wsys.req.DataTaskRequest; +import ${domain}.module.wsys.req.DataTotalRequest; +import ${domain}.module.wsys.rsp.DataErrorResponse; +import ${domain}.module.wsys.rsp.DataLoginResponse; +import ${domain}.module.wsys.rsp.DataTaskResponse; +import ${domain}.module.wsys.rsp.DataTotalResponse; + +public class DataAjax { + + @Autowired + private DataManager dataManager; + + public DataTotalResponse total(DataTotalRequest request) { + return dataManager.total(request, LocalData.getToken()); + } + + public DataLoginResponse login(DataLoginRequest request) { + return dataManager.login(request, LocalData.getToken()); + } + + public DataErrorResponse error(DataErrorRequest request) { + return dataManager.error(request, LocalData.getToken()); + } + + public DataTaskResponse task(DataTaskRequest request) { + return dataManager.task(request, LocalData.getToken()); + } +} diff --git a/src/main/resources/modules/SpringBoot/java/frame/validation/Number.java b/src/main/resources/modules/SpringBoot/java/frame/validation/Number.java new file mode 100644 index 00000000..32127b9b --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/frame/validation/Number.java @@ -0,0 +1,25 @@ +package ${domain}.frame.validation; + +import javax.validation.Constraint; +import javax.validation.Payload; +import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target({ElementType.FIELD}) +@Retention(RetentionPolicy.RUNTIME) +@Constraint(validatedBy = NumberValidator.class) +@Inherited +public @interface Number { + String message() default "字段长度不符合"; + + int min() default 0; + + int max() default 2147483647; + + Class[] groups() default {}; + + Class[] payload() default {}; +} diff --git a/src/main/resources/modules/SpringBoot/java/frame/validation/NumberValidator.java b/src/main/resources/modules/SpringBoot/java/frame/validation/NumberValidator.java new file mode 100644 index 00000000..e0e7a89f --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/frame/validation/NumberValidator.java @@ -0,0 +1,48 @@ +package ${domain}.frame.validation; + +import org.hibernate.validator.internal.engine.constraintvalidation.ConstraintValidatorContextImpl; +import ${domain}.frame.utils.StringUtil; + +import javax.validation.ConstraintValidator; +import javax.validation.ConstraintValidatorContext; +import java.util.Locale; + +public class NumberValidator implements ConstraintValidator { + + private int min; + private int max; + private String defaultMessage; + + @Override + public void initialize(Number constraint) { + min = constraint.min(); + max = constraint.max(); + } + + @Override + public boolean isValid(Integer o, ConstraintValidatorContext constraintValidatorContext) { + String fieldName = ""; + if (constraintValidatorContext instanceof ConstraintValidatorContextImpl) { + ConstraintValidatorContextImpl validatorContext = (ConstraintValidatorContextImpl) constraintValidatorContext; + if (validatorContext.getConstraintViolationCreationContexts() != null + && validatorContext.getConstraintViolationCreationContexts().size() > 0 + && validatorContext.getConstraintViolationCreationContexts().get(0).getPath() != null) { + fieldName = validatorContext.getConstraintViolationCreationContexts().get(0).getPath().asString(); + } + } + + if (o < min) { + constraintValidatorContext.disableDefaultConstraintViolation(); + String message = StringUtil.isNotEmpty(defaultMessage) ? defaultMessage : String.format(Locale.CHINESE, "[ %s ] 最小值为%d!", fieldName, min); + constraintValidatorContext.buildConstraintViolationWithTemplate(message).addConstraintViolation(); + return false; + } else if (o > max) { + constraintValidatorContext.disableDefaultConstraintViolation(); + String message = StringUtil.isNotEmpty(defaultMessage) ? defaultMessage : String.format(Locale.CHINESE, "[ %s ] 最大值为%d!", fieldName, max); + constraintValidatorContext.buildConstraintViolationWithTemplate(message).addConstraintViolation(); + return false; + } else { + return true; + } + } +} diff --git a/src/main/resources/modules/SpringBoot/java/module/wsys/ent/DataCount.java b/src/main/resources/modules/SpringBoot/java/module/wsys/ent/DataCount.java new file mode 100644 index 00000000..f9fe24f9 --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/module/wsys/ent/DataCount.java @@ -0,0 +1,29 @@ +package ${domain}.module.wsys.ent; + +/** + * DataCount - 统计 + * + * @author wangbing + * @version 0.0.1 + * @since 2020-11-15 + */ +public class DataCount { + private String date; + private int count; + + public String getDate() { + return date; + } + + public void setDate(String date) { + this.date = date; + } + + public int getCount() { + return count; + } + + public void setCount(int count) { + this.count = count; + } +} diff --git a/src/main/resources/modules/SpringBoot/java/module/wsys/ent/DataTotal.java b/src/main/resources/modules/SpringBoot/java/module/wsys/ent/DataTotal.java new file mode 100644 index 00000000..e592fd4d --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/module/wsys/ent/DataTotal.java @@ -0,0 +1,61 @@ +package ${domain}.module.wsys.ent; + +/** + * DataTotal - 统计 + * + * @author wangbing + * @version 0.0.1 + * @since 2020-11-15 + */ +public class DataTotal { + // 用户总数 + private int userAll; + // 用户在线数 + private int userLine; + // 机构总数 + private int deptAll; + // 故障未处理数 + private int errorUn; + // 故障总数 + private int errorAll; + + public int getUserAll() { + return userAll; + } + + public void setUserAll(int userAll) { + this.userAll = userAll; + } + + public int getUserLine() { + return userLine; + } + + public void setUserLine(int userLine) { + this.userLine = userLine; + } + + public int getDeptAll() { + return deptAll; + } + + public void setDeptAll(int deptAll) { + this.deptAll = deptAll; + } + + public int getErrorUn() { + return errorUn; + } + + public void setErrorUn(int errorUn) { + this.errorUn = errorUn; + } + + public int getErrorAll() { + return errorAll; + } + + public void setErrorAll(int errorAll) { + this.errorAll = errorAll; + } +} diff --git a/src/main/resources/modules/SpringBoot/java/module/wsys/mgr/DataManager.java b/src/main/resources/modules/SpringBoot/java/module/wsys/mgr/DataManager.java new file mode 100644 index 00000000..b7de34f3 --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/module/wsys/mgr/DataManager.java @@ -0,0 +1,29 @@ +package ${domain}.module.wsys.mgr; + +import ${domain}.frame.auth.Token; +import ${domain}.module.wsys.req.DataErrorRequest; +import ${domain}.module.wsys.req.DataLoginRequest; +import ${domain}.module.wsys.req.DataTaskRequest; +import ${domain}.module.wsys.req.DataTotalRequest; +import ${domain}.module.wsys.rsp.DataErrorResponse; +import ${domain}.module.wsys.rsp.DataLoginResponse; +import ${domain}.module.wsys.rsp.DataTaskResponse; +import ${domain}.module.wsys.rsp.DataTotalResponse; + +/** + * 通行证 + * + * @author author + * @version 0.0.1 + * @since 2017-01-01 + */ +public interface DataManager { + + DataTotalResponse total(DataTotalRequest request, Token token); + + DataLoginResponse login(DataLoginRequest request, Token token); + + DataErrorResponse error(DataErrorRequest request, Token token); + + DataTaskResponse task(DataTaskRequest request, Token token); +} diff --git a/src/main/resources/modules/SpringBoot/java/module/wsys/mgr/DataManagerImpl.java b/src/main/resources/modules/SpringBoot/java/module/wsys/mgr/DataManagerImpl.java new file mode 100644 index 00000000..746709bd --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/module/wsys/mgr/DataManagerImpl.java @@ -0,0 +1,176 @@ +package ${domain}.module.wsys.mgr; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import ${domain}.frame.auth.Token; +import ${domain}.frame.base.ErrorType; +import ${domain}.frame.base.SortType; +import ${domain}.frame.utils.ValidationUtil; +import ${domain}.module.wsys.ent.DataCount; +import ${domain}.module.wsys.ent.DataTotal; +import ${domain}.module.wsys.ent.Logtask; +import ${domain}.module.wsys.mpr.DataMapper; +import ${domain}.module.wsys.req.DataErrorRequest; +import ${domain}.module.wsys.req.DataLoginRequest; +import ${domain}.module.wsys.req.DataTaskRequest; +import ${domain}.module.wsys.req.DataTotalRequest; +import ${domain}.module.wsys.req.LogtaskFindRequest; +import ${domain}.module.wsys.rsp.DataErrorResponse; +import ${domain}.module.wsys.rsp.DataLoginResponse; +import ${domain}.module.wsys.rsp.DataTaskResponse; +import ${domain}.module.wsys.rsp.DataTotalResponse; +import ${domain}.module.wsys.rsp.LogtaskFindResponse; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * TOKENS - 通行证 + * + * @author author + * @version 0.0.1 + * @since 2017-01-01 + */ +@Transactional +@Service +public class DataManagerImpl implements DataManager { + + @Autowired + private DataMapper dataMapper; + + @Autowired + private LogtaskManager logtaskManager; + + @Override + public DataTotalResponse total(DataTotalRequest request, Token token) { + DataTotalResponse response = new DataTotalResponse(); + + ValidationUtil.validate(request, response); + if (response.hasError()) { + return response; + } + + DataTotal dataTotal = dataMapper.total(request, token); + response.setDataTotal(dataTotal); + return response; + } + + @Override + public DataLoginResponse login(DataLoginRequest request, Token token) { + DataLoginResponse response = new DataLoginResponse(); + + ValidationUtil.validate(request, response); + if (response.hasError()) { + return response; + } + SimpleDateFormat simpleDateFormat1 = null; + SimpleDateFormat simpleDateFormat2 = new SimpleDateFormat("yyyy-MM-dd"); + try { + simpleDateFormat1 = new SimpleDateFormat(request.getFormat()); + } catch (Exception e) { + response.addError(ErrorType.BUSINESS_ERROR, "日期格式化表达式错误"); + return response; + } + + List> list = new ArrayList<>(); + Calendar instance = Calendar.getInstance(); + instance.setTime(new Date()); + if (request.isToday()) { + Map datas = new HashMap<>(); + datas.put("date1", simpleDateFormat1.format(instance.getTime())); + datas.put("date2", simpleDateFormat2.format(instance.getTime())); + list.add(datas); + } + while (list.size() < request.getDays()) { + instance.add(Calendar.DAY_OF_MONTH, -1); + Map datas = new HashMap<>(); + datas.put("date1", simpleDateFormat1.format(instance.getTime())); + datas.put("date2", simpleDateFormat2.format(instance.getTime())); + list.add(datas); + } + + List result = dataMapper.login(list, token); + response.setResult(result); + return response; + } + + @Override + public DataErrorResponse error(DataErrorRequest request, Token token) { + DataErrorResponse response = new DataErrorResponse(); + + ValidationUtil.validate(request, response); + if (response.hasError()) { + return response; + } + SimpleDateFormat simpleDateFormat1 = null; + SimpleDateFormat simpleDateFormat2 = new SimpleDateFormat("yyyy-MM-dd"); + try { + simpleDateFormat1 = new SimpleDateFormat(request.getFormat()); + } catch (Exception e) { + response.addError(ErrorType.BUSINESS_ERROR, "日期格式化表达式错误"); + return response; + } + + List> list = new ArrayList<>(); + Calendar instance = Calendar.getInstance(); + instance.setTime(new Date()); + if (request.isToday()) { + Map datas = new HashMap<>(); + datas.put("date1", simpleDateFormat1.format(instance.getTime())); + datas.put("date2", simpleDateFormat2.format(instance.getTime())); + list.add(datas); + } + while (list.size() < request.getDays()) { + instance.add(Calendar.DAY_OF_MONTH, -1); + Map datas = new HashMap<>(); + datas.put("date1", simpleDateFormat1.format(instance.getTime())); + datas.put("date2", simpleDateFormat2.format(instance.getTime())); + list.add(datas); + } + + List result = dataMapper.error(list, token); + response.setResult(result); + return response; + } + + @Override + public DataTaskResponse task(DataTaskRequest request, Token token) { + DataTaskResponse response = new DataTaskResponse(); + + ValidationUtil.validate(request, response); + if (response.hasError()) { + return response; + } + + LogtaskFindRequest logtaskFindRequest = new LogtaskFindRequest(); + logtaskFindRequest.setSortType(SortType.ASC); + logtaskFindRequest.setSortKey("CREATE_TIME"); + logtaskFindRequest.setPageSize(100); + LogtaskFindResponse logtaskFindResponse = logtaskManager.find(logtaskFindRequest, token); + if (logtaskFindResponse.hasError()) { + response.addErrors(logtaskFindResponse.getErrors()); + return response; + } + List result = new ArrayList<>(); + response.setResult(result); + int countSuccess = 0; + for (Logtask logtask : logtaskFindResponse.getResult()) { + DataCount dataCount = new DataCount(); + dataCount.setDate(""); + dataCount.setCount(logtask.getExecTime()); + if ("1".equals(logtask.getExecState())) { + countSuccess++; + } + result.add(dataCount); + } + response.setCountSuceess(countSuccess); + response.setCountFailed(logtaskFindResponse.getResult().size() - countSuccess); + return response; + } +} diff --git a/src/main/resources/modules/SpringBoot/java/module/wsys/mpr/DataMapper.java b/src/main/resources/modules/SpringBoot/java/module/wsys/mpr/DataMapper.java new file mode 100644 index 00000000..d7ec5e01 --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/module/wsys/mpr/DataMapper.java @@ -0,0 +1,49 @@ +package ${domain}.module.wsys.mpr; + +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; +import ${domain}.frame.auth.Token; +import ${domain}.module.wsys.ent.DataCount; +import ${domain}.module.wsys.ent.DataTotal; +import ${domain}.module.wsys.req.DataTaskRequest; +import ${domain}.module.wsys.req.DataTotalRequest; + +import java.util.List; +import java.util.Map; + +/** + * 数据 + * + * @author wangbing + * @since 2020-06-27 + */ +@Mapper +public interface DataMapper { + + /** + * 获得对象 + * + * @param request 请求 + * @param token 令牌 + * @return 返回对象 + */ + DataTotal total(@Param("request") DataTotalRequest request, @Param("token") Token token); + + /** + * 获得对象 + * + * @param list 主键集合 + * @param token 令牌 + * @return 返回对象 + */ + List login(@Param("list") List> list, @Param("token") Token token); + + /** + * 获得对象 + * + * @param list 主键集合 + * @param token 令牌 + * @return 返回对象 + */ + List error(@Param("list") List> list, @Param("token") Token token); +} diff --git a/src/main/resources/modules/SpringBoot/java/module/wsys/mpr/SQLite_DataMapper.xml b/src/main/resources/modules/SpringBoot/java/module/wsys/mpr/SQLite_DataMapper.xml new file mode 100644 index 00000000..15b2ec31 --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/module/wsys/mpr/SQLite_DataMapper.xml @@ -0,0 +1,31 @@ + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/modules/SpringBoot/java/module/wsys/req/DataErrorRequest.java b/src/main/resources/modules/SpringBoot/java/module/wsys/req/DataErrorRequest.java new file mode 100644 index 00000000..356ef1a3 --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/module/wsys/req/DataErrorRequest.java @@ -0,0 +1,46 @@ +package ${domain}.module.wsys.req; + +import ${domain}.frame.base.BaseFindRequest; +import ${domain}.frame.validation.Number; + +/** + * TokensLogoutRequest - 通行证注销 + * + * @author wangbing + * @version 0.0.1 + * @since 2017-01-01 + */ +public class DataErrorRequest extends BaseFindRequest { + + // 日期格式化;默认yyyy-MM-dd + private String format = "yyyy-MM-dd"; + // 统计天数 + @Number(min = 1, max = 366, message = "统计天数最少为1天,最大为366天") + private int days; + // 是否包含今天 + private boolean today; + + public String getFormat() { + return format; + } + + public void setFormat(String format) { + this.format = format; + } + + public int getDays() { + return days; + } + + public void setDays(int days) { + this.days = days; + } + + public boolean isToday() { + return today; + } + + public void setToday(boolean today) { + this.today = today; + } +} diff --git a/src/main/resources/modules/SpringBoot/java/module/wsys/req/DataLoginRequest.java b/src/main/resources/modules/SpringBoot/java/module/wsys/req/DataLoginRequest.java new file mode 100644 index 00000000..b9d3b131 --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/module/wsys/req/DataLoginRequest.java @@ -0,0 +1,46 @@ +package ${domain}.module.wsys.req; + +import ${domain}.frame.base.BaseFindRequest; +import ${domain}.frame.validation.Number; + +/** + * TokensLogoutRequest - 通行证注销 + * + * @author wangbing + * @version 0.0.1 + * @since 2017-01-01 + */ +public class DataLoginRequest extends BaseFindRequest { + + // 日期格式化;默认yyyy-MM-dd + private String format = "yyyy-MM-dd"; + // 统计天数 + @Number(min = 1, max = 366, message = "统计天数最少为1天,最大为366天") + private int days; + // 是否包含今天 + private boolean today; + + public String getFormat() { + return format; + } + + public void setFormat(String format) { + this.format = format; + } + + public int getDays() { + return days; + } + + public void setDays(int days) { + this.days = days; + } + + public boolean isToday() { + return today; + } + + public void setToday(boolean today) { + this.today = today; + } +} diff --git a/src/main/resources/modules/SpringBoot/java/module/wsys/req/DataTaskRequest.java b/src/main/resources/modules/SpringBoot/java/module/wsys/req/DataTaskRequest.java new file mode 100644 index 00000000..8954f41a --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/module/wsys/req/DataTaskRequest.java @@ -0,0 +1,14 @@ +package ${domain}.module.wsys.req; + +import ${domain}.frame.base.BaseFindRequest; + +/** + * DataTaskRequest - 任务执行数据 + * + * @author wangbing + * @version 0.0.1 + * @since 2017-01-01 + */ +public class DataTaskRequest extends BaseFindRequest { + +} diff --git a/src/main/resources/modules/SpringBoot/java/module/wsys/req/DataTotalRequest.java b/src/main/resources/modules/SpringBoot/java/module/wsys/req/DataTotalRequest.java new file mode 100644 index 00000000..bb907ca6 --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/module/wsys/req/DataTotalRequest.java @@ -0,0 +1,14 @@ +package ${domain}.module.wsys.req; + +import ${domain}.frame.base.BaseRequest; + +/** + * DataTotalRequest - 数据统计 + * + * @author wangbing + * @version 0.0.1 + * @since 2017-01-01 + */ +public class DataTotalRequest extends BaseRequest { + +} diff --git a/src/main/resources/modules/SpringBoot/java/module/wsys/rsp/DataErrorResponse.java b/src/main/resources/modules/SpringBoot/java/module/wsys/rsp/DataErrorResponse.java new file mode 100644 index 00000000..05a2eccc --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/module/wsys/rsp/DataErrorResponse.java @@ -0,0 +1,7 @@ +package ${domain}.module.wsys.rsp; + +import ${domain}.frame.base.BaseFindResponse; +import ${domain}.module.wsys.ent.DataCount; + +public class DataErrorResponse extends BaseFindResponse { +} \ No newline at end of file diff --git a/src/main/resources/modules/SpringBoot/java/module/wsys/rsp/DataLoginResponse.java b/src/main/resources/modules/SpringBoot/java/module/wsys/rsp/DataLoginResponse.java new file mode 100644 index 00000000..eecbf478 --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/module/wsys/rsp/DataLoginResponse.java @@ -0,0 +1,7 @@ +package ${domain}.module.wsys.rsp; + +import ${domain}.frame.base.BaseFindResponse; +import ${domain}.module.wsys.ent.DataCount; + +public class DataLoginResponse extends BaseFindResponse { +} \ No newline at end of file diff --git a/src/main/resources/modules/SpringBoot/java/module/wsys/rsp/DataTaskResponse.java b/src/main/resources/modules/SpringBoot/java/module/wsys/rsp/DataTaskResponse.java new file mode 100644 index 00000000..0857faf8 --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/module/wsys/rsp/DataTaskResponse.java @@ -0,0 +1,25 @@ +package ${domain}.module.wsys.rsp; + +import ${domain}.frame.base.BaseFindResponse; +import ${domain}.module.wsys.ent.DataCount; + +public class DataTaskResponse extends BaseFindResponse { + private int countSuceess; + private int countFailed; + + public int getCountSuceess() { + return countSuceess; + } + + public void setCountSuceess(int countSuceess) { + this.countSuceess = countSuceess; + } + + public int getCountFailed() { + return countFailed; + } + + public void setCountFailed(int countFailed) { + this.countFailed = countFailed; + } +} \ No newline at end of file diff --git a/src/main/resources/modules/SpringBoot/java/module/wsys/rsp/DataTotalResponse.java b/src/main/resources/modules/SpringBoot/java/module/wsys/rsp/DataTotalResponse.java new file mode 100644 index 00000000..bee93b14 --- /dev/null +++ b/src/main/resources/modules/SpringBoot/java/module/wsys/rsp/DataTotalResponse.java @@ -0,0 +1,17 @@ +package ${domain}.module.wsys.rsp; + +import ${domain}.frame.base.BaseResponse; +import ${domain}.module.wsys.ent.DataTotal; + +public class DataTotalResponse extends BaseResponse { + + private DataTotal dataTotal; + + public DataTotal getDataTotal() { + return dataTotal; + } + + public void setDataTotal(DataTotal dataTotal) { + this.dataTotal = dataTotal; + } +} \ No newline at end of file diff --git a/src/main/resources/modules/SpringBoot/resources/templates/layout/home.ftl b/src/main/resources/modules/SpringBoot/resources/templates/layout/home.ftl index 02aadf45..3cdb063d 100644 --- a/src/main/resources/modules/SpringBoot/resources/templates/layout/home.ftl +++ b/src/main/resources/modules/SpringBoot/resources/templates/layout/home.ftl @@ -4,6 +4,8 @@ ${title?default("首页")} + + diff --git a/src/main/resources/modules/SpringBoot/resources/templates/screen/home.ftl b/src/main/resources/modules/SpringBoot/resources/templates/screen/home.ftl index a976f49d..c14be011 100644 --- a/src/main/resources/modules/SpringBoot/resources/templates/screen/home.ftl +++ b/src/main/resources/modules/SpringBoot/resources/templates/screen/home.ftl @@ -10,27 +10,34 @@ d="M515.776 537.472c-216.64 0-216.64-322.56-216.64-322.56S299.136 0 515.776 0s216.64 214.912 216.64 214.912S732.352 537.472 515.776 537.472L515.776 537.472z" p-id="2846" fill="#ffffff"> - 3300 + {{dataTotal.userAll}} 用户人数
+ xmlns="http://www.w3.org/2000/svg" + p-id="2844" width="48" height="48"> - 3300 + {{dataTotal.userLine}} 在线人数
- + - 3300 + {{dataTotal.deptAll}} 部门总数
@@ -40,7 +47,7 @@ d="M230.065 736.146L169.78 748.77 61.495 911.958l20.386 20.275 20.386 20.306 164.414-107.588 12.774-59.85 135.22-134.324-49.265-49.017-135.345 134.386z m589.641-614.423c5.666-5.683 14.983-5.683 20.706 0 5.792 5.687 5.792 14.931 0 20.586l-237.217 235.6 36.999 36.767L877.35 179.078c5.788-5.716 15.04-5.716 20.758 0a14.361 14.361 0 0 1 0 20.585L660.895 435.227l33.22 32.961c0.568-0.529 1.136-0.84 1.703-1.439l25.103-24.9v0.035l201.1-199.676c40.15-39.824 40.15-104.364 0-144.163-40.08-39.824-105.137-39.856-145.227 0L576.957 296.376l-26.364 26.213c-0.505 0.592-0.886 1.215-1.387 1.744l33.165 33.02 237.335-235.63zM478.105 312.652c3.396-18.587 4.275-37.545 2.577-56.293-4.216-46.419-24.162-91.716-59.904-127.226C359.3 68.151 269.07 53.375 193.566 84.673L315.574 205.69c18.307 18.278 18.374 47.896-0.066 66.198l-50.904 50.48c-18.31 18.209-48.193 18.272-66.444 0L78.856 203.911c-27.117 73.163-11.262 158.38 47.889 217.11 32.4 32.11 72.74 51.19 114.704 57.725a211.463 211.463 0 0 0 60.032 0.627C428.396 605.483 741.82 916.672 741.82 916.672c47.56 47.14 124.834 47.14 172.341 0 22.964-22.831 35.679-53.162 35.679-85.43 0-32.366-12.715-62.795-35.741-85.626L478.105 312.652z m398.55 566.723c-24.852 24.652-64.936 24.652-89.85 0.064-24.666-24.554-24.666-64.54 0.063-89.094 24.851-24.486 64.935-24.553 89.727 0 24.855 24.554 24.791 64.54 0.06 89.03z" p-id="4248" fill="#ffffff"> - 3300 + {{dataTotal.errorUn}} 故障未处理
@@ -50,7 +57,7 @@ d="M230.065 736.146L169.78 748.77 61.495 911.958l20.386 20.275 20.386 20.306 164.414-107.588 12.774-59.85 135.22-134.324-49.265-49.017-135.345 134.386z m589.641-614.423c5.666-5.683 14.983-5.683 20.706 0 5.792 5.687 5.792 14.931 0 20.586l-237.217 235.6 36.999 36.767L877.35 179.078c5.788-5.716 15.04-5.716 20.758 0a14.361 14.361 0 0 1 0 20.585L660.895 435.227l33.22 32.961c0.568-0.529 1.136-0.84 1.703-1.439l25.103-24.9v0.035l201.1-199.676c40.15-39.824 40.15-104.364 0-144.163-40.08-39.824-105.137-39.856-145.227 0L576.957 296.376l-26.364 26.213c-0.505 0.592-0.886 1.215-1.387 1.744l33.165 33.02 237.335-235.63zM478.105 312.652c3.396-18.587 4.275-37.545 2.577-56.293-4.216-46.419-24.162-91.716-59.904-127.226C359.3 68.151 269.07 53.375 193.566 84.673L315.574 205.69c18.307 18.278 18.374 47.896-0.066 66.198l-50.904 50.48c-18.31 18.209-48.193 18.272-66.444 0L78.856 203.911c-27.117 73.163-11.262 158.38 47.889 217.11 32.4 32.11 72.74 51.19 114.704 57.725a211.463 211.463 0 0 0 60.032 0.627C428.396 605.483 741.82 916.672 741.82 916.672c47.56 47.14 124.834 47.14 172.341 0 22.964-22.831 35.679-53.162 35.679-85.43 0-32.366-12.715-62.795-35.741-85.626L478.105 312.652z m398.55 566.723c-24.852 24.652-64.936 24.652-89.85 0.064-24.666-24.554-24.666-64.54 0.063-89.094 24.851-24.486 64.935-24.553 89.727 0 24.855 24.554 24.791 64.54 0.06 89.03z" p-id="4248" fill="#ffffff"> - 3300 + {{dataTotal.errorAll}} 故障总数
@@ -130,213 +137,278 @@ var app = new Vue({ mixins: [mixin], el: "#app", - data: {}, + data: { + dataTotal: {} + }, methods: { + initTotalCount: function () { + new Ajax("wsys", "data", "total").post({}, function (response) { + if (response.errors.length > 0) { + nav.e(response.errors[0].message); + } else { + this.dataTotal = response.dataTotal; + } + }.bind(this)) + }, initLoginChart: function () { var loginChart = echarts.init(document.getElementById('LoginChart')); - var option = { - title: { - text: '周登录情况', - subtext: '折线图', - textStyle: { - color: '#515151', - fontSize: 14 - }, - top: '10px', - left: 'center' - }, - tooltip: { - trigger: 'axis', - axisPointer: { - type: 'cross' + new Ajax("wsys", "data", "login").post({ + "days": 7, + "today": false, + "format": "MM月dd日" + }, function (response) { + if (response.errors.length > 0) { + nav.e(response.errors[0].message); + } else { + var date = []; + var data = []; + for (var i = 0; i < response.result.length; i++) { + var obj = response.result[i]; + date.push(obj.date) + data.push(obj.count) } - }, - xAxis: { - type: 'category', - name: '日期', - axisTick: false, - axisLabel: { - interval: 0, - fontSize: 11 - }, - boundaryGap: false, - data: ['11月07日', '11月08日', '11月09日', '11月10日', '11月11日', '11月12日', '11月13日'] - }, - yAxis: { - type: 'value', - name: '登录/次', - axisTick: false, - axisLabel: { - interval: 0 - }, - }, - series: [{ - data: [10, 21, 23, 14, 31, 33, 27], - type: 'line', - itemStyle: { - color: '#515151' - }, - lineStyle: { - color: "#515151", - type: 'dashed', - width: 1 - }, - label: { - show: true, - color: '#2c8aff', - position: 'top' - } - }] - }; - loginChart.setOption(option); + + var option = { + title: { + text: '周登录情况', + subtext: '折线图', + textStyle: { + color: '#515151', + fontSize: 14 + }, + top: '10px', + left: 'center' + }, + tooltip: { + trigger: 'axis', + axisPointer: { + type: 'cross' + } + }, + xAxis: { + type: 'category', + name: '日期', + axisTick: false, + axisLabel: { + interval: 0, + fontSize: 11 + }, + boundaryGap: false, + data: date + }, + yAxis: { + type: 'value', + name: '登录/次', + axisTick: false, + axisLabel: { + interval: 0 + }, + }, + series: [{ + data: data, + type: 'line', + itemStyle: { + color: '#515151' + }, + lineStyle: { + color: "#515151", + type: 'dashed', + width: 1 + }, + label: { + show: true, + color: '#2c8aff', + position: 'top' + } + }] + }; + loginChart.setOption(option); + } + }.bind(this)); }, initErrorChart: function () { var loginChart = echarts.init(document.getElementById('ErrorChart')); - var option = { - title: { - text: '周故障情况', - subtext: '折线图', - textStyle: { - color: '#515151', - fontSize: 14 - }, - top: '10px', - left: 'center' - }, - tooltip: { - trigger: 'axis', - axisPointer: { - type: 'cross' + new Ajax("wsys", "data", "error").post({ + "days": 7, + "today": false, + "format": "MM月dd日" + }, function (response) { + if (response.errors.length > 0) { + nav.e(response.errors[0].message); + } else { + var date = []; + var data = []; + for (var i = 0; i < response.result.length; i++) { + var obj = response.result[i]; + date.push(obj.date) + data.push(obj.count) } - }, - xAxis: { - type: 'category', - name: '日期', - axisTick: false, - axisLabel: { - interval: 0, - fontSize: 11 - }, - boundaryGap: false, - data: ['11月07日', '11月08日', '11月09日', '11月10日', '11月11日', '11月12日', '11月13日'] - }, - yAxis: { - type: 'value', - name: '故障/次', - axisTick: false, - axisLabel: { - interval: 0 - }, - }, - series: [{ - data: [1, 2, 2, 0, 0, 1, 0], - type: 'line', - itemStyle: { - color: '#ff0000' - }, - lineStyle: { - color: "#ff0000", - type: 'solid', - width: 1 - }, - label: { - show: true, - color: '#ff0000', - position: 'top' - } - }] - }; - loginChart.setOption(option); + var option = { + title: { + text: '周故障情况', + subtext: '折线图', + textStyle: { + color: '#515151', + fontSize: 14 + }, + top: '10px', + left: 'center' + }, + tooltip: { + trigger: 'axis', + axisPointer: { + type: 'cross' + } + }, + xAxis: { + type: 'category', + name: '日期', + axisTick: false, + axisLabel: { + interval: 0, + fontSize: 11 + }, + boundaryGap: false, + data: date + }, + yAxis: { + type: 'value', + name: '故障/次', + axisTick: false, + axisLabel: { + interval: 0 + }, + }, + series: [{ + data: data, + type: 'line', + itemStyle: { + color: '#ff0000' + }, + lineStyle: { + color: "#ff0000", + type: 'solid', + width: 1 + }, + label: { + show: true, + color: '#ff0000', + position: 'top' + } + }] + }; + loginChart.setOption(option); + } + }.bind(this)); }, - initTokenTaskChart: function () { + initTaskChart: function () { var chart = echarts.init(document.getElementById('TokenTaskChart')); - var option = { - title: { - text: '任务执行情况', - subtext: '最近100次执行情况间', - textStyle: { - color: '#515151', - fontSize: 14 - }, - top: '10px', - left: 'center' - }, - grid: { - left: '50px', - right: '50px', - top: '30%', - bottom: '5%', - containLabel: true - }, - xAxis: { - type: 'category', - boundaryGap: false, - axisLabel: { - show: false + new Ajax("wsys", "data", "task").post({}, function (response) { + if (response.errors.length > 0) { + nav.e(response.errors[0].message); + } else { + var date = []; + var data = []; + for (var i = 0; i < response.result.length; i++) { + var obj = response.result[i]; + date.push(obj.date) + data.push(obj.count) } - }, - yAxis: { - name: '时间(ms)', - type: 'value', - axisTick: false - }, - tooltip: { - trigger: 'axis', - axisPointer: { - type: 'cross' - } - }, - series: [{ - name: '执行时间(ms)', - type: 'line', - smooth: true, - itemStyle: { - color: '#2c8df2', - }, - data: [30, 52, 17, 20, 10, 11, 10, 13, 10, 10], - }, { - name: '任务', - type: 'pie', - z: 100, - radius: '40%', - center: ['85%', '40%'], - itemStyle: { - opacity: 0.7 - }, - label: { - formatter: '{b}:{d}%' - }, - tooltip: { - trigger: 'item', - formatter: '{b}:{d}%' - }, - data: [{ - value: 95, - name: '成功率', - itemStyle: { - color: '#2c8df2' - }, - label: { - } - }, { - value: 5, - name: '失败率', - itemStyle: { - color: '#ff0000' + var option = { + title: { + text: '登录凭证任务执行情况', + subtext: '最近100次执行情况', + textStyle: { + color: '#515151', + fontSize: 14 + }, + top: '10px', + left: 'center' }, - }] - }] - }; - chart.setOption(option); - }, + grid: { + left: '50px', + right: '50px', + top: '30%', + bottom: '5%', + containLabel: true + }, + xAxis: { + type: 'category', + boundaryGap: false, + axisLabel: { + show: false + } + }, + yAxis: { + name: '时间(ms)', + type: 'value', + axisTick: false + }, + tooltip: { + trigger: 'axis', + axisPointer: { + type: 'cross' + } + }, + series: [{ + name: '执行时间(ms)', + type: 'line', + smooth: true, + itemStyle: { + color: '#2c8df2', + }, + tooltip: { + trigger: 'item', + axisPointer: { + type: 'cross' + } + }, + data: data + }, { + name: '任务', + type: 'pie', + z: 100, + radius: '40%', + center: ['85%', '40%'], + itemStyle: { + opacity: 0.7 + }, + label: { + formatter: '{b}:{d}%' + }, + tooltip: { + trigger: 'item', + formatter: '{b}:{d}%' + }, + data: [{ + value: response.countSuceess, + name: '成功率', + itemStyle: { + color: '#2c8df2' + }, + label: {} + }, { + value: response.countFailed, + name: '失败率', + itemStyle: { + color: '#ff0000' + }, + }] + }] + }; + chart.setOption(option); + } + }.bind(this)) + } }, created: function () { }, mounted: function () { + this.initTotalCount(); this.initLoginChart(); this.initErrorChart(); - this.initTokenTaskChart(); + this.initTaskChart(); }, watch: {} })