添加设备时将设备添加到风控平台
diff --git a/src/main/java/com/supwisdom/dlpay/conference/util/HttpConnectionUtil.java b/src/main/java/com/supwisdom/dlpay/conference/util/HttpConnectionUtil.java
new file mode 100644
index 0000000..202b99d
--- /dev/null
+++ b/src/main/java/com/supwisdom/dlpay/conference/util/HttpConnectionUtil.java
@@ -0,0 +1,641 @@
+package com.supwisdom.dlpay.conference.util;
+
+import com.supwisdom.dlpay.framework.util.StringUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.net.ssl.*;
+import java.io.*;
+import java.net.HttpURLConnection;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLEncoder;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * Http工具类
+ * 
+ * @version 1.0
+ * @author LIXD
+ */
+public class HttpConnectionUtil {
+
+	/**
+	 * Logger for this class
+	 */
+	private static final Logger log = LoggerFactory.getLogger( HttpConnectionUtil.class);
+
+	/**
+	 * GET方式连接
+	 */
+	public static final String METHOD_GET = "GET";
+	/**
+	 * POST方式连接
+	 */
+	public static final String METHOD_POST = "POST";
+
+	/**
+	 * 字符集
+	 */
+	private String charset = "UTF-8";
+
+	/**
+	 * 待发送请求参数
+	 */
+	private Map<String, String> webParams = null;
+
+	/**
+	 * 超时时间(毫秒)
+	 */
+	private int timeout = 10000;
+	
+	public String sendByPost(String targetUrl, Map<String, String> webParams) {
+		if (null == targetUrl) {
+			return null;
+		}
+		URL url = null;
+		try {
+			String requestParams = getRequestParam(webParams);
+			if (null != requestParams) {
+				targetUrl += "?" + requestParams;
+			}
+			if (!targetUrl.startsWith("http")) {
+				targetUrl = "http://" + targetUrl;
+			}
+			url = new URL(targetUrl);
+			log.info(">> post {}",targetUrl);
+		} catch (UnsupportedEncodingException e) {
+			e.printStackTrace();
+			return null;
+		} catch (MalformedURLException e) {
+			e.printStackTrace();
+			return null;
+		}
+		if (targetUrl.startsWith("https")) {
+			// https
+			HttpsURLConnection connection = null;
+			try {
+				SSLContext sslcontext = SSLContext.getInstance("TLS");
+				sslcontext.init(null, new TrustManager[] { new TrustAllX509TrustManager(null) }, null);
+				HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() {
+					@Override
+					public boolean verify(String hostname, SSLSession session) {
+						return true;
+					}
+				});
+				connection = (HttpsURLConnection) url.openConnection();
+				connection.setSSLSocketFactory(sslcontext.getSocketFactory());
+				connection.setRequestMethod(METHOD_POST);
+				connection.setReadTimeout(timeout);
+				connection.setConnectTimeout(timeout);
+				connection.setRequestProperty("accept", "*/*");
+				connection.connect();
+				int code = connection.getResponseCode();
+				if (code != 200) {
+					log.warn("https get response code is {}", code);
+					return null;
+				}
+				BufferedReader reader = new BufferedReader(new InputStreamReader(
+						connection.getInputStream()));
+				String line;
+				StringBuffer response = new StringBuffer(128);
+				while ((line = reader.readLine()) != null) {
+					response.append(line);
+				}
+				return response.toString();
+			} catch (Exception e) {
+				e.printStackTrace();
+				return null;
+			} finally {
+				if (null != connection) {
+					connection.disconnect();
+				}
+			}
+		} else {
+			// http
+			HttpURLConnection connection = null;
+			try {
+				connection = (HttpURLConnection) url.openConnection();
+				connection.setRequestMethod(METHOD_POST);
+				connection.setReadTimeout(timeout);
+				connection.setConnectTimeout(timeout);
+				connection.connect();
+				int code = connection.getResponseCode();
+				if (code != 200) {
+					log.warn("http get response code is {}", code);
+					return null;
+				}
+				BufferedReader reader = new BufferedReader(new InputStreamReader(
+						connection.getInputStream()));
+				String line;
+				StringBuffer response = new StringBuffer(128);
+				while ((line = reader.readLine()) != null) {
+					response.append(line);
+				}
+				return response.toString();
+			} catch (IOException e) {
+				e.printStackTrace();
+				return null;
+			} finally {
+				if (null != connection) {
+					connection.disconnect();
+				}
+			}
+		}
+	}
+
+	/**
+	 * 通过post发送http请求(form)
+	 */
+	public String sendByPostForm(String targetUrl, Map<String, String> webParams) {
+		URL url = null;
+		OutputStream stream = null;
+		BufferedReader reader = null;
+		String requestParams = null;
+		try {
+			requestParams = getRequestParam(webParams);
+			if (null == requestParams) {
+				requestParams = "";
+			}
+			if (!targetUrl.startsWith("http")) {
+				targetUrl = "http://" + targetUrl;
+			}
+			url = new URL(targetUrl);
+			log.info("post {}",targetUrl);
+			log.info("post form data {}",requestParams);
+		} catch (Exception e) {
+			e.printStackTrace();
+			return null;
+		}
+		if (targetUrl.startsWith("https")) {
+			// https
+			HttpsURLConnection connection = null;
+			try {
+				SSLContext sslcontext = SSLContext.getInstance("TLS");
+				sslcontext.init(null, new TrustManager[] { new TrustAllX509TrustManager(null) }, null);
+				HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() {
+					@Override
+					public boolean verify(String hostname, SSLSession session) {
+						return true;
+					}
+				});
+				connection = (HttpsURLConnection) url.openConnection();
+				connection.setSSLSocketFactory(sslcontext.getSocketFactory());
+				connection.setRequestMethod(METHOD_POST);
+				connection.setReadTimeout(timeout);
+				connection.setConnectTimeout(timeout);
+				connection.setUseCaches(false);
+				connection.setRequestProperty("accept", "*/*");
+				connection.setRequestProperty("connection", "Keep-Alive");
+				connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
+				connection.setRequestProperty("Content-Length", String.valueOf(requestParams.getBytes(charset).length));
+				// 发送POST请求必须设置如下两行
+				connection.setDoOutput(true);
+				connection.setDoInput(true);
+				stream = new DataOutputStream(connection.getOutputStream());
+				stream.write(requestParams.toString().getBytes(charset));
+				stream.flush();
+				int code = connection.getResponseCode();
+				if (code != 200) {
+					log.warn("https post response code is {}", code);
+					return null;
+				}
+				reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), charset));
+				String line;
+				StringBuffer response = new StringBuffer(128);
+				while ((line = reader.readLine()) != null) {
+					response.append(line);
+				}
+				log.info("resp data : {}",response.toString());
+				return response.toString();
+			} catch (Exception e) {
+				e.printStackTrace();
+				return null;
+			} finally {
+				if (null != connection) {
+					connection.disconnect();
+				}
+				try {
+					if (stream != null) {
+						stream.close();
+					}
+					if (reader != null) {
+						reader.close();
+					}
+				} catch (IOException ex) {
+					ex.printStackTrace();
+				}
+			}
+		} else {
+			HttpURLConnection connection = null;
+			try {
+				connection = (HttpURLConnection) url.openConnection();
+				connection.setRequestMethod(METHOD_POST);
+				connection.setReadTimeout(timeout);
+				connection.setConnectTimeout(timeout);
+				connection.setUseCaches(false);
+				connection.setRequestProperty("accept", "*/*");
+				connection.setRequestProperty("connection", "Keep-Alive");
+				connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
+				connection.setRequestProperty("Content-Length",String.valueOf(requestParams.getBytes(charset).length));
+				// 发送POST请求必须设置如下两行
+				connection.setDoOutput(true);
+				connection.setDoInput(true);
+				stream = new DataOutputStream(connection.getOutputStream());
+				stream.write(requestParams.toString().getBytes(charset));
+				stream.flush();
+				int code = connection.getResponseCode();
+				if (code != 200) {
+					log.warn("http post response code is {}", code);
+					return null;
+				}
+				reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), charset));
+				String line;
+				StringBuffer response = new StringBuffer(128);
+				while ((line = reader.readLine()) != null) {
+					response.append(line);
+				}
+				log.info("resp data : {}",response.toString());
+				return response.toString();
+			} catch (Exception e) {
+				e.printStackTrace();
+				return null;
+			} finally {
+				if (null != connection) {
+					connection.disconnect();
+				}
+				try {
+					if (stream != null) {
+						stream.close();
+					}
+					if (reader != null) {
+						reader.close();
+					}
+				} catch (IOException ex) {
+					ex.printStackTrace();
+				}
+			}
+		}
+	}
+	
+	/**
+	 * 通过post发送Json数据
+	 */
+	public String sendByPostJson(String targetUrl, String jsonString) {
+		URL url = null;
+		OutputStream stream = null;
+		BufferedReader reader = null;
+		try {
+			if (!targetUrl.startsWith("http")) {
+				targetUrl = "http://" + targetUrl;
+			}
+			url = new URL(targetUrl);
+			log.info("post {}",targetUrl);
+			log.info("post json data {}",jsonString);
+		} catch (Exception e) {
+			e.printStackTrace();
+			return null;
+		}
+		if (targetUrl.startsWith("https")) {
+			// https
+			HttpsURLConnection connection = null;
+			try {
+				SSLContext sslcontext = SSLContext.getInstance("TLS");
+				sslcontext.init(null, new TrustManager[] { new TrustAllX509TrustManager(null) }, null);
+				HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() {
+					@Override
+					public boolean verify(String hostname, SSLSession session) {
+						return true;
+					}
+				});
+				connection = (HttpsURLConnection) url.openConnection();
+				connection.setSSLSocketFactory(sslcontext.getSocketFactory());
+				connection.setRequestMethod(METHOD_POST);
+				connection.setReadTimeout(timeout);
+				connection.setConnectTimeout(timeout);
+				connection.setUseCaches(false);
+				connection.setRequestProperty("accept", "*/*");
+				connection.setRequestProperty("connection", "Keep-Alive");
+				connection.setRequestProperty("Content-Type", "application/json");
+				connection.setRequestProperty("Content-Length", String.valueOf(jsonString.getBytes(charset).length));
+				// 发送POST请求必须设置如下两行
+				connection.setDoOutput(true);
+				connection.setDoInput(true);
+				stream = new DataOutputStream(connection.getOutputStream());
+				stream.write(jsonString.getBytes(charset));
+				stream.flush();
+				int code = connection.getResponseCode();
+				if (code != 200) {
+					log.warn("https post response code is {}", code);
+					return null;
+				}
+				reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), charset));
+				String line;
+				StringBuffer response = new StringBuffer(128);
+				while ((line = reader.readLine()) != null) {
+					response.append(line);
+				}
+				return response.toString();
+			} catch (Exception e) {
+				e.printStackTrace();
+				return null;
+			} finally {
+				if (null != connection) {
+					connection.disconnect();
+				}
+				try {
+					if (stream != null) {
+						stream.close();
+					}
+					if (reader != null) {
+						reader.close();
+					}
+				} catch (IOException ex) {
+					ex.printStackTrace();
+				}
+			}
+		} else {
+			HttpURLConnection connection = null;
+			try {
+				connection = (HttpURLConnection) url.openConnection();
+				connection.setRequestMethod(METHOD_POST);
+				connection.setReadTimeout(timeout);
+				connection.setConnectTimeout(timeout);
+				connection.setUseCaches(false);
+				connection.setRequestProperty("accept", "*/*");
+				connection.setRequestProperty("connection", "Keep-Alive");
+				connection.setRequestProperty("Content-Type", "application/json");
+				connection.setRequestProperty("Content-Length", String.valueOf(jsonString.getBytes(charset).length));
+				// 发送POST请求必须设置如下两行
+				connection.setDoOutput(true);
+				connection.setDoInput(true);
+				stream = new DataOutputStream(connection.getOutputStream());
+				stream.write(jsonString.getBytes(charset));
+				stream.flush();
+				int code = connection.getResponseCode();
+				if (code != 200) {
+					log.warn("http post response code is {}", code);
+					return null;
+				}
+				reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), charset));
+				String line;
+				StringBuffer response = new StringBuffer(128);
+				while ((line = reader.readLine()) != null) {
+					response.append(line);
+				}
+				return response.toString();
+			} catch (Exception e) {
+				e.printStackTrace();
+				return null;
+			} finally {
+				if (null != connection) {
+					connection.disconnect();
+				}
+				try {
+					if (stream != null) {
+						stream.close();
+					}
+					if (reader != null) {
+						reader.close();
+					}
+				} catch (IOException ex) {
+					ex.printStackTrace();
+				}
+			}
+		}
+	}
+	
+	/**
+	 * 通过post发送http请求
+	 */
+	public String sendByPost2(String targetUrl, Map<String, String> webParams) {
+		URL url = null;
+		OutputStream stream = null;
+		BufferedReader reader = null;
+		String requestParams = null;
+		try {
+			requestParams = getRequestParam(webParams);
+			if (null == requestParams) {
+				requestParams = "";
+			}
+			if (!targetUrl.startsWith("http")) {
+				targetUrl = "http://" + targetUrl;
+			}
+			url = new URL(targetUrl);
+			log.info("post {}",targetUrl);
+			log.info("post data {}",requestParams);
+		} catch (Exception e) {
+			e.printStackTrace();
+			return null;
+		}
+		if (targetUrl.startsWith("https")) {
+			// https
+			HttpsURLConnection connection = null;
+			try {
+				SSLContext sslcontext = SSLContext.getInstance("TLS");
+				sslcontext.init(null, new TrustManager[] { new TrustAllX509TrustManager(null) }, null);
+				HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() {
+					@Override
+					public boolean verify(String hostname, SSLSession session) {
+						return true;
+					}
+				});
+				connection = (HttpsURLConnection) url.openConnection();
+				connection.setSSLSocketFactory(sslcontext.getSocketFactory());
+				connection.setRequestMethod(METHOD_POST);
+				connection.setReadTimeout(timeout);
+				connection.setConnectTimeout(timeout);
+				connection.setUseCaches(false);
+				connection.setRequestProperty("accept", "*/*");
+				connection.setRequestProperty("connection", "Keep-Alive");
+				//connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
+				connection.setRequestProperty("Content-Length", String.valueOf(requestParams.length()));
+				// 发送POST请求必须设置如下两行
+				connection.setDoOutput(true);
+				connection.setDoInput(true);
+				stream = new DataOutputStream(connection.getOutputStream());
+				stream.write(requestParams.toString().getBytes(charset));
+				stream.flush();
+				int code = connection.getResponseCode();
+				if (code != 200) {
+					log.warn("https post response code is {}", code);
+					return null;
+				}
+				reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), charset));
+				String line;
+				StringBuffer response = new StringBuffer(128);
+				while ((line = reader.readLine()) != null) {
+					response.append(line);
+				}
+				return response.toString();
+			} catch (Exception e) {
+				e.printStackTrace();
+				return null;
+			} finally {
+				if (null != connection) {
+					connection.disconnect();
+				}
+				try {
+					if (stream != null) {
+						stream.close();
+					}
+					if (reader != null) {
+						reader.close();
+					}
+				} catch (IOException ex) {
+					ex.printStackTrace();
+				}
+			}
+		} else {
+			HttpURLConnection connection = null;
+			try {
+				connection = (HttpURLConnection) url.openConnection();
+				connection.setRequestMethod(METHOD_POST);
+				connection.setReadTimeout(timeout);
+				connection.setConnectTimeout(timeout);
+				connection.setUseCaches(false);
+				connection.setRequestProperty("accept", "*/*");
+				connection.setRequestProperty("connection", "Keep-Alive");
+//				connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
+				connection.setRequestProperty("Content-Length", String.valueOf(requestParams.length()));
+				// 发送POST请求必须设置如下两行
+				connection.setDoOutput(true);
+				connection.setDoInput(true);
+				stream = new DataOutputStream(connection.getOutputStream());
+				stream.write(requestParams.toString().getBytes(charset));
+				stream.flush();
+				int code = connection.getResponseCode();
+				if (code != 200) {
+					log.warn("http post response code is {}", code);
+					return null;
+				}
+//				reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), charset));
+//				String line;
+//				StringBuffer response = new StringBuffer(128);
+//				while ((line = reader.readLine()) != null) {
+//					response.append(line);
+//				}
+				InputStream inStream = connection.getInputStream();
+				ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+		        byte[] buffer = new byte[1024];
+		        int len = 0;
+		        while ((len = inStream.read(buffer)) != -1) {
+		            outStream.write(buffer, 0, len);
+		        }
+		        byte[] data = outStream.toByteArray();
+		        outStream.close();
+		        inStream.close();
+				return new String(data,charset);
+			} catch (Exception e) {
+				e.printStackTrace();
+				return null;
+			} finally {
+				if (null != connection) {
+					connection.disconnect();
+				}
+				try {
+					if (stream != null) {
+						stream.close();
+					}
+					if (reader != null) {
+						reader.close();
+					}
+				} catch (IOException ex) {
+					ex.printStackTrace();
+				}
+			}
+		}
+		
+	}
+	
+	/**
+	 * 获取请求参数
+	 * 
+	 * @param
+	 *          webParams<key,value>
+	 * @return key1=value1&key2=value2...
+	 * @throws UnsupportedEncodingException
+	 */
+	public String getRequestParam(Map<String, String> webParams) throws UnsupportedEncodingException {
+		StringBuffer requestParam = new StringBuffer(128);
+		if (null != webParams && webParams.size() > 0) {
+			Iterator<String> its = webParams.keySet().iterator();
+			while (its.hasNext()) {
+				String key = its.next();
+				if(!StringUtil.isEmpty(webParams.get(key))){
+					requestParam.append("&").append(key).append("=")
+							.append(URLEncoder.encode(webParams.get(key), charset));
+				}
+			}
+			return requestParam.substring(1).toString();
+		}
+		return null;
+	}
+
+	/**
+	 * 获取请求参数
+	 *
+	 * @param
+	 *          webParams<key,value>
+	 * @return key1=value1&key2=value2...
+	 * @throws UnsupportedEncodingException
+	 */
+	public String getRequestParamNoEncode(Map<String, String> webParams) throws UnsupportedEncodingException {
+		StringBuffer requestParam = new StringBuffer(128);
+		if (null != webParams && webParams.size() > 0) {
+			Iterator<String> its = webParams.keySet().iterator();
+			while (its.hasNext()) {
+				String key = its.next();
+				requestParam.append("&").append(key).append("=")
+						.append(webParams.get(key));
+			}
+			return requestParam.substring(1).toString();
+		}
+		return null;
+	}
+
+	public Map<String, String> getWebParams() {
+		return webParams;
+	}
+
+	public void setWebParams(Map<String, String> webParams) {
+		this.webParams = webParams;
+	}
+
+	public int getTimeout() {
+		return timeout;
+	}
+
+	public void setTimeout(int timeout) {
+		this.timeout = timeout;
+	}
+
+	public String getCharset() {
+		return charset;
+	}
+
+	public void setCharset(String charset) {
+		this.charset = charset;
+	}
+
+
+
+/*	public static void main(String[] args) {
+		String url="172.28.43.20:8082/collect/device/register";
+
+		Map<String,String> map=new HashMap<>();
+		map.put("areaname","Test");
+		map.put("status","1");
+		map.put("devicename","Test2");
+		map.put("devphyid","12345687");
+		map.put("source","restaurant");
+		Gson gson=new Gson();
+		System.out.println();
+
+		String i=sendByPostJson(url,gson.toJson(map));
+
+
+	}*/
+
+}
\ No newline at end of file
diff --git a/src/main/java/com/supwisdom/dlpay/conference/util/TrustAllX509TrustManager.java b/src/main/java/com/supwisdom/dlpay/conference/util/TrustAllX509TrustManager.java
new file mode 100644
index 0000000..2669ed3
--- /dev/null
+++ b/src/main/java/com/supwisdom/dlpay/conference/util/TrustAllX509TrustManager.java
@@ -0,0 +1,52 @@
+package com.supwisdom.dlpay.conference.util;
+
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.TrustManagerFactory;
+import javax.net.ssl.X509TrustManager;
+import java.security.KeyStore;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+
+/**
+ * 授信类-默认实现
+ * 
+ * @version 1.0
+ * @author LIXD
+ */
+public class TrustAllX509TrustManager implements X509TrustManager {
+
+	private X509TrustManager standardTrustManager = null;
+
+	public TrustAllX509TrustManager(KeyStore keystore) throws NoSuchAlgorithmException,
+	    KeyStoreException {
+		super();
+		TrustManagerFactory factory = TrustManagerFactory.getInstance(TrustManagerFactory
+		    .getDefaultAlgorithm());
+		factory.init(keystore);
+		TrustManager[] trustmanagers = factory.getTrustManagers();
+		if (trustmanagers.length == 0) {
+			throw new NoSuchAlgorithmException("no trust manager found");
+		}
+		this.standardTrustManager = (X509TrustManager) trustmanagers[0];
+	}
+
+	public void checkClientTrusted(X509Certificate[] certificates, String authType)
+	    throws CertificateException {
+		standardTrustManager.checkClientTrusted(certificates, authType);
+	}
+
+	public void checkServerTrusted(X509Certificate[] certificates, String authType)
+	    throws CertificateException {
+		if ((certificates != null) && (certificates.length == 1)) {
+			certificates[0].checkValidity();
+		} else {
+			standardTrustManager.checkServerTrusted(certificates, authType);
+		}
+	}
+
+	public X509Certificate[] getAcceptedIssuers() {
+		return this.standardTrustManager.getAcceptedIssuers();
+	}
+}
diff --git a/src/main/java/com/supwisdom/dlpay/ncmgr/controller/NcMgrController.java b/src/main/java/com/supwisdom/dlpay/ncmgr/controller/NcMgrController.java
index 7b64d26..e1d4c6d 100644
--- a/src/main/java/com/supwisdom/dlpay/ncmgr/controller/NcMgrController.java
+++ b/src/main/java/com/supwisdom/dlpay/ncmgr/controller/NcMgrController.java
@@ -7,6 +7,8 @@
 import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;

 import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;

 import cn.afterturn.easypoi.view.PoiBaseView;

+import com.google.gson.Gson;

+import com.supwisdom.dlpay.conference.util.HttpConnectionUtil;

 import com.supwisdom.dlpay.framework.domain.TOperator;

 import com.supwisdom.dlpay.framework.util.DateUtil;

 import com.supwisdom.dlpay.framework.util.StringUtil;

@@ -23,6 +25,7 @@
 import org.slf4j.Logger;

 import org.slf4j.LoggerFactory;

 import org.springframework.beans.factory.annotation.Autowired;

+import org.springframework.beans.factory.annotation.Value;

 import org.springframework.security.core.annotation.AuthenticationPrincipal;

 import org.springframework.stereotype.Controller;

 import org.springframework.ui.ModelMap;

@@ -50,6 +53,11 @@
     @Autowired

     private ManagerService managerService;

 

+

+    @Value("${auditsys.url}")

+    private String auditsysurl;

+

+

     @RequestMapping("/devindex")

     public String devindex(ModelMap model) {

         return "ncmgr/nc_dev";

@@ -71,17 +79,18 @@
     }

 

     @RequestMapping("/devweek")

-    public String devweek(ModelMap model){

+    public String devweek(ModelMap model) {

         return "ncmgr/nc_devweek";

     }

 

     @RequestMapping("/impdevindex")

-    public String impdevindex(){

+    public String impdevindex() {

         return "ncmgr/nc_impDev";

     }

 

     /**

      * 分页查询设备信息

+     *

      * @param request

      * @param response

      * @param pageNo

@@ -100,16 +109,16 @@
                            @RequestParam(value = "pageSize", required = false, defaultValue = "10") int pageSize,

                            @RequestParam(value = "devname", required = false, defaultValue = "") String devname,

                            @RequestParam(value = "buildingid", required = false, defaultValue = "") String buildingid,

-                           @RequestParam(value = "regionid",required = false,defaultValue = "") String regionid,

+                           @RequestParam(value = "regionid", required = false, defaultValue = "") String regionid,

                            @RequestParam(value = "devtype", required = false, defaultValue = "") String devtype,

-                           @AuthenticationPrincipal TOperator operUser){

+                           @AuthenticationPrincipal TOperator operUser) {

         Map map = new HashMap();

-        try{

+        try {

             String opertype = operUser.getOpertype();

             Pagination page = null;

             List<TRegion> regions = null;

             List<TBuilding> buildings = null;

-            if (!StringUtil.isEmpty(opertype) &&(opertype.equals("S")||opertype.equals("P"))) {

+            if (!StringUtil.isEmpty(opertype) && (opertype.equals("S") || opertype.equals("P"))) {

                 page = ncService.getSystemNcDeviceWithPage(devname, pageNo, pageSize, map, buildingid, regionid, devtype);

                 map.put("PageResult", page);

                 regions = systemService.getAllRegions();

@@ -117,14 +126,14 @@
                 buildings = ncService.getAllBuilding();

                 map.put("buildings", buildings);

 

-            }else if (opertype.equals("H") && !StringUtil.isEmpty(operUser.getRegionid())){

-                page = ncService.getOperatorNcDeviceWithPage(devname, pageNo, pageSize, buildingid, regionid, devtype,operUser.getRegionid());

+            } else if (opertype.equals("H") && !StringUtil.isEmpty(operUser.getRegionid())) {

+                page = ncService.getOperatorNcDeviceWithPage(devname, pageNo, pageSize, buildingid, regionid, devtype, operUser.getRegionid());

                 map.put("PageResult", page);

                 regions = systemService.getRegionListById(operUser.getRegionid());

                 map.put("regions", regions);

                 buildings = systemService.getBuildingByRegionId(operUser.getRegionid());

                 map.put("buildings", buildings);

-            }else if (opertype.equals("L")){

+            } else if (opertype.equals("L")) {

                 map.put("regions", regions);

                 page = ncService.getBuildingOperNcDeviceWithPage(devname, pageNo, pageSize, buildingid, devtype, operUser.getOperid());

                 map.put("PageResult", page);

@@ -135,7 +144,7 @@
             map.put("dicts", dicts);

 

 

-        }catch (Exception e){

+        } catch (Exception e) {

             e.printStackTrace();

             logger.error("查询设备失败:" + e.getMessage());

         }

@@ -144,13 +153,14 @@
 

     /**

      * 获取设备信息

+     *

      * @param deviceid

      * @return

      */

     @RequestMapping("/loadNcDevForUpdate")

     @ResponseBody

     public Map loadNcDevForUpdate(@RequestParam(value = "deviceid") int deviceid,

-                                  @AuthenticationPrincipal TOperator operUser){

+                                  @AuthenticationPrincipal TOperator operUser) {

         Map map = new HashMap();

         try {

             TNcDevice device = ncService.findDevById(deviceid);

@@ -164,21 +174,21 @@
             List<TRegion> regionsfill = null;

             List<TBuilding> buildingsfill = null;

             List<TNcDevice> devices = null;

-            if (!StringUtil.isEmpty(opertype) &&(opertype.equals("S")||opertype.equals("P"))){

+            if (!StringUtil.isEmpty(opertype) && (opertype.equals("S") || opertype.equals("P"))) {

                 regionsfill = systemService.getAllRegions();

                 map.put("regionsfill", regionsfill);

                 buildingsfill = ncService.getAllBuilding();

                 map.put("buildingsfill", buildingsfill);

                 devices = ncService.getSystemDevByType("C");//根据设备类型获取设备

                 map.put("devices", devices);

-            }else if (opertype.equals("H") && !StringUtil.isEmpty(operUser.getRegionid())){

+            } else if (opertype.equals("H") && !StringUtil.isEmpty(operUser.getRegionid())) {

                 regionsfill = systemService.getRegionListById(operUser.getRegionid());

                 map.put("regionsfill", regionsfill);

                 buildingsfill = systemService.getBuildingByRegionId(operUser.getRegionid());

                 map.put("buildingsfill", buildingsfill);

                 devices = ncService.getOperatorDevByType("C", operUser.getRegionid());

                 map.put("devices", devices);

-            }else if (opertype.equals("L") ){

+            } else if (opertype.equals("L")) {

                 //楼栋管理员填充区域为所有区域

                 regionsfill = systemService.getAllRegions();

                 map.put("regionsfill", regionsfill);

@@ -196,24 +206,25 @@
 

     /**

      * 根据区域id填充可选楼栋列表

+     *

      * @param regionid

      * @return

      */

     @ResponseBody

     @RequestMapping("/getRegionBuilding")

-    public Map getRegionBuilding(@RequestParam(value = "regionid") String regionid,@AuthenticationPrincipal TOperator operUser){

+    public Map getRegionBuilding(@RequestParam(value = "regionid") String regionid, @AuthenticationPrincipal TOperator operUser) {

         Map map = new HashMap();

-        try{

+        try {

             List<TBuilding> regionBuildings = null;

-            if (operUser.getOpertype().equals("L")){

+            if (operUser.getOpertype().equals("L")) {

                 regionBuildings = systemService.getBuildingOperBuildingByRegionId(regionid, operUser.getOperid());

-            }else if(operUser.getOpertype().equals("H") && !StringUtil.isEmpty(operUser.getRegionid())){

-                regionBuildings = systemService.getOperatorBuildingByRegionId(regionid,operUser.getRegionid());

+            } else if (operUser.getOpertype().equals("H") && !StringUtil.isEmpty(operUser.getRegionid())) {

+                regionBuildings = systemService.getOperatorBuildingByRegionId(regionid, operUser.getRegionid());

             } else {

                 regionBuildings = systemService.getBuildingByRegionId(regionid);

             }

             map.put("reBuilding", regionBuildings);

-        }catch (Exception e){

+        } catch (Exception e) {

             e.printStackTrace();

         }

         return map;

@@ -222,6 +233,7 @@
 

     /**

      * 添加或修改设备

+     *

      * @param postData

      * @param request

      * @param response

@@ -230,32 +242,32 @@
     @PostMapping("/saveNcDev")

     @ResponseBody

     public Map saveNcDev(@RequestBody NcDevBean postData,

-                         HttpServletRequest request, HttpServletResponse response){

+                         HttpServletRequest request, HttpServletResponse response) {

         Map map = new HashMap();

         try {

             //需要校验名称,读头编号,物理编号是否重复

             //大于0则更新,否则为新加记录

             TNcDevice device;

-            if (postData.getDeviceid()>0) {

+            if (postData.getDeviceid() > 0) {

                 device = ncService.validDevName(postData.getDeviceid(), postData.getDevname());

                 if (device != null && device.getDeviceid() > 0) {

                     map.put("errStr", "设备名称已经存在!");

                     return map;

                 }

-                device = ncService.validDevPhyid(postData.getDeviceid(),postData.getDevphyid());

-                if (device !=null && device.getDeviceid()>0){

+                device = ncService.validDevPhyid(postData.getDeviceid(), postData.getDevphyid());

+                if (device != null && device.getDeviceid() > 0) {

                     map.put("errStr", "设备物理编号已经存在!");

                     return map;

                 }

-                if(postData.getDevtype().equals("R")){

-                    device = ncService.validDevNo(postData.getFdevid(),postData.getDevno(),postData.getDeviceid());

-                    if (device !=null && device.getDeviceid()>0){

+                if (postData.getDevtype().equals("R")) {

+                    device = ncService.validDevNo(postData.getFdevid(), postData.getDevno(), postData.getDeviceid());

+                    if (device != null && device.getDeviceid() > 0) {

                         map.put("errStr", "该控制器下读头号已经存在!");

                         return map;

                     }

                     TNcDevice fDev = ncService.findDevById(postData.getFdevid());

                     TBuilding buidingF = ncService.getBuidingById(fDev.getBuildingid());

-                    if (!postData.getBuildingid().equals(buidingF.getBuildingid())){

+                    if (!postData.getBuildingid().equals(buidingF.getBuildingid())) {

                         map.put("errStr", "该读头和其控制器读头楼栋不一致!");

                         return map;

                     }

@@ -280,39 +292,39 @@
                 ncService.updateDevice(devUpdate);

 

                 map.put("errStr", "");

-            }else {

+            } else {

                 //添加设备

-                device = ncService.validDevName(0,postData.getDevname());

-                if (device !=null && device.getDeviceid()>0){

+                device = ncService.validDevName(0, postData.getDevname());

+                if (device != null && device.getDeviceid() > 0) {

                     map.put("errStr", "设备名称已经存在!");

                     return map;

                 }

-                device = ncService.validDevPhyid(0,postData.getDevphyid());

-                if (device !=null && device.getDeviceid()>0){

+                device = ncService.validDevPhyid(0, postData.getDevphyid());

+                if (device != null && device.getDeviceid() > 0) {

                     map.put("errStr", "设备物理编号已经存在!");

                     return map;

                 }

-                if(postData.getDevtype().equals("R")){

-                    device = ncService.validDevNo(postData.getFdevid(),postData.getDevno(),0);

-                    if (device !=null && device.getDeviceid()>0){

+                if (postData.getDevtype().equals("R")) {

+                    device = ncService.validDevNo(postData.getFdevid(), postData.getDevno(), 0);

+                    if (device != null && device.getDeviceid() > 0) {

                         map.put("errStr", "该控制器下读头号已经存在!");

                         return map;

                     }

                     TNcDevice fDev = ncService.findDevById(postData.getFdevid());

                     TBuilding buidingF = ncService.getBuidingById(fDev.getBuildingid());

-                    if (!postData.getBuildingid().equals(buidingF.getBuildingid())){

+                    if (!postData.getBuildingid().equals(buidingF.getBuildingid())) {

                         map.put("errStr", "该读头和其控制器读头楼栋不一致!");

                         return map;

                     }

                 }

-                if(postData.getDevtype().equals("R")){

+                if (postData.getDevtype().equals("R")) {

                     RedisUtil.del("ncdev_" + postData.getDevphyid() + "_" + postData.getDevno());

-                    RedisUtil.set("ncdev_" + postData.getDevphyid() + "_" + postData.getDevno(),String.valueOf(postData.getDeviceid()));

+                    RedisUtil.set("ncdev_" + postData.getDevphyid() + "_" + postData.getDevno(), String.valueOf(postData.getDeviceid()));

                 }

 

                 int maxId = ncService.getMaxId();

                 TNcDevice devAdd = new TNcDevice();

-                devAdd.setDeviceid(maxId+1);

+                devAdd.setDeviceid(maxId + 1);

                 devAdd.setDevname(postData.getDevname());

                 devAdd.setDevphyid(postData.getDevphyid().toUpperCase());

                 devAdd.setDevtype(postData.getDevtype());

@@ -329,13 +341,29 @@
                 devAdd.setSynctime(DateUtil.getNow());

                 devAdd.setUsetype(postData.getUsetype());

                 TNcDevice fdev = ncService.findDevById(postData.getFdevid());

-                if(postData.getDevtype().equals("R")){

-                    RedisUtil.set("ncdev_" + fdev.getDevphyid() + "_" + postData.getDevno(),String.valueOf(maxId+1));

+                if (postData.getDevtype().equals("R")) {

+                    RedisUtil.set("ncdev_" + fdev.getDevphyid() + "_" + postData.getDevno(), String.valueOf(maxId + 1));

                 }

-                ncService.saveDevice(devAdd);

+                boolean bool = ncService.saveDevice(devAdd);

+

+                if (bool) {

+                    HttpConnectionUtil util = new HttpConnectionUtil();

+

+                    Map<String, String> postmap = new HashMap<>();

+                    postmap.put("areaname", devAdd.getBuildingname());  //区域名称

+                    postmap.put("status", "1");   //状态

+                    postmap.put("devicename", devAdd.getDevname());  //设备名称

+                    postmap.put("devphyid", devAdd.getDevphyid());  //设备物理id

+                    postmap.put("source", "door");  //来源

+                    Gson gson = new Gson();

+                    String result = util.sendByPostJson(auditsysurl + "/register", gson.toJson(postmap));

+                    logger.info(result);

+                }

+

+

                 map.put("errStr", "");

             }

-        }catch (Exception e){

+        } catch (Exception e) {

             e.printStackTrace();

             map.put("errStr", "添加设备失败!");

             logger.error("添加设备失败:" + e.getMessage());

@@ -345,6 +373,7 @@
 

     /**

      * 设备删除

+     *

      * @param devid

      * @param request

      * @param response

@@ -353,22 +382,22 @@
     @RequestMapping(value = "/deleteNcDev", method = {RequestMethod.GET})

     @ResponseBody

     public Map deleteNcDev(@RequestParam(value = "devid") int devid,

-                              HttpServletRequest request, HttpServletResponse response) {

+                           HttpServletRequest request, HttpServletResponse response) {

         Map map = new HashMap();

         String message = "";

         try {

             boolean flag = ncService.getDevWeekByDevid(devid);

-            if (flag==true){

+            if (flag == true) {

                 message = "该设备已绑定时间周!";

                 map.put("message", message);

                 return map;

             }

             TNcDevice dev = ncService.getDevInfoByDevid(devid);

-            if(dev!=null){

+            if (dev != null) {

                 RedisUtil.del("ncdev_" + dev.getDevphyid() + "_" + dev.getDevno());

-                if (dev.getDevtype().equals("C")){

+                if (dev.getDevtype().equals("C")) {

                     List<TNcDevice> listByfDevid = ncService.getDevListByfDevid(dev.getDeviceid());

-                    if (listByfDevid!=null && listByfDevid.size()>0){

+                    if (listByfDevid != null && listByfDevid.size() > 0) {

                         message = "该控制器设备已绑定读头!";

                         map.put("message", message);

                         return map;

@@ -391,6 +420,7 @@
 

     /**

      * 清除设备名单

+     *

      * @param devid

      * @param request

      * @param response

@@ -399,12 +429,12 @@
     @RequestMapping(value = "/listClean", method = {RequestMethod.GET})

     @ResponseBody

     public Map listClean(@RequestParam(value = "devid") int devid,

-                         HttpServletRequest request, HttpServletResponse response,@AuthenticationPrincipal TOperator operUser){

+                         HttpServletRequest request, HttpServletResponse response, @AuthenticationPrincipal TOperator operUser) {

         Map map = new HashMap();

-        String message="";

-        try{

+        String message = "";

+        try {

             TNcCardlist cleanList = ncService.getCleanList(devid);

-            if (cleanList==null) {

+            if (cleanList == null) {

                 //如果该设备没有清空专用名单则添加一个(直接添加到同步表里)

                 TNcCardlist tNcCardlist = new TNcCardlist();

                 long listid = RedisUtil.incr("seq_cardlist");

@@ -425,17 +455,17 @@
                 tNcCardlist.setRtntime("");

                 tNcCardlist.setVersion(0);

                 ncService.saveCardlist(tNcCardlist);

-            }else{

+            } else {

                 cleanList.setSyncflag("N");

                 cleanList.setSynctime("");

-                cleanList.setVersion(cleanList.getVersion()+1);

+                cleanList.setVersion(cleanList.getVersion() + 1);

                 cleanList.setRectime(DateUtil.getNow());

                 ncService.updateCardlist(cleanList);

             }

-        }catch (Exception e){

+        } catch (Exception e) {

             e.printStackTrace();

             message = "设备名单清空异常!";

-            logger.error("设备名单清空失败:"+e.getMessage());

+            logger.error("设备名单清空失败:" + e.getMessage());

         }

         map.put("message", message);

         return map;

@@ -443,6 +473,7 @@
 

     /**

      * 设备名单重下

+     *

      * @param devid

      * @param request

      * @param response

@@ -451,16 +482,16 @@
     @RequestMapping(value = "/listReload", method = {RequestMethod.GET})

     @ResponseBody

     public Map listReload(@RequestParam(value = "devid") int devid,

-                          HttpServletRequest request, HttpServletResponse response){

+                          HttpServletRequest request, HttpServletResponse response) {

         Map map = new HashMap();

-        String message="";

-        try{

+        String message = "";

+        try {

             //修改该设备名单同步标志为未同步

             ncService.updateForListReload(devid);

-        }catch (Exception e){

+        } catch (Exception e) {

             e.printStackTrace();

             message = "设备名单重下异常!";

-            logger.error("设备名单重下失败"+e.getMessage());

+            logger.error("设备名单重下失败" + e.getMessage());

         }

         map.put("message", message);

         return map;

@@ -468,6 +499,7 @@
 

     /**

      * 获取时间段

+     *

      * @param request

      * @param response

      * @param pageNo

@@ -481,13 +513,13 @@
                             HttpServletResponse response,

                             @RequestParam(value = "pageNo", required = false, defaultValue = "1") int pageNo,

                             @RequestParam(value = "pageSize", required = false, defaultValue = "10") int pageSize,

-                            @RequestParam(value = "timename", required = true, defaultValue = "") String timename){

+                            @RequestParam(value = "timename", required = true, defaultValue = "") String timename) {

         Map map = new HashMap();

         try {

             Pagination page = null;

             page = ncService.getNcTimeWithPage(timename, pageNo, pageSize, map);

             map.put("PageResult", page);

-        }catch (Exception e){

+        } catch (Exception e) {

             e.printStackTrace();

             logger.error("查询设备失败:" + e.getMessage());

         }

@@ -496,6 +528,7 @@
 

     /**

      * 删除时间段

+     *

      * @param timeid

      * @param request

      * @param response

@@ -504,16 +537,16 @@
     @RequestMapping(value = "/deleteNcTime", method = {RequestMethod.GET})

     @ResponseBody

     public Map deleteNcTime(@RequestParam(value = "timeid") int timeid,

-                            HttpServletRequest request, HttpServletResponse response){

+                            HttpServletRequest request, HttpServletResponse response) {

         Map map = new HashMap();

         String message = "";

-        int flag=0;

+        int flag = 0;

         try {

             List<String> timegrpIdById = ncService.getTimegrpIdById(timeid);

-            if(timegrpIdById.size()>0){

+            if (timegrpIdById.size() > 0) {

                 message = "时间段已被应用于时间组,删除失败!";

-                flag=1;

-            }else {

+                flag = 1;

+            } else {

                 ncService.delTimeByTimeId(timeid);

                 ncService.updListVersion();

             }

@@ -522,13 +555,14 @@
             message = "删除时间段出现异常!";

             logger.error("删除时间段失败:" + e.getMessage());

         }

-        map.put("flag",flag);

+        map.put("flag", flag);

         map.put("message", message);

         return map;

     }

 

     /**

      * 获取时间段信息

+     *

      * @param timeid

      * @return

      */

@@ -547,6 +581,7 @@
 

     /**

      * 添加时间段

+     *

      * @param postData

      * @param request

      * @param response

@@ -555,7 +590,7 @@
     @RequestMapping(value = "/addNcTime", method = {RequestMethod.POST})

     @ResponseBody

     public Map addNcTime(@RequestBody NcTimeBean postData,

-                              HttpServletRequest request, HttpServletResponse response) {

+                         HttpServletRequest request, HttpServletResponse response) {

         Map map = new HashMap();

         try {

             TNcTime time = ncService.findByTimeName(postData.getTimename());

@@ -563,7 +598,7 @@
             if (time == null) {

                 int timeid = ncService.getMaxTimeId();

                 ts = new TNcTime();

-                ts.setTimeid(timeid+1);

+                ts.setTimeid(timeid + 1);

                 ts.setTimename(postData.getTimename());

                 ts.setBtime(postData.getBtime());

                 ts.setEtime(postData.getEtime());

@@ -588,6 +623,7 @@
 

     /**

      * 修改时间段信息

+     *

      * @param bean

      * @param request

      * @return

@@ -595,7 +631,7 @@
     @RequestMapping(value = "/updateNcTime", method = {RequestMethod.POST})

     @ResponseBody

     public Map updateNcTime(@RequestBody NcTimeBean bean,

-                                 HttpServletRequest request) {

+                            HttpServletRequest request) {

         Map map = new HashMap();

         try {

             if (bean == null) {

@@ -669,7 +705,7 @@
     @RequestMapping("/loadNcTimeGrpForUpdate")

     @ResponseBody

     public Map loadNcTimeGrpForUpdate(

-                                        @RequestParam(value = "timegrpid") int timegrpid) {

+            @RequestParam(value = "timegrpid") int timegrpid) {

         Map map = new HashMap();

         try {

             TNcTimegrp timegrp = ncService.findByTimeGrpId(timegrpid);

@@ -695,7 +731,7 @@
     @RequestMapping(value = "/addNcTimegrp", method = {RequestMethod.POST})

     @ResponseBody

     public Map addNcTime(@RequestBody TNcTimegrp postData,

-                              HttpServletRequest request, HttpServletResponse response) {

+                         HttpServletRequest request, HttpServletResponse response) {

         Map map = new HashMap();

         try {

             TNcTimegrp timegrp = ncService.findByTimeGrpName(postData.getTimegrpname());

@@ -704,7 +740,7 @@
             if (timegrp == null) {

                 int timegrpid = ncService.getMaxTimeGrpId();

                 ts = new TNcTimegrp();

-                ts.setTimegrpid(timegrpid+1);

+                ts.setTimegrpid(timegrpid + 1);

                 ts.setTimegrpname(postData.getTimegrpname());

                 ts.setTimeid1(postData.getTimeid1());

                 ts.setTimeid2(postData.getTimeid2());

@@ -732,6 +768,7 @@
 

     /**

      * 修改时间组信息

+     *

      * @param bean

      * @param request

      * @return

@@ -739,7 +776,7 @@
     @ResponseBody

     @RequestMapping(value = "/updateNcTimegrp", method = {RequestMethod.POST})

     public Map updateNcTimegrp(@RequestBody TNcTimegrp bean,

-                                    HttpServletRequest request) {

+                               HttpServletRequest request) {

         Map map = new HashMap();

         try {

             if (bean == null) {

@@ -777,6 +814,7 @@
 

     /**

      * 删除时间组

+     *

      * @param timegrpid

      * @param request

      * @param response

@@ -785,31 +823,32 @@
     @ResponseBody

     @RequestMapping(value = "/deleteNcTimegrp", method = {RequestMethod.GET})

     public Map deleteNcTimegrp(@RequestParam(value = "timegrpid") int timegrpid,

-                                  HttpServletRequest request, HttpServletResponse response) {

+                               HttpServletRequest request, HttpServletResponse response) {

         Map map = new HashMap();

         String message = "";

         int flag = 0;

-            try {

-                List<String> weekTimeById = ncService.getWeekTimeById(timegrpid);

-                if(weekTimeById.size()>0){

-                    message="时间组已应用于时间周,删除失败!";

-                    flag=1;

-                }else {

-                    ncService.delByGrpId(timegrpid);

-                    ncService.updListVersion();

-                }

-            } catch (Exception e) {

-                e.printStackTrace();

-                message = "删除时间组出现异常!";

-                logger.error("删除时间组失败:" + e.getMessage());

+        try {

+            List<String> weekTimeById = ncService.getWeekTimeById(timegrpid);

+            if (weekTimeById.size() > 0) {

+                message = "时间组已应用于时间周,删除失败!";

+                flag = 1;

+            } else {

+                ncService.delByGrpId(timegrpid);

+                ncService.updListVersion();

             }

-        map.put("flag",flag);

+        } catch (Exception e) {

+            e.printStackTrace();

+            message = "删除时间组出现异常!";

+            logger.error("删除时间组失败:" + e.getMessage());

+        }

+        map.put("flag", flag);

         map.put("message", message);

         return map;

     }

 

     /**

      * 查询获取时间周信息列表

+     *

      * @param request

      * @param response

      * @param pageNo

@@ -849,7 +888,7 @@
     @ResponseBody

     @RequestMapping("/loadNcweektimeForUpdate")

     public Map loadNcweektimeForUpdate(

-                                          @RequestParam(value = "weektimeid") int weektimeid) {

+            @RequestParam(value = "weektimeid") int weektimeid) {

         Map map = new HashMap();

         try {

             TNcWeektime weektime = ncService.findByWeekTimeId(weektimeid);

@@ -864,6 +903,7 @@
 

     /**

      * 添加时间周

+     *

      * @param postData

      * @param request

      * @param response

@@ -872,21 +912,21 @@
     @ResponseBody

     @RequestMapping(value = "/addNcweektime", method = {RequestMethod.POST})

     public Map addNcweektime(@RequestBody TNcWeektime postData,

-                                  HttpServletRequest request, HttpServletResponse response) {

+                             HttpServletRequest request, HttpServletResponse response) {

         Map map = new HashMap();

         try {

             TNcWeektime weektime = ncService.findByWeekTimeName(postData.getWeekname());

 

             TNcWeektime ts = null;

-            int weektimeid=ncService.getMaxWeekId();//weekid最小值3,最大值15

-            if (weektimeid==0){

-                weektimeid=3;

-            }else{

-                weektimeid= weektimeid+1;

+            int weektimeid = ncService.getMaxWeekId();//weekid最小值3,最大值15

+            if (weektimeid == 0) {

+                weektimeid = 3;

+            } else {

+                weektimeid = weektimeid + 1;

             }

 

-            if(weektimeid>=15){

-                map.put("errStr","时间周数量超限!");

+            if (weektimeid >= 15) {

+                map.put("errStr", "时间周数量超限!");

             }

             if (weektime == null) {

                 ts = new TNcWeektime();

@@ -919,6 +959,7 @@
 

     /**

      * 修改时间周信息

+     *

      * @param bean

      * @param request

      * @return

@@ -926,7 +967,7 @@
     @ResponseBody

     @RequestMapping(value = "/updateNcweektime", method = {RequestMethod.POST})

     public Map updateNcweektime(@RequestBody TNcWeektime bean,

-                                     HttpServletRequest request) {

+                                HttpServletRequest request) {

         Map map = new HashMap();

         try {

             if (bean == null) {

@@ -965,6 +1006,7 @@
 

     /**

      * 删除时间周

+     *

      * @param weektimeid

      * @param request

      * @param response

@@ -973,16 +1015,16 @@
     @ResponseBody

     @RequestMapping(value = "/deleteNcweektime", method = {RequestMethod.GET})

     public Map deleteNcweektime(@RequestParam(value = "weektimeid") int weektimeid,

-                                   HttpServletRequest request, HttpServletResponse response) {

+                                HttpServletRequest request, HttpServletResponse response) {

         Map map = new HashMap();

-        int flag=0;

-        String message="";

+        int flag = 0;

+        String message = "";

         try {

             List devWeekByWeekid = ncService.getDevWeekByWeekid(weektimeid);

-            if(devWeekByWeekid.size()>0){

+            if (devWeekByWeekid.size() > 0) {

                 message = "时间周已绑定设备,删除失败!";

-                flag=1;

-            }else {

+                flag = 1;

+            } else {

                 ncService.delByWeekId(weektimeid);

                 ncService.updListVersion();

                 /*//删除doortime表中的时间周

@@ -994,7 +1036,7 @@
             logger.error("删除时间周失败:" + e.getMessage());

         }

 

-        map.put("flag",flag);

+        map.put("flag", flag);

         map.put("message", message);

         return map;

     }

@@ -1002,6 +1044,7 @@
 

     /**

      * 获取设备时间周

+     *

      * @param request

      * @param response

      * @param pageNo

@@ -1035,6 +1078,7 @@
 

     /**

      * 删除设备时间周

+     *

      * @param devid

      * @param weekid

      * @param request

@@ -1049,7 +1093,7 @@
         String message = "";

         Map map = new HashMap();

         try {

-            ncService.delDevWeekById(devid,weekid);

+            ncService.delDevWeekById(devid, weekid);

             ncService.updListVersion();

             RedisUtil.incr("zcard_max_version");

         } catch (Exception e) {

@@ -1063,6 +1107,7 @@
 

     /**

      * 添加设备时间周

+     *

      * @param weekid

      * @param devids

      * @param request

@@ -1077,57 +1122,58 @@
             HttpServletRequest request,

             @RequestBody String[] beans) {

         Map map = new HashMap();

-        String errStr="";

-            try {

-                int maxDevWeekVersion = ncService.findMaxDevWeekVersion();

-                if(beans != null && beans.length > 0){

-                    String[] devlist=beans;

-                    ncService.deleteDevWeekByWeekId(weekid);

-                    for (int i=0;i<devlist.length;i++){

-                        TNcDevweek devweek = new TNcDevweek();

-                        TNcDevweekId tNcDevweekId = new TNcDevweekId();

-                        tNcDevweekId.setDevid(Integer.parseInt(devlist[i]));

-                        tNcDevweekId.setWeekid(weekid);

-                        devweek.setId(tNcDevweekId);

-                        TNcDevice dev = ncService.findDevById(Integer.parseInt(devlist[i]));

-                        devweek.setDevname(dev.getDevname());

-                        TNcWeektime wt = ncService.findByWeekTimeId(weekid);

-                        devweek.setWeekname(wt.getWeekname());

-                        devweek.setUpdatetime(DateUtil.getNow());

-                        devweek.setVersion(maxDevWeekVersion);

-                        boolean b = ncService.saveDevWeek(devweek);

-                        map.put("errStr", "");

-                    }

-                    ncService.updListVersion();

-                    RedisUtil.incr("zcard_max_version");

+        String errStr = "";

+        try {

+            int maxDevWeekVersion = ncService.findMaxDevWeekVersion();

+            if (beans != null && beans.length > 0) {

+                String[] devlist = beans;

+                ncService.deleteDevWeekByWeekId(weekid);

+                for (int i = 0; i < devlist.length; i++) {

+                    TNcDevweek devweek = new TNcDevweek();

+                    TNcDevweekId tNcDevweekId = new TNcDevweekId();

+                    tNcDevweekId.setDevid(Integer.parseInt(devlist[i]));

+                    tNcDevweekId.setWeekid(weekid);

+                    devweek.setId(tNcDevweekId);

+                    TNcDevice dev = ncService.findDevById(Integer.parseInt(devlist[i]));

+                    devweek.setDevname(dev.getDevname());

+                    TNcWeektime wt = ncService.findByWeekTimeId(weekid);

+                    devweek.setWeekname(wt.getWeekname());

+                    devweek.setUpdatetime(DateUtil.getNow());

+                    devweek.setVersion(maxDevWeekVersion);

+                    boolean b = ncService.saveDevWeek(devweek);

+                    map.put("errStr", "");

                 }

-            } catch (Exception e) {

-                e.printStackTrace();

-                map.put("errStr", "分配设备失败");

-                logger.error("分配设备失败:" + e.getMessage());

+                ncService.updListVersion();

+                RedisUtil.incr("zcard_max_version");

             }

+        } catch (Exception e) {

+            e.printStackTrace();

+            map.put("errStr", "分配设备失败");

+            logger.error("分配设备失败:" + e.getMessage());

+        }

 

         return map;

     }

 

     /**

      * 根据id查询已选取此时间周的设备

+     *

      * @param reWeekId

      * @param request

      * @param response

      * @return

      */

     @ResponseBody

-    @RequestMapping(value="/getChosenDev")

+    @RequestMapping(value = "/getChosenDev")

     public Map getChosenDev(

-            @RequestParam(value = "reWeekId",required=true) int reWeekId,

+            @RequestParam(value = "reWeekId", required = true) int reWeekId,

             HttpServletRequest request,

-            HttpServletResponse response){

+            HttpServletResponse response) {

         Map map = new HashMap();

-        try{

+        try {

             List<TNcDevweek> chosenDev = ncService.findChosenDev(reWeekId);

-            map.put("chosenDev",chosenDev);//已做出选择的设备

-        }catch (Exception e){

+            map.put("chosenDev", chosenDev);//已做出选择的设备

+        } catch (Exception e) {

             e.printStackTrace();

             logger.error("查询已做出选择设备失败:" + e.getMessage());

         }

@@ -1154,7 +1200,7 @@
             String opertype = operUser.getOpertype();

             List<TNcDevice> device = null;

 

-                device = ncService.findAllNcDevices();

+            device = ncService.findAllNcDevices();

 

 

             map.put("device", device);//设备

@@ -1167,12 +1213,13 @@
 

     /**

      * 设备导入模板下载

+     *

      * @param request

      * @param response

      */

     @ResponseBody

     @RequestMapping("/downNcDevExcelTemplate")

-    public void downNcDevExcelTemplate(HttpServletRequest request, HttpServletResponse response){

+    public void downNcDevExcelTemplate(HttpServletRequest request, HttpServletResponse response) {

         Map map = new HashMap();

         try {

             List<ExcelExportEntity> entity = new ArrayList<ExcelExportEntity>();

@@ -1209,15 +1256,16 @@
 

     /**

      * 设备导入

+     *

      * @param file

      * @param request

      * @param response

      * @return

      */

     @ResponseBody

-    @RequestMapping(value = "/saveNcDevByExcel",method = {RequestMethod.POST})

+    @RequestMapping(value = "/saveNcDevByExcel", method = {RequestMethod.POST})

     public Map saveNcDevByExcel(@RequestParam(value = "file", required = false) MultipartFile file,

-                                   HttpServletRequest request,HttpServletResponse response){

+                                HttpServletRequest request, HttpServletResponse response) {

         Map map = new HashMap();

         try {

             String devTypeId = request.getParameter("devTypeId");

@@ -1228,128 +1276,128 @@
                 targetFile.mkdirs();

             }

             file.transferTo(targetFile);

-            map = impNcDevList(path + "/" + fileName,devTypeId, map);

+            map = impNcDevList(path + "/" + fileName, devTypeId, map);

 

-        }catch (Exception e){

+        } catch (Exception e) {

             e.printStackTrace();

         }

 

         return map;

     }

 

-    private Map impNcDevList(String fpath,String devTypeId,Map map){

+    private Map impNcDevList(String fpath, String devTypeId, Map map) {

         ImportParams params = new ImportParams();

         params.setTitleRows(0);

         List<TNcDevice> tNcDeviceList = ExcelImportUtil.importExcel(new File(fpath), TNcDevice.class, params);

         int totCnt = tNcDeviceList.size();

         int flag = 0;

-        if (totCnt<=0){

-            map.put("impDev_succ","导入文件中未查询到数据!");

+        if (totCnt <= 0) {

+            map.put("impDev_succ", "导入文件中未查询到数据!");

             flag = -1;

             map.put("flag", flag);

             return map;

         }

         String failStr = "";

-        try{

+        try {

             TNcDevice device;

 

             //判断导入数据是否合法

-            for (int i=0;i<tNcDeviceList.size();i++){

-                if (tNcDeviceList.get(i).getRegionid()==null||"".equals(tNcDeviceList.get(i).getRegionid())){

-                    failStr = "第"+(i+1)+"条数据--设备所属区域编号为空!";

-                    map.put("impDev_succ",failStr);

+            for (int i = 0; i < tNcDeviceList.size(); i++) {

+                if (tNcDeviceList.get(i).getRegionid() == null || "".equals(tNcDeviceList.get(i).getRegionid())) {

+                    failStr = "第" + (i + 1) + "条数据--设备所属区域编号为空!";

+                    map.put("impDev_succ", failStr);

                     flag = -1;

                     map.put("flag", flag);

                     return map;

                 }

                 TRegion regionById = systemService.getRegionById(tNcDeviceList.get(i).getRegionid());

-                if (regionById==null){

-                    failStr = "第"+(i+1)+"条数据--设备所属区域不存在!";

-                    map.put("impDev_succ",failStr);

+                if (regionById == null) {

+                    failStr = "第" + (i + 1) + "条数据--设备所属区域不存在!";

+                    map.put("impDev_succ", failStr);

                     flag = -1;

                     map.put("flag", flag);

                     return map;

                 }

 

-                if (tNcDeviceList.get(i).getBuildingid()==null||"".equals(tNcDeviceList.get(i).getBuildingid())){

-                    failStr = "第"+(i+1)+"条数据--设备所属楼栋编号为空!";

-                    map.put("impDev_succ",failStr);

+                if (tNcDeviceList.get(i).getBuildingid() == null || "".equals(tNcDeviceList.get(i).getBuildingid())) {

+                    failStr = "第" + (i + 1) + "条数据--设备所属楼栋编号为空!";

+                    map.put("impDev_succ", failStr);

                     flag = -1;

                     map.put("flag", flag);

                     return map;

                 }

                 TBuilding buildingById = systemService.getBuildingById(tNcDeviceList.get(i).getBuildingid());

-                if (buildingById==null){

-                    failStr = "第"+(i+1)+"条数据--设备所属楼栋不存在!";

-                    map.put("impDev_succ",failStr);

+                if (buildingById == null) {

+                    failStr = "第" + (i + 1) + "条数据--设备所属楼栋不存在!";

+                    map.put("impDev_succ", failStr);

                     flag = -1;

                     map.put("flag", flag);

                     return map;

                 }

 

                 //控制器设备类型

-                if (devTypeId.equals("C")){

-                    if (!tNcDeviceList.get(i).getDevtype().equals("C")){

-                        failStr = "第"+(i+1)+"条数据--设备类型和所选设备类型不一致!";

-                        map.put("impDev_succ",failStr);

+                if (devTypeId.equals("C")) {

+                    if (!tNcDeviceList.get(i).getDevtype().equals("C")) {

+                        failStr = "第" + (i + 1) + "条数据--设备类型和所选设备类型不一致!";

+                        map.put("impDev_succ", failStr);

                         flag = -1;

                         map.put("flag", flag);

                         return map;

                     }

-                    if (tNcDeviceList.get(i).getDevphyid()==null){

-                        failStr = "第"+(i+1)+"条数据--终端物理编号为空!";

-                        map.put("impDev_succ",failStr);

+                    if (tNcDeviceList.get(i).getDevphyid() == null) {

+                        failStr = "第" + (i + 1) + "条数据--终端物理编号为空!";

+                        map.put("impDev_succ", failStr);

                         flag = -1;

                         map.put("flag", flag);

                         return map;

                     }

-                    if (tNcDeviceList.get(i).getDevname()==null){

-                        failStr = "第"+(i+1)+"条数据--设备名称为空!";

-                        map.put("impDev_succ",failStr);

+                    if (tNcDeviceList.get(i).getDevname() == null) {

+                        failStr = "第" + (i + 1) + "条数据--设备名称为空!";

+                        map.put("impDev_succ", failStr);

                         flag = -1;

                         map.put("flag", flag);

                         return map;

                     }

-                    if (tNcDeviceList.get(i).getDevtype()==null){

-                        failStr = "第"+(i+1)+"条数据--设备类型为空!";

-                        map.put("impDev_succ",failStr);

+                    if (tNcDeviceList.get(i).getDevtype() == null) {

+                        failStr = "第" + (i + 1) + "条数据--设备类型为空!";

+                        map.put("impDev_succ", failStr);

                         flag = -1;

                         map.put("flag", flag);

                         return map;

                     }

-                    device = ncService.validDevPhyid(0,tNcDeviceList.get(i).getDevphyid());

-                    if (device!=null && device.getDeviceid()>0){

-                        failStr = "第"+(i+1)+"条数据--终端物理编号已存在!";

-                        map.put("impDev_succ",failStr);

+                    device = ncService.validDevPhyid(0, tNcDeviceList.get(i).getDevphyid());

+                    if (device != null && device.getDeviceid() > 0) {

+                        failStr = "第" + (i + 1) + "条数据--终端物理编号已存在!";

+                        map.put("impDev_succ", failStr);

                         flag = -1;

                         map.put("flag", flag);

                         return map;

                     }

-                    device = ncService.validDevName(0,tNcDeviceList.get(i).getDevname());

-                    if (device!=null && device.getDeviceid()>0){

-                        failStr = "第"+(i+1)+"条数据--设备名称已存在!";

-                        map.put("impDev_succ",failStr);

+                    device = ncService.validDevName(0, tNcDeviceList.get(i).getDevname());

+                    if (device != null && device.getDeviceid() > 0) {

+                        failStr = "第" + (i + 1) + "条数据--设备名称已存在!";

+                        map.put("impDev_succ", failStr);

                         flag = -1;

                         map.put("flag", flag);

                         return map;

                     }

-                    if (tNcDeviceList.get(i).getFdevid()!=null){

-                        failStr = "第"+(i+1)+"条数据--控制器类型上级设备必须为空!";

-                        map.put("impDev_succ",failStr);

+                    if (tNcDeviceList.get(i).getFdevid() != null) {

+                        failStr = "第" + (i + 1) + "条数据--控制器类型上级设备必须为空!";

+                        map.put("impDev_succ", failStr);

                         flag = -1;

                         map.put("flag", flag);

                         return map;

                     }

-                    if (tNcDeviceList.get(i).getDevno()!=null){

-                        failStr = "第"+(i+1)+"条数据--控制器类型读头号必须为空!";

-                        map.put("impDev_succ",failStr);

+                    if (tNcDeviceList.get(i).getDevno() != null) {

+                        failStr = "第" + (i + 1) + "条数据--控制器类型读头号必须为空!";

+                        map.put("impDev_succ", failStr);

                         flag = -1;

                         map.put("flag", flag);

                         return map;

                     }

-                    if (tNcDeviceList.get(i).getDevtype().equals("C") && tNcDeviceList.get(i).getDevphyid().length()!=12){

-                        failStr = "第"+(i+1)+"条数据--控制器类型终端物理编号必须为12位!";

-                        map.put("impDev_succ",failStr);

+                    if (tNcDeviceList.get(i).getDevtype().equals("C") && tNcDeviceList.get(i).getDevphyid().length() != 12) {

+                        failStr = "第" + (i + 1) + "条数据--控制器类型终端物理编号必须为12位!";

+                        map.put("impDev_succ", failStr);

                         flag = -1;

                         map.put("flag", flag);

                         return map;

@@ -1358,87 +1406,87 @@
 

 

                 //读头设备类型

-                if (devTypeId.equals("R")){

-                    if (!tNcDeviceList.get(i).getDevtype().equals("R")){

-                        failStr = "第"+(i+1)+"条数据--设备类型和所选设备类型不一致!";

-                        map.put("impDev_succ",failStr);

+                if (devTypeId.equals("R")) {

+                    if (!tNcDeviceList.get(i).getDevtype().equals("R")) {

+                        failStr = "第" + (i + 1) + "条数据--设备类型和所选设备类型不一致!";

+                        map.put("impDev_succ", failStr);

                         flag = -1;

                         map.put("flag", flag);

                         return map;

                     }

-                    if (tNcDeviceList.get(i).getDevphyid()==null){

-                        failStr = "第"+(i+1)+"条数据--终端物理编号为空!";

-                        map.put("impDev_succ",failStr);

+                    if (tNcDeviceList.get(i).getDevphyid() == null) {

+                        failStr = "第" + (i + 1) + "条数据--终端物理编号为空!";

+                        map.put("impDev_succ", failStr);

                         flag = -1;

                         map.put("flag", flag);

                         return map;

                     }

-                    if (tNcDeviceList.get(i).getDevname()==null){

-                        failStr = "第"+(i+1)+"条数据--设备名称为空!";

-                        map.put("impDev_succ",failStr);

+                    if (tNcDeviceList.get(i).getDevname() == null) {

+                        failStr = "第" + (i + 1) + "条数据--设备名称为空!";

+                        map.put("impDev_succ", failStr);

                         flag = -1;

                         map.put("flag", flag);

                         return map;

                     }

-                    if (tNcDeviceList.get(i).getDevtype()==null){

-                        failStr = "第"+(i+1)+"条数据--设备类型为空!";

-                        map.put("impDev_succ",failStr);

+                    if (tNcDeviceList.get(i).getDevtype() == null) {

+                        failStr = "第" + (i + 1) + "条数据--设备类型为空!";

+                        map.put("impDev_succ", failStr);

                         flag = -1;

                         map.put("flag", flag);

                         return map;

                     }

-                    device = ncService.validDevPhyid(0,tNcDeviceList.get(i).getDevphyid());

-                    if (device!=null && device.getDeviceid()>0){

-                        failStr = "第"+(i+1)+"条数据--终端物理编号已存在!";

-                        map.put("impDev_succ",failStr);

+                    device = ncService.validDevPhyid(0, tNcDeviceList.get(i).getDevphyid());

+                    if (device != null && device.getDeviceid() > 0) {

+                        failStr = "第" + (i + 1) + "条数据--终端物理编号已存在!";

+                        map.put("impDev_succ", failStr);

                         flag = -1;

                         map.put("flag", flag);

                         return map;

                     }

-                    device = ncService.validDevName(0,tNcDeviceList.get(i).getDevname());

-                    if (device!=null && device.getDeviceid()>0){

-                        failStr = "第"+(i+1)+"条数据--设备名称已存在!";

-                        map.put("impDev_succ",failStr);

+                    device = ncService.validDevName(0, tNcDeviceList.get(i).getDevname());

+                    if (device != null && device.getDeviceid() > 0) {

+                        failStr = "第" + (i + 1) + "条数据--设备名称已存在!";

+                        map.put("impDev_succ", failStr);

                         flag = -1;

                         map.put("flag", flag);

                         return map;

                     }

-                    if (tNcDeviceList.get(i).getDevtype().equals("R") && tNcDeviceList.get(i).getFdevid()==null){

-                        failStr = "第"+(i+1)+"条数据--读头类型上级设备不可为空!";

-                        map.put("impDev_succ",failStr);

+                    if (tNcDeviceList.get(i).getDevtype().equals("R") && tNcDeviceList.get(i).getFdevid() == null) {

+                        failStr = "第" + (i + 1) + "条数据--读头类型上级设备不可为空!";

+                        map.put("impDev_succ", failStr);

                         flag = -1;

                         map.put("flag", flag);

                         return map;

                     }

-                    if (tNcDeviceList.get(i).getDevtype().equals("R") && tNcDeviceList.get(i).getDevno()==null){

-                        failStr = "第"+(i+1)+"条数据--读头类型读头号不可为空!";

-                        map.put("impDev_succ",failStr);

+                    if (tNcDeviceList.get(i).getDevtype().equals("R") && tNcDeviceList.get(i).getDevno() == null) {

+                        failStr = "第" + (i + 1) + "条数据--读头类型读头号不可为空!";

+                        map.put("impDev_succ", failStr);

                         flag = -1;

                         map.put("flag", flag);

                         return map;

                     }

-                    if (tNcDeviceList.get(i).getDevtype().equals("R")){

+                    if (tNcDeviceList.get(i).getDevtype().equals("R")) {

                         device = ncService.findDevById(tNcDeviceList.get(i).getFdevid());

-                        if (device==null){

-                            failStr = "第"+(i+1)+"条数据--此上级设备不存在!";

-                            map.put("impDev_succ",failStr);

+                        if (device == null) {

+                            failStr = "第" + (i + 1) + "条数据--此上级设备不存在!";

+                            map.put("impDev_succ", failStr);

                             flag = -1;

                             map.put("flag", flag);

                             return map;

                         }

                     }

                     device = ncService.findDevById(tNcDeviceList.get(i).getFdevid());

-                    if (!(device.getDevtype().equals("C"))){

-                        failStr = "第"+(i+1)+"条数据--此上级设备不为控制器!";

-                        map.put("impDev_succ",failStr);

+                    if (!(device.getDevtype().equals("C"))) {

+                        failStr = "第" + (i + 1) + "条数据--此上级设备不为控制器!";

+                        map.put("impDev_succ", failStr);

                         flag = -1;

                         map.put("flag", flag);

                         return map;

                     }

-                    device=ncService.validDevNo(tNcDeviceList.get(i).getFdevid(),tNcDeviceList.get(i).getDevno(),0);

-                    if (device!=null && device.getDeviceid()>0){

-                        failStr = "第"+(i+1)+"条数据--该控制器下此读头号已存在!";

-                        map.put("impDev_succ",failStr);

+                    device = ncService.validDevNo(tNcDeviceList.get(i).getFdevid(), tNcDeviceList.get(i).getDevno(), 0);

+                    if (device != null && device.getDeviceid() > 0) {

+                        failStr = "第" + (i + 1) + "条数据--该控制器下此读头号已存在!";

+                        map.put("impDev_succ", failStr);

                         flag = -1;

                         map.put("flag", flag);

                         return map;

@@ -1450,36 +1498,36 @@
             //批量添加设备

             int successCnt = 0;

             int errCnt = 0;

-            for (TNcDevice tNcDeviceTemp:tNcDeviceList){

+            for (TNcDevice tNcDeviceTemp : tNcDeviceList) {

                 TNcDevice validDevName = ncService.validDevName(0, tNcDeviceTemp.getDevname());

-                if (validDevName!=null && validDevName.getDeviceid()>0){

+                if (validDevName != null && validDevName.getDeviceid() > 0) {

                     errCnt++;

                     continue;

                 }

                 TNcDevice validDevPhyid = ncService.validDevPhyid(0, tNcDeviceTemp.getDevphyid());

-                if (validDevPhyid!=null){

+                if (validDevPhyid != null) {

                     errCnt++;

                     continue;

                 }

-                if (tNcDeviceTemp.getDevtype().equals("R")){

+                if (tNcDeviceTemp.getDevtype().equals("R")) {

                     TNcDevice validDevNo = ncService.validDevNo(tNcDeviceTemp.getFdevid(), tNcDeviceTemp.getDevno(), 0);

-                    if (validDevNo!=null){

+                    if (validDevNo != null) {

                         errCnt++;

                         continue;

                     }

                     RedisUtil.del("ncdev_" + tNcDeviceTemp.getDevphyid() + "_" + tNcDeviceTemp.getDevno());

-                    RedisUtil.set("ncdev_" + tNcDeviceTemp.getDevphyid() + "_" + tNcDeviceTemp.getDevno(),String.valueOf(tNcDeviceTemp.getDeviceid()));

+                    RedisUtil.set("ncdev_" + tNcDeviceTemp.getDevphyid() + "_" + tNcDeviceTemp.getDevno(), String.valueOf(tNcDeviceTemp.getDeviceid()));

                 }

                 int maxId = ncService.getMaxId();

                 TNcDevice devAdd = new TNcDevice();

-                devAdd.setDeviceid(maxId+1);

+                devAdd.setDeviceid(maxId + 1);

                 devAdd.setDevname(tNcDeviceTemp.getDevname());

                 devAdd.setDevphyid(tNcDeviceTemp.getDevphyid().toUpperCase());

                 devAdd.setDevtype(tNcDeviceTemp.getDevtype());

                 devAdd.setFdevid(tNcDeviceTemp.getFdevid());

-                if (tNcDeviceTemp.getDevtype().equals("C")){

+                if (tNcDeviceTemp.getDevtype().equals("C")) {

                     devAdd.setDevno(0);//控制器读头为0

-                }else {

+                } else {

                     devAdd.setDevno(tNcDeviceTemp.getDevno());

                 }

                 devAdd.setIp(tNcDeviceTemp.getIp());

@@ -1493,18 +1541,32 @@
                 devAdd.setBuildingid(tNcDeviceTemp.getBuildingid());

                 TBuilding buildingById = systemService.getBuildingById(tNcDeviceTemp.getBuildingid());

                 devAdd.setBuildingname(buildingById.getBuildingname());

-                if(tNcDeviceTemp.getDevtype().equals("R")){

+                if (tNcDeviceTemp.getDevtype().equals("R")) {

                     TNcDevice fdev = ncService.findDevById(tNcDeviceTemp.getFdevid());

-                    RedisUtil.set("ncdev_" + fdev.getDevphyid() + "_" + tNcDeviceTemp.getDevno(),String.valueOf(devAdd.getDeviceid()));

+                    RedisUtil.set("ncdev_" + fdev.getDevphyid() + "_" + tNcDeviceTemp.getDevno(), String.valueOf(devAdd.getDeviceid()));

                 }

-                ncService.saveDevice(devAdd);

+                boolean bool=ncService.saveDevice(devAdd);

+

+                if (bool) {

+                    HttpConnectionUtil util = new HttpConnectionUtil();

+

+                    Map<String, String> postmap = new HashMap<>();

+                    postmap.put("areaname", devAdd.getBuildingname());  //区域名称

+                    postmap.put("status", "1");   //状态

+                    postmap.put("devicename", devAdd.getDevname());  //设备名称

+                    postmap.put("devphyid", devAdd.getDevphyid());  //设备物理id

+                    postmap.put("source", "door");  //来源

+                    Gson gson = new Gson();

+                    String result = util.sendByPostJson(auditsysurl + "/register", gson.toJson(postmap));

+                    logger.info(result);

+                }

                 successCnt++;

             }

-            map.put("resultStr","共导入"+totCnt+"条数据,"+successCnt+"条数据成功,"+errCnt+"条数据失败!");

+            map.put("resultStr", "共导入" + totCnt + "条数据," + successCnt + "条数据成功," + errCnt + "条数据失败!");

             map.put("impDev_succ", "");

-        }catch (Exception e){

-            map.put("impDev_succ","导入失败");

-            logger.error("设备名单导入失败--"+e.getMessage());

+        } catch (Exception e) {

+            map.put("impDev_succ", "导入失败");

+            logger.error("设备名单导入失败--" + e.getMessage());

             flag = -2;

             map.put("flag", flag);

             return map;

diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
index 8d30168..ee55559 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -53,4 +53,6 @@
 
 spring.redis.database=2
 
+auditsys.url=http://1.10.10.76:8080/collect/device
+
 
diff --git a/src/main/resources/templates/doorlist/customer/form.html b/src/main/resources/templates/doorlist/customer/form.html
index bde6e88..6d5f56d 100644
--- a/src/main/resources/templates/doorlist/customer/form.html
+++ b/src/main/resources/templates/doorlist/customer/form.html
@@ -3,7 +3,7 @@
     <input name="custid" id="customer-custid" type="hidden"/>
 
     <div class="layui-form-item">
-        <label class="layui-form-label"><span style="color: red">* </span>市名卡号</label>
+        <label class="layui-form-label"><span style="color: red">* </span>市民卡号</label>
         <div class="layui-input-block">
             <input name="cardno" placeholder="请输入" type="text" class="layui-input" maxlength="20"
                    lay-verify="required|number" required/>
diff --git a/src/main/resources/templates/doorlist/customer/index.html b/src/main/resources/templates/doorlist/customer/index.html
index 9e29e75..15af95d 100644
--- a/src/main/resources/templates/doorlist/customer/index.html
+++ b/src/main/resources/templates/doorlist/customer/index.html
@@ -80,7 +80,7 @@
             cols: [
                 [
                     {field: 'custname', sort: true, title: '客户姓名'},
-                    {field: 'cardno', sort: true, title: '市名卡号'},
+                    {field: 'cardno', sort: true, title: '市民卡号'},
              //       {field: 'bankcardno', sort: true,  title: '银行卡号'},
                     /*{
                         field: 'checkstatus', title: '审核状态', align: 'center', width: 120, sort: true, templet: function (d) {