From 51f3652b96a09c150554ff8cbca7585e932235cd Mon Sep 17 00:00:00 2001
From: fengxiang <110431245@qq.com>
Date: Wed, 25 Apr 2018 16:43:31 +0800
Subject: [PATCH] 微信页面详情 完善
---
src/main/java/com/moral/config/MvcConfiguration.java | 23 +++++++++++
src/main/java/com/moral/common/convert/StringToDateConverter.java | 28 ++++++++++++++
src/main/webapp/view/alarm/device-data.jsp | 19 +++++++--
3 files changed, 66 insertions(+), 4 deletions(-)
diff --git a/src/main/java/com/moral/common/convert/StringToDateConverter.java b/src/main/java/com/moral/common/convert/StringToDateConverter.java
new file mode 100644
index 0000000..d08bc68
--- /dev/null
+++ b/src/main/java/com/moral/common/convert/StringToDateConverter.java
@@ -0,0 +1,28 @@
+package com.moral.common.convert;
+
+import com.moral.common.util.StringUtils;
+import org.springframework.core.convert.converter.Converter;
+
+import java.util.Date;
+
+/**
+ * ������������������������������
+ * @author byshome
+ * @version $Id: StringToDateConverter.java, v 0.1 2015���9���24��� ������7:19:41 byshome Exp $
+ */
+public class StringToDateConverter implements Converter<String, Date> {
+// private static final String dateFormat = "yyyy-MM-dd HH:mm:ss";
+// private static final String shortDateFormat = "yyyy-MM-dd";
+
+ /**
+ * @see org.springframework.core.convert.converter.Converter#convert(java.lang.Object)
+ */
+ @Override
+ public Date convert(String source) {
+ if(StringUtils.isNullOrEmpty(source)){
+ throw new RuntimeException(String.format("parser %s to Date fail", source));
+ };
+ return new Date(Long.parseLong(source));
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/com/moral/config/MvcConfiguration.java b/src/main/java/com/moral/config/MvcConfiguration.java
index 7d63670..b2462ae 100644
--- a/src/main/java/com/moral/config/MvcConfiguration.java
+++ b/src/main/java/com/moral/config/MvcConfiguration.java
@@ -1,10 +1,17 @@
package com.moral.config;
+import com.moral.common.convert.StringToDateConverter;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
+import org.springframework.core.convert.support.GenericConversionService;
+import org.springframework.web.bind.support.ConfigurableWebBindingInitializer;
import org.springframework.web.servlet.ViewResolver;
import org.springframework.web.servlet.config.annotation.*;
+import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
+
+import javax.annotation.PostConstruct;
@Configuration
@EnableWebMvc
@@ -21,4 +28,20 @@
DefaultServletHandlerConfigurer configurer) {
configurer.enable();
}
+ @Autowired
+ private RequestMappingHandlerAdapter handlerAdapter;
+ /**
+ * ���������������������������������
+ */
+ @PostConstruct
+ public void initEditableValidation() {
+ ConfigurableWebBindingInitializer initializer = (ConfigurableWebBindingInitializer) handlerAdapter
+ .getWebBindingInitializer();
+ if (initializer.getConversionService() != null) {
+ GenericConversionService genericConversionService = (GenericConversionService) initializer
+ .getConversionService();
+ genericConversionService.addConverter(new StringToDateConverter());
+ }
+
+ }
}
diff --git a/src/main/webapp/view/alarm/device-data.jsp b/src/main/webapp/view/alarm/device-data.jsp
index 13983d5..226a762 100644
--- a/src/main/webapp/view/alarm/device-data.jsp
+++ b/src/main/webapp/view/alarm/device-data.jsp
@@ -289,6 +289,16 @@
.attr("dy", "1em")
.text(function(d) { return d.subtitle; });
}
+
+ /**
+ *
+ * @param sortKeys ������������key������
+ * @param data ������������
+ * @param sensors ������������
+ * @param alarmData ������������
+ * @param alarmLevels ������������������
+ * @returns {Array}
+ */
function createBulletData(sortKeys,data,sensors,alarmData,alarmLevels) {
var bullets = [];
for(var index = 0; index<sortKeys.length;index++){
@@ -298,22 +308,22 @@
return value.sensorKey == sensorKey;
});
sensorLevel = alarmLevels[sensorKey];
- if(!sensor||!sensorLevel) break;
+ if(!sensor) break;
bullet.title = !!sensor["description"]?sensor["description"]:sensor.name;
bullet.subtitle = sensor.unit;
bullet.state = !!alarmData[sensorKey]?alarmData[sensorKey]:0;
bullet.measures.push(data[sensorKey]);
bullet.markers.push(data[sensorKey]);
- if(!!sensorLevel.enable){
- var start = 0;
+ var start = 0;
+ if(!!sensorLevel&&!!sensorLevel.enable){
var ranges = sensorLevel.increment;
if(!!sensorLevel.degressEnable){
var inFirst = sensorLevel.increment[0];
var deFirst = sensorLevel.degression[0];
start = (inFirst+deFirst)/2;
ranges = Math.abs(data[sensorKey]-inFirst) > Math.abs(data[sensorKey]-deFirst) ? sensorLevel.degression:sensorLevel.increment;
+ bullet.startPoint = start;
}
- bullet.startPoint = start;
bullet.ranges = ranges;
}else {
var range = data[sensorKey]*10;
@@ -323,6 +333,7 @@
}
bullets.push(bullet);
}
+ console.log(bullets);
return bullets;
}
// init page
--
Gitblit v1.8.0