1
0

13 Commits 7f9856db7c ... 9755e03259

Autor SHA1 Nachricht Datum
  wulianwei 9755e03259 add:等保认证 vor 1 Woche
  wulianwei 2494b5e9f3 init vor 2 Monaten
  wulianwei c65b1c2588 init vor 4 Monaten
  zhouzeyu 24beb11fb3 添加gateWay和netMask字段,修改netty服务 vor 5 Monaten
  zhouzeyu 31cab4a81f 添加ipAddress字段,修改netty服务 vor 5 Monaten
  zhouzeyu 35a8d2d83e 添加netMac字段,修改netty服务 vor 5 Monaten
  zhouzeyu 9b976af65d 添加netMac字段,修改netty服务 vor 5 Monaten
  zhouzeyu 9e8258fa36 添加netMac字段,修改netty服务 vor 5 Monaten
  zhouzeyu 75e33bda25 添加netMac字段,修改netty服务 vor 5 Monaten
  wulianwei 4c7b8a23aa Merge branch 'master' into develop vor 5 Monaten
  wulianwei 7a9fd816be add netmac vor 5 Monaten
  zhouzeyu 2be4e60320 添加netMac字段,修改netty服务 vor 5 Monaten
  wulianwei fcae6b3b84 init vor 5 Monaten
32 geänderte Dateien mit 387 neuen und 290 gelöschten Zeilen
  1. 3 0
      .gitignore
  2. 0 8
      .idea/.gitignore
  3. 0 19
      .idea/compiler.xml
  4. 0 6
      .idea/encodings.xml
  5. 0 20
      .idea/jarRepositories.xml
  6. 0 12
      .idea/misc.xml
  7. 0 124
      .idea/uiDesigner.xml
  8. 0 6
      .idea/vcs.xml
  9. 0 0
      he1fuh9LSDW12357securemode2authTyperegnwlsignmethodhmacsha256random996instanceIdiot-060a0bgd-sslhe1fuh9LSDWiot-as-mqttcn-shanghaialiyuncscom443/.lck
  10. 2 1
      src/main/java/com/tuoren/forward/config/SaTokenConfigure.java
  11. 5 1
      src/main/java/com/tuoren/forward/config/amqp/AmqpClient1.java
  12. 5 1
      src/main/java/com/tuoren/forward/config/amqp/AmqpClient2.java
  13. 15 7
      src/main/java/com/tuoren/forward/controller/DeviceController.java
  14. 20 0
      src/main/java/com/tuoren/forward/controller/OpenController.java
  15. 20 6
      src/main/java/com/tuoren/forward/entity/Device.java
  16. 3 0
      src/main/java/com/tuoren/forward/entity/User.java
  17. 13 1
      src/main/java/com/tuoren/forward/entity/req/DeviceAddReq.java
  18. 36 0
      src/main/java/com/tuoren/forward/entity/req/DeviceEditReq.java
  19. 3 0
      src/main/java/com/tuoren/forward/entity/req/UserAddReq.java
  20. 12 0
      src/main/java/com/tuoren/forward/entity/resp/DeviceRelevancyResp.java
  21. 5 5
      src/main/java/com/tuoren/forward/netty/AES.java
  22. 103 49
      src/main/java/com/tuoren/forward/netty/MyServer.java
  23. 7 7
      src/main/java/com/tuoren/forward/netty/excepetion/NExcCode.java
  24. 28 8
      src/main/java/com/tuoren/forward/service/DeviceService.java
  25. 29 3
      src/main/java/com/tuoren/forward/service/UserService.java
  26. 18 0
      src/main/java/com/tuoren/forward/util/RemoteUtil.java
  27. 1 1
      src/main/resources/application.yml
  28. 2 0
      src/main/resources/db/migration/V1.0.3__device.sql
  29. 2 0
      src/main/resources/db/migration/V1.0.4__user.sql
  30. 39 3
      src/main/resources/mapper/DeviceMapper.xml
  31. 8 0
      src/main/resources/mapper/DeviceRelevancyMapper.xml
  32. 8 2
      src/main/resources/mapper/UserMapper.xml

+ 3 - 0
.gitignore

@@ -1,3 +1,6 @@
 /.settings
 /LOG_PATH_IS_UNDEFINED
 /target
+/.idea
+/he1fuh9LSDW12357securemode2authTyperegnwlsignmethodhmacsha256random996instanceIdiot-060a0bgd-sslhe1fuh9LSDWiot-as-mqttcn-shanghaialiyuncscom443
+.idea

+ 0 - 8
.idea/.gitignore

@@ -1,8 +0,0 @@
-# Default ignored files
-/shelf/
-/workspace.xml
-# Editor-based HTTP Client requests
-/httpRequests/
-# Datasource local storage ignored files
-/dataSources/
-/dataSources.local.xml

+ 0 - 19
.idea/compiler.xml

@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project version="4">
-  <component name="CompilerConfiguration">
-    <annotationProcessing>
-      <profile default="true" name="Default" enabled="true" />
-      <profile name="Maven default annotation processors profile" enabled="true">
-        <sourceOutputDir name="target/generated-sources/annotations" />
-        <sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
-        <outputRelativeToContentRoot value="true" />
-        <module name="forward" />
-      </profile>
-    </annotationProcessing>
-  </component>
-  <component name="JavacSettings">
-    <option name="ADDITIONAL_OPTIONS_OVERRIDE">
-      <module name="forward" options="-parameters" />
-    </option>
-  </component>
-</project>

+ 0 - 6
.idea/encodings.xml

@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project version="4">
-  <component name="Encoding">
-    <file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
-  </component>
-</project>

+ 0 - 20
.idea/jarRepositories.xml

@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project version="4">
-  <component name="RemoteRepositoriesConfiguration">
-    <remote-repository>
-      <option name="id" value="central" />
-      <option name="name" value="Maven Central repository" />
-      <option name="url" value="https://repo1.maven.org/maven2" />
-    </remote-repository>
-    <remote-repository>
-      <option name="id" value="jboss.community" />
-      <option name="name" value="JBoss Community repository" />
-      <option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
-    </remote-repository>
-    <remote-repository>
-      <option name="id" value="central" />
-      <option name="name" value="Central Repository" />
-      <option name="url" value="https://maven.aliyun.com/repository/public" />
-    </remote-repository>
-  </component>
-</project>

+ 0 - 12
.idea/misc.xml

@@ -1,12 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project version="4">
-  <component name="ExternalStorageConfigurationManager" enabled="true" />
-  <component name="MavenProjectsManager">
-    <option name="originalFiles">
-      <list>
-        <option value="$PROJECT_DIR$/pom.xml" />
-      </list>
-    </option>
-  </component>
-  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK" />
-</project>

+ 0 - 124
.idea/uiDesigner.xml

@@ -1,124 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project version="4">
-  <component name="Palette2">
-    <group name="Swing">
-      <item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
-        <default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
-      </item>
-      <item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
-        <default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
-      </item>
-      <item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
-        <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
-      </item>
-      <item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
-        <default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
-      </item>
-      <item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
-        <default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
-        <initial-values>
-          <property name="text" value="Button" />
-        </initial-values>
-      </item>
-      <item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
-        <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
-        <initial-values>
-          <property name="text" value="RadioButton" />
-        </initial-values>
-      </item>
-      <item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
-        <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
-        <initial-values>
-          <property name="text" value="CheckBox" />
-        </initial-values>
-      </item>
-      <item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
-        <default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
-        <initial-values>
-          <property name="text" value="Label" />
-        </initial-values>
-      </item>
-      <item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
-        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
-          <preferred-size width="150" height="-1" />
-        </default-constraints>
-      </item>
-      <item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
-        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
-          <preferred-size width="150" height="-1" />
-        </default-constraints>
-      </item>
-      <item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
-        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
-          <preferred-size width="150" height="-1" />
-        </default-constraints>
-      </item>
-      <item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
-        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
-          <preferred-size width="150" height="50" />
-        </default-constraints>
-      </item>
-      <item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
-        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
-          <preferred-size width="150" height="50" />
-        </default-constraints>
-      </item>
-      <item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
-        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
-          <preferred-size width="150" height="50" />
-        </default-constraints>
-      </item>
-      <item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
-        <default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
-      </item>
-      <item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
-        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
-          <preferred-size width="150" height="50" />
-        </default-constraints>
-      </item>
-      <item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
-        <default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
-          <preferred-size width="150" height="50" />
-        </default-constraints>
-      </item>
-      <item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
-        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
-          <preferred-size width="150" height="50" />
-        </default-constraints>
-      </item>
-      <item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
-        <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
-          <preferred-size width="200" height="200" />
-        </default-constraints>
-      </item>
-      <item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
-        <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
-          <preferred-size width="200" height="200" />
-        </default-constraints>
-      </item>
-      <item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
-        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
-      </item>
-      <item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
-        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
-      </item>
-      <item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
-        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
-      </item>
-      <item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
-        <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
-      </item>
-      <item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
-        <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
-          <preferred-size width="-1" height="20" />
-        </default-constraints>
-      </item>
-      <item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
-        <default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
-      </item>
-      <item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
-        <default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
-      </item>
-    </group>
-  </component>
-</project>

+ 0 - 6
.idea/vcs.xml

@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project version="4">
-  <component name="VcsDirectoryMappings">
-    <mapping directory="" vcs="Git" />
-  </component>
-</project>

+ 0 - 0
he1fuh9LSDW12357securemode2authTyperegnwlsignmethodhmacsha256random996instanceIdiot-060a0bgd-sslhe1fuh9LSDWiot-as-mqttcn-shanghaialiyuncscom443/.lck


+ 2 - 1
src/main/java/com/tuoren/forward/config/SaTokenConfigure.java

@@ -34,7 +34,8 @@ public class SaTokenConfigure {
 		"/swagger-ui/**",  //swagger
 		"/v3/**",  //swagger
 		"/favicon.ico",//swagger
-		"/open/**",//对外开放接口
+		"/open/**",//对外开放接口"
+			 "/open/getCaptcha"
 	};
 
 	/**

+ 5 - 1
src/main/java/com/tuoren/forward/config/amqp/AmqpClient1.java

@@ -330,7 +330,11 @@ public class AmqpClient1 {
     						mqttUtil.pub(t, mqttJson.toString());
     					}
     				}else {
-    					mqttUtil.pub(CommonConstant.MQTT_PUBLISH_PREFIX+hospitalCode, mqttJson.toString());
+    					if("8879".equals(hospitalCode)) {
+    						remoteUtil.postDeviceDataToHospital(mqttJson.toString());
+    					}else {
+    						mqttUtil.pub(CommonConstant.MQTT_PUBLISH_PREFIX+hospitalCode, mqttJson.toString());
+    					}
     				}
     			}
     		}

+ 5 - 1
src/main/java/com/tuoren/forward/config/amqp/AmqpClient2.java

@@ -337,7 +337,11 @@ public class AmqpClient2 {
     						mqttUtil.pub(t, mqttJson.toString());
     					}
     				}else {
-    					mqttUtil.pub(CommonConstant.MQTT_PUBLISH_PREFIX+hospitalCode, mqttJson.toString());
+    					if("8879".equals(hospitalCode)) {
+    						remoteUtil.postDeviceDataToHospital(mqttJson.toString());
+    					}else {
+    						mqttUtil.pub(CommonConstant.MQTT_PUBLISH_PREFIX+hospitalCode, mqttJson.toString());
+    					}
     				}
     			}
     		}

+ 15 - 7
src/main/java/com/tuoren/forward/controller/DeviceController.java

@@ -1,6 +1,7 @@
 package com.tuoren.forward.controller;
 
 
+import com.tuoren.forward.entity.req.*;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -13,12 +14,6 @@ import com.github.pagehelper.util.StringUtil;
 import com.tuoren.forward.annotation.HandleLog;
 import com.tuoren.forward.constant.CommonConstant;
 import com.tuoren.forward.entity.Device;
-import com.tuoren.forward.entity.req.DeviceAddReq;
-import com.tuoren.forward.entity.req.DeviceBindReq;
-import com.tuoren.forward.entity.req.DeviceRecordSearchReq;
-import com.tuoren.forward.entity.req.DeviceRecordSendReq;
-import com.tuoren.forward.entity.req.DeviceSearchReq;
-import com.tuoren.forward.entity.req.IdReq;
 import com.tuoren.forward.entity.resp.CountCategoryResp;
 import com.tuoren.forward.entity.resp.CountResp;
 import com.tuoren.forward.entity.resp.DeviceRecordProcessResp;
@@ -99,7 +94,7 @@ public class DeviceController {
     @ResponseBody
     @Operation(summary = "修改设备")
 	@Parameter(name="token",description = "token",required = true,in = ParameterIn.HEADER)
-	public Result edit(@RequestBody DeviceAddReq req){
+	public Result edit(@RequestBody DeviceEditReq req){
 		log.info("edit>>:{}",req);
 		if(StringUtil.isEmpty(req.getId())) {
 			return Result.fail(CommonConstant.LACK_PARAM);
@@ -221,4 +216,17 @@ public class DeviceController {
 		return deviceService.resendRecord(req);
 	}
 	
+	/**
+	 * 
+	 * @param req
+	 * @return
+	 */
+	@PostMapping("searchResendProcess")
+    @ResponseBody
+    @Operation(summary = "日志重发进度查询")
+	public ResultData<DeviceRecordProcessResp> searchResendProcess(@RequestBody IdReq req){
+		log.info("searchResendProcess>>:{}",req);
+		return deviceService.searchResendProcess(req.getId());
+	}
+	
 }

+ 20 - 0
src/main/java/com/tuoren/forward/controller/OpenController.java

@@ -23,6 +23,7 @@ import com.tuoren.forward.entity.resp.CaptchaResp;
 import com.tuoren.forward.service.HospitalService;
 import com.tuoren.forward.service.UserService;
 import com.tuoren.forward.util.AliyunMessageUtil;
+import com.tuoren.forward.util.RemoteUtil;
 import com.tuoren.forward.util.Result;
 import com.tuoren.forward.util.ResultData;
 import com.tuoren.forward.util.UUIDUtil;
@@ -56,6 +57,9 @@ public class OpenController {
 	@Autowired
 	AliyunMessageUtil aliyunMessageUtil; 
 	
+	@Autowired
+    RemoteUtil remoteUtil;
+	
 	private final String SECRET = "yunzhineng";
 	
 //	@PostMapping("addHospital")
@@ -131,6 +135,22 @@ public class OpenController {
 		return Result.success();
 	}
 	
+	@PostMapping("testSend")
+    @ResponseBody
+    @Operation(summary = "验证发送接口")
+	public Result testSend(@RequestBody String data) {
+		remoteUtil.postDeviceDataToHospital(data);
+		return Result.success();
+	}
+	
+	@PostMapping("testRecevice")
+    @ResponseBody
+    @Operation(summary = "验证接受接口")
+	public Result testRecevice(@RequestBody String data) {
+		System.out.println("===testRecevice==="+data);
+		return Result.success();
+	}
+	
 	
 	public static void main(String[] args) {
 		String content="test3&yunzhineng";

+ 20 - 6
src/main/java/com/tuoren/forward/entity/Device.java

@@ -1,7 +1,9 @@
 package com.tuoren.forward.entity;
 
 import io.swagger.v3.oas.annotations.media.Schema;
+
 import java.util.Date;
+
 import lombok.Data;
 
 @Data
@@ -13,9 +15,21 @@ public class Device {
     @Schema(description = "MAC")
     private String mac;
 
+    @Schema(description = "通信模块mac")
+    private String netMac;
+
+    @Schema(description = "网关")
+    private String gateWay;
+
+    @Schema(description = "子网掩码")
+    private String netMask;
+
+    @Schema(description = "ip范围")
+    private String ipAddress;
+
     @Schema(description = "设备名称")
     private String name;
-    
+
     @Schema(description = "设备别名")
     private String alias;
 
@@ -39,19 +53,19 @@ public class Device {
 
     @Schema(description = "租户ID")
     private String tenantId;
-    
+
     @Schema(description = "纬度")
     private String lat;
-    
+
     @Schema(description = "经度")
     private String lng;
-    
+
     @Schema(description = "地址")
     private String address;
-    
+
     @Schema(description = "误差半径,单位:米")
     private String radius;
-    
+
     @Schema(description = "当前数据")
     private String data;
 }

+ 3 - 0
src/main/java/com/tuoren/forward/entity/User.java

@@ -48,6 +48,9 @@ public class User {
     @Schema(description = "登录令牌")
     private String token;
     
+    @Schema(description = "无效登录次数")
+    private Integer invalidCount;
+    
     @Schema(description="角色ID, 'roleId1,roleId2'")
     private List<String> roleIds;
 }

+ 13 - 1
src/main/java/com/tuoren/forward/entity/req/DeviceAddReq.java

@@ -4,7 +4,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 
 @Data
-@Schema(description = "设备")
+@Schema(description = "设备添加")
 public class DeviceAddReq {
 
     @Schema(description = "ID")
@@ -13,6 +13,18 @@ public class DeviceAddReq {
     @Schema(description = "MAC")
     private String mac;
 
+    @Schema(description = "通信模块mac")
+    private String netMac;
+
+    @Schema(description = "网关")
+    private String gateWay;
+
+    @Schema(description = "子网掩码")
+    private String netMask;
+
+    @Schema(description = "ip范围")
+    private String ipAddress;
+
     @Schema(description = "设备名称")
     private String name;
 

+ 36 - 0
src/main/java/com/tuoren/forward/entity/req/DeviceEditReq.java

@@ -0,0 +1,36 @@
+package com.tuoren.forward.entity.req;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+@Data
+@Schema(description = "设备修改")
+public class DeviceEditReq {
+
+    @Schema(description = "ID")
+    private String id;
+
+    @Schema(description = "MAC")
+    private String mac;
+
+    @Schema(description = "通信模块mac")
+    private String netMac;
+
+    @Schema(description = "网关")
+    private String gateWay;
+
+    @Schema(description = "子网掩码")
+    private String netMask;
+
+    @Schema(description = "ip范围")
+    private String ipAddress;
+
+    @Schema(description = "SIM 卡号")
+    private String sim;
+
+    @Schema(description = "产品ID")
+    private String productId;
+
+    @Schema(description = "描述")
+    private String description;
+}

+ 3 - 0
src/main/java/com/tuoren/forward/entity/req/UserAddReq.java

@@ -36,6 +36,9 @@ public class UserAddReq {
     @Schema(description = "详细地址")
     private String address;
     
+    @Schema(description = "无效登录次数")
+    private Integer invalidCount;
+    
     @Schema(description="角色ID, 'roleId1,roleId2'")
     private List<String> roleIds;
 }

+ 12 - 0
src/main/java/com/tuoren/forward/entity/resp/DeviceRelevancyResp.java

@@ -20,6 +20,18 @@ public class DeviceRelevancyResp {
     @Schema(description = "MAC")
     private String mac;
 
+    @Schema(description = "通信模块mac")
+    private String netMac;
+
+    @Schema(description = "网关")
+    private String gateWay;
+
+    @Schema(description = "子网掩码")
+    private String netMask;
+
+    @Schema(description = "ip范围")
+    private String ipAddress;
+
     @Schema(description = "是否删除:, '0':未删除.’'1' 删除")
     private String isDelete;
 

+ 5 - 5
src/main/java/com/tuoren/forward/netty/AES.java

@@ -96,13 +96,13 @@ public class AES {
 //        json.put("deviceId", "11111");
 //        json.put("platform", "aliyun");
         json.put("version", 1);
-        json.put("networkType", "2");
+        json.put("networkType", "3");
         json.put("networkProtocol", 1);
         json.put("productId", "1dbfd476b7nm2");
-        json.put("deviceId", "3332583205340147");
-        json.put("sim", "898604C4192290736770");
-
-        json.put("userId", "6710");
+        json.put("deviceId", "02303B560DB60132");
+        json.put("sim", "898604C4192290738888");
+        json.put("netMac","64:e8:33:b3:8a:f4");
+        json.put("userId", "1000");
 
         System.out.println(json.toString());
         // 加密 

+ 103 - 49
src/main/java/com/tuoren/forward/netty/MyServer.java

@@ -135,7 +135,10 @@ class MyServerHandler extends ChannelInboundHandlerAdapter {
         byte[] resultByte = new byte[result.readableBytes()];
         result.readBytes(resultByte);
         result.release();
-
+        for (byte a : resultByte) {
+            System.out.printf("%02x", a);
+        }
+        System.out.println();
         String msgStr = AES.decrypt(resultByte, key);
         System.out.println("aes decrypt:" + msgStr);
         logger.info("aes decrypt:" + msgStr);
@@ -186,7 +189,7 @@ class MyServerHandler extends ChannelInboundHandlerAdapter {
             registLog.setStatus("2");//异常
             registLog.setMsg(e.getMessage());
             registLogMapper.insert(registLog);
-            logger.error("regist error:" + e);
+            logger.error("regist error" , e);
         }
         //执行加密操作
         byte[] resultRegister = AES.encrypt(jsonString, key);
@@ -216,8 +219,7 @@ class MyServerHandler extends ChannelInboundHandlerAdapter {
         //判断传入的version是0或者为空
         if (version == 0 || StrUtil.isBlank(String.valueOf(version))) {
             processVersionZero(paramJson, json);
-        }
-        else if (version == 1) {
+        } else if (version == 1) {
             //网络类型
             Integer networkCode = paramJson.getIntValue("networkType");
             NetworkType network = NetworkType.NetworkTypeName(networkCode);
@@ -225,7 +227,7 @@ class MyServerHandler extends ChannelInboundHandlerAdapter {
             String userId = paramJson.getString("userId");//1000
             //查询userId是否存在
             User userIdCode = userMapper.selectByCode(userId);
-            if (  userIdCode == null || StrUtil.isBlank(userIdCode.getCode())) {
+            if (userIdCode == null || StrUtil.isBlank(userIdCode.getCode())) {
                 return buildErrorResponse(NExcCode.ERROR_USERID, json);
             }
             //产品编号
@@ -240,6 +242,17 @@ class MyServerHandler extends ChannelInboundHandlerAdapter {
             String deviceName = paramJson.getString("deviceId");
             //SIM卡号
             String sim = paramJson.getString("sim");
+            //通信模块mac(这是传给你的字段,然后插入到数据库中)
+            String netMac = paramJson.getString("netMac");
+            //查询出来返回给他ip范围(需要就注册用,不需要就传"")
+            Device deviceMac = deviceMapper.selectByMac(deviceName);
+            //ip范围
+            String ipAddress = deviceMac == null?"":deviceMac.getIpAddress();
+            //网关
+            String gateWay = deviceMac == null?"":deviceMac.getGateWay();
+            //子网掩码
+            String netMask = deviceMac == null?"":deviceMac.getNetMask();
+
             //通过查询获取到参数
             String id = userIdCode.getId();
             //查找用户id
@@ -273,16 +286,19 @@ class MyServerHandler extends ChannelInboundHandlerAdapter {
                 return buildErrorResponse(NExcCode.ERROR_PLATFORM_NULL, json);
             }
             //添加修改设备
-            handleDevice(deviceName, sim, productId, id);
+            handleDevice(platform, deviceName, netMac, ipAddress, sim, productId, id);
+
             //通过平台进行设备注册
             switch (platform) {
                 case 1:
-                    handleAliYunRegistration(json, version, network, userId, productId, protocol, deviceName, platform, productKey);
+                    handleAliYunRegistration(json, version, network, userId, productId, protocol, deviceName, platform, productKey);//走的阿里云
                     break;
                 case 2:
                     return buildErrorResponse(NExcCode.ERROR_PLATFORM_TYPE, json);
                 case 3:
-                    handleLocalRegistration(json, paramJson, network, userId, productId, protocol, deviceName, wifi, deviceSecret, remoteAddress, remotePort);
+                    handleLocalRegistration(json, paramJson, network,
+                            userId, productId, protocol, deviceName,
+                            ipAddress,gateWay,netMask, wifi, deviceSecret, remoteAddress, remotePort);
                     break;
                 default:
                     return buildErrorResponse(NExcCode.ERROR_VERSION_TYPE, json);
@@ -291,22 +307,28 @@ class MyServerHandler extends ChannelInboundHandlerAdapter {
         return json.toString();
     }
 
+
     //处理版本1的local设备注册
-    private void handleLocalRegistration(JSONObject json, JSONObject paramJson, NetworkType network, String userId, String productId, NetworkProtocol protocol, String deviceName, String wifi, String deviceSecret, String remoteAddress, int remotePort) {
+    private void handleLocalRegistration(JSONObject json, JSONObject paramJson, NetworkType network, String userId,
+                                         String productId, NetworkProtocol protocol, String deviceName,
+                                         String ipAddress,String gateWay,String netMask, String wifi, String deviceSecret, String remoteAddress, int remotePort) {
         //WiFi注册
         if (NetworkType.WIFI.equals(network)) {
-            LocalReturnParam(paramJson, json, network, protocol, deviceName, userId, productId, remoteAddress, remotePort, deviceSecret);
+            LocalReturnParam(paramJson, json, network, protocol, deviceName,
+                    ipAddress,gateWay,netMask, userId, productId, remoteAddress, remotePort, deviceSecret);
             JSONArray wifiArray = JSON.parseArray(wifi);
             JSONArray transformWifiArray = WifiDataTrans.transformWifiArray(wifiArray);
             json.put("wifi", transformWifiArray);
         }
         // 4G注册
         else if (NetworkType.LTE.equals(network)) {
-            LocalReturnParam(paramJson, json, network, protocol, deviceName, userId, productId, remoteAddress, remotePort, deviceSecret);
+            LocalReturnParam(paramJson, json, network, protocol, deviceName,
+                    ipAddress,gateWay,netMask, userId, productId, remoteAddress, remotePort, deviceSecret);
         }
         // NB注册
         else if (NetworkType.NB_IOT.equals(network)) {
-            LocalReturnParam(paramJson, json, network, protocol, deviceName, userId, productId, remoteAddress, remotePort, deviceSecret);
+            LocalReturnParam(paramJson, json, network, protocol, deviceName,
+                    ipAddress,gateWay,netMask, userId, productId, remoteAddress, remotePort, deviceSecret);
         }
     }
 
@@ -334,6 +356,7 @@ class MyServerHandler extends ChannelInboundHandlerAdapter {
             json.put("productKey", productKey);
         }
     }
+
     //处理版本0的设备注册
     private void processVersionZero(JSONObject paramJson, JSONObject json) {
         String deviceName = paramJson.getString("deviceId"); //device表中的mac
@@ -350,32 +373,32 @@ class MyServerHandler extends ChannelInboundHandlerAdapter {
             json.put("deviceSecret", registData.getString("DeviceSecret"));
             json.put("productKey", registData.getString("ProductKey"));
         }
-        
-        Device device =  deviceMapper.selectByMac(deviceName);
-        if(device != null) {
-        	device.setSim(sim);
-        	if(StringUtils.isEmpty(userCode)) {
-            	User user = userMapper.selectByCode(userCode);
-            	if(user != null) {
-            		device.setTenantId(user.getId());
-            	}
-            	deviceMapper.updateByPrimaryKeySelective2(device);
+
+        Device device = deviceMapper.selectByMac(deviceName);
+        if (device != null) {
+            device.setSim(sim);
+            if (StringUtils.isEmpty(userCode)) {
+                User user = userMapper.selectByCode(userCode);
+                if (user != null) {
+                    device.setTenantId(user.getId());
+                }
+                deviceMapper.updateByPrimaryKeySelective2(device);
             }
-        }else {
-        	device = new Device();
-        	device.setId(UUIDUtil.get32UUID());
-        	device.setMac(deviceName);
-        	device.setSim(sim);
-        	device.setCreatetime(new Date());
-        	if(StringUtils.isEmpty(userCode)) {
-            	User user = userMapper.selectByCode(userCode);
-            	if(user != null) {
-            		device.setTenantId(user.getId());
-            	}
+        } else {
+            device = new Device();
+            device.setId(UUIDUtil.get32UUID());
+            device.setMac(deviceName);
+            device.setSim(sim);
+            device.setCreatetime(new Date());
+            if (StringUtils.isEmpty(userCode)) {
+                User user = userMapper.selectByCode(userCode);
+                if (user != null) {
+                    device.setTenantId(user.getId());
+                }
             }
-        	deviceMapper.insertSelective(device);
+            deviceMapper.insertSelective(device);
         }
-        
+
     }
 
     //截取deviceId
@@ -390,20 +413,23 @@ class MyServerHandler extends ChannelInboundHandlerAdapter {
     }
 
     //新增修改设备信息
-    private void handleDevice(String deviceName, String sim, String productId, String id) {
+    private void handleDevice(Integer platform, String deviceName, String netMac, String ipAddress, String sim, String productId, String id) {
         //查询数据库是否存在该设备
         Device deviceMac = deviceMapper.selectByMac(deviceName);
         if (deviceMac == null) {
-            //不存在,则新增设备
-            //添加操作
-            Device NewDevice = new Device();
-            NewDevice.setId(UUIDUtil.get32UUID());
-            NewDevice.setMac(deviceName);
-            NewDevice.setSim(sim);
-            NewDevice.setProductId(productId);
-            NewDevice.setCreatetime(new Date());
-            NewDevice.setTenantId(id);
-            deviceMapper.insertSelective(NewDevice);
+            Device newDevice = new Device();
+            newDevice.setId(UUIDUtil.get32UUID());
+            newDevice.setMac(deviceName);
+            newDevice.setSim(sim);
+            newDevice.setProductId(productId);
+            newDevice.setCreatetime(new Date());
+            newDevice.setTenantId(id);
+
+            if (platform == 3) {
+                newDevice.setNetMac(netMac);
+            }
+
+            deviceMapper.insertSelective(newDevice);
         } else {
             //如果存在,检查productId是否一致
             boolean needUpdate = false;
@@ -428,6 +454,16 @@ class MyServerHandler extends ChannelInboundHandlerAdapter {
                 deviceMac.setModifytime(new Date());
                 needUpdate = true;
             }
+
+            if (platform == 3) {
+                String deviceMacNetMac = deviceMac.getNetMac();
+                if (StrUtil.isBlank(deviceMacNetMac) || !netMac.equals(deviceMacNetMac)) {
+                    deviceMac.setNetMac(netMac);
+                    deviceMac.setModifytime(new Date());
+                    needUpdate = true;
+                }
+            }
+
             if (needUpdate) {
                 deviceMapper.updateByMac(deviceMac);
                 logger.debug("Device updated: {}", deviceMac);
@@ -436,15 +472,33 @@ class MyServerHandler extends ChannelInboundHandlerAdapter {
     }
 
     //Local 平台返回参数
-    private void LocalReturnParam(JSONObject paramJson, JSONObject json, NetworkType network, NetworkProtocol protocol, String deviceName, String userId, String productId, String remoteAddress, int remotePort, String deviceSecret) {
+    private void LocalReturnParam(JSONObject paramJson, JSONObject json, NetworkType network,
+                                  NetworkProtocol protocol, String deviceName,
+                                  String ipAddress,String gateWay,String netMask, String userId, String productId,
+                                  String remoteAddress, int remotePort, String deviceSecret) {
         json.put("code", NExcCode.SUCCESS.getCode());
         json.put("version", paramJson.getString("version"));
         json.put("platform", Platform.LOCAL.getCode());
         json.put("networkType", network.getCode());
         json.put("networkProtocol", protocol.getCode());
-        json.put("productId", paramJson.getString("productId"));
+        json.put("productId", productId);
         json.put("deviceId", deviceName);
-        json.put("userId", paramJson.getString("userId"));
+        if (StrUtil.isBlank(ipAddress)) {
+            json.put("ipAddress", "");
+        } else {
+            json.put("ipAddress", ipAddress);
+        }
+        if (StrUtil.isBlank(gateWay)) {
+            json.put("gateWay", "");
+        } else {
+            json.put("gateWay", gateWay);
+        }
+        if (StrUtil.isBlank(netMask)) {
+            json.put("netMask", "");
+        } else {
+            json.put("netMask", netMask);
+        }
+        json.put("userId", userId);
         json.put("remoteAddress", remoteAddress);
         json.put("remotePort", remotePort);
         json.put("deviceSecret", deviceSecret);

+ 7 - 7
src/main/java/com/tuoren/forward/netty/excepetion/NExcCode.java

@@ -13,13 +13,13 @@ import lombok.Getter;
 @Getter
 public enum NExcCode {
     SUCCESS(200,"成功"),
-    ERROR_PARAM(400,"Parameter null"),
-    ERROR_USERID(401,"userId not exist"),
-    ERROR_NETWORK_TYPE(402,"network no exist"),
-    ERROR_VERSION_TYPE(403,"version no exist"),
-    ERROR_PLATFORM_TYPE(404,"platform no exist"),
-    ERROR_PLATFORM_NULL(404,"platform null"),
-    ERROR_PRODUCTID(405,"productId no exist");
+    ERROR_PARAM(400,"参数为空"),
+    ERROR_USERID(401,"用户编码不存在"),
+    ERROR_NETWORK_TYPE(402,"网络类型不存在"),
+    ERROR_VERSION_TYPE(403,"版本号不存在"),
+    ERROR_PLATFORM_TYPE(404,"平台不存在"),
+    ERROR_PLATFORM_NULL(404,"平台为空"),
+    ERROR_PRODUCTID(405,"产品id不存在");
 
 
 

+ 28 - 8
src/main/java/com/tuoren/forward/service/DeviceService.java

@@ -5,6 +5,7 @@ import java.util.List;
 import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 
+import com.tuoren.forward.entity.req.*;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -24,11 +25,6 @@ import com.tuoren.forward.constant.CommonConstant;
 import com.tuoren.forward.entity.Device;
 import com.tuoren.forward.entity.User;
 import com.tuoren.forward.entity.dto.DeviceDto;
-import com.tuoren.forward.entity.req.DeviceAddReq;
-import com.tuoren.forward.entity.req.DeviceBindReq;
-import com.tuoren.forward.entity.req.DeviceRecordSearchReq;
-import com.tuoren.forward.entity.req.DeviceRecordSendReq;
-import com.tuoren.forward.entity.req.DeviceSearchReq;
 import com.tuoren.forward.entity.resp.CountCategoryResp;
 import com.tuoren.forward.entity.resp.CountResp;
 import com.tuoren.forward.entity.resp.DeviceRecordProcessResp;
@@ -124,7 +120,7 @@ public class DeviceService {
 	 * @return Result
 	 * @title 修改设备
 	 */
-	public Result edit(DeviceAddReq req) {
+	public Result edit(DeviceEditReq req) {
 		Date date = new Date();
 		Device device = new Device();
 		BeanUtils.copyProperties(req, device);
@@ -279,8 +275,10 @@ public class DeviceService {
 				|| StringUtils.isBlank(req.getUserCode())) {
 			return ResultData.failNull(CommonConstant.LACK_PARAM);
 		}
-		DeviceRecordProcessResp resp = new DeviceRecordProcessResp();
 		User user = userMapper.selectByCode(req.getUserCode());	
+		if(user == null) {
+			return ResultData.failNull("不存在该用户,检查用户编码");
+		}
 		String processKey = UUIDUtil.get32UUID();
 		Runnable task = () -> {
 			Query query = new Query();
@@ -332,10 +330,32 @@ public class DeviceService {
 				}
 			}
 		};
-		resp.setProcessKey(processKey);
 		new Thread(task).start();
+		DeviceRecordProcessResp resp = new DeviceRecordProcessResp();
+		resp.setProcessKey(processKey);
+		return ResultData.success(resp);
+	}
+	
+	/**
+	 * @return
+	 * @title 日志重发进度
+	 */
+	public ResultData<DeviceRecordProcessResp> searchResendProcess(String token) {
+		if (StringUtils.isBlank(token)) {
+			return ResultData.failNull(CommonConstant.LACK_PARAM);
+		}
+		DeviceRecordProcessResp resp = new DeviceRecordProcessResp();
+		resp.setProcessKey(token);
+		String proStr = (String)redisTemplate.opsForHash().get(CommonConstant.LOG_RESERND_REDIS_PROCESS, token);
+		if(StringUtils.isBlank(proStr)) {
+			return ResultData.success(resp,"传输结束");
+		}
+		JSONObject jdata = JSONObject.parseObject(proStr);
+		resp.setTotal(jdata.getInteger("total"));
+		resp.setSendNum(jdata.getInteger("sendNum"));
 		return ResultData.success(resp);
 	}
 
 
+
 }

+ 29 - 3
src/main/java/com/tuoren/forward/service/UserService.java

@@ -39,11 +39,14 @@ import com.tuoren.forward.util.ResultPage;
 import com.tuoren.forward.util.UUIDUtil;
 
 import cn.dev33.satoken.stp.StpUtil;
+import cn.hutool.Hutool;
 import cn.hutool.captcha.generator.MathGenerator;
+import cn.hutool.core.util.ReUtil;
 
 @Service
 public class UserService {
-	
+	private  final  Integer MAXCOUNT = 5;
+	private  final  Integer PWDLEN = 8;
 	@Autowired
 	RedisTemplate<String, Object> redisTemplate;
 	
@@ -81,9 +84,25 @@ public class UserService {
 		if(!mg.verify(verifyCode, captchaCode)) {
 			return ResultData.failNull("验证码错误");
 		}
+		if(req.getPassword().length()<8) {
+			return ResultData.failNull("密码长度不得小于8位");
+		}
+		if(!ReUtil.isMatch("^(?=.*[0-9])(?=.*[a-zA-Z])(?=.*[^a-zA-Z0-9]).+$", req.getPassword())) {
+			return ResultData.failNull("密码要包含特殊字符字母和数字");
+		}
 		User loginUser = userMapper.selectByUsername(req.getUsername());
-		if(loginUser == null || !MD5Util.encode32(req.getPassword()).equals(loginUser.getPassword())) {
-			return ResultData.failNull("用户名或密码错误");
+		if(loginUser == null) {
+			return ResultData.failNull("用户不存在");
+		}
+		if(!MD5Util.encode32(req.getPassword()).equals(loginUser.getPassword())) {
+			Integer invalidCount = loginUser.getInvalidCount()+1;
+			if(invalidCount > MAXCOUNT) {
+				return ResultData.failNull("密码次数太多,请联系管理员解锁");
+			}else {
+				loginUser.setInvalidCount(invalidCount);
+				userMapper.updateByPrimaryKeySelective(loginUser);
+				return ResultData.failNull("密码错误,还有"+(MAXCOUNT-invalidCount)+"次机会");
+			}
 		}
 		Date date= new Date();
 		List<String> roleIds = roleMapper.selectIdByUserId(loginUser.getId());
@@ -97,6 +116,7 @@ public class UserService {
 		user.setId(loginUser.getId());
 		user.setLasttime(date);
 		user.setToken(token);
+		user.setInvalidCount(0);
 		userMapper.updateByPrimaryKeySelective(user);
 		
 		if(logMapper.existLoginTodayByUseid(user.getId()) == null) {
@@ -354,6 +374,12 @@ public class UserService {
 		User user = new User();
 		BeanUtils.copyProperties(req, user);
 		if(!StringUtils.isEmpty(user.getPassword())) {
+			if(req.getPassword().length()<8) {
+				return ResultData.failNull("密码长度不得小于8位");
+			}
+			if(!ReUtil.isMatch("^(?=.*[0-9])(?=.*[a-zA-Z])(?=.*[^a-zA-Z0-9]).+$", req.getPassword())) {
+				return ResultData.failNull("密码要包含特殊字符字母和数字");
+			}
 			user.setPassword(MD5Util.encode32(user.getPassword()));
 		}
 		userMapper.updateByPrimaryKeySelective(user);

+ 18 - 0
src/main/java/com/tuoren/forward/util/RemoteUtil.java

@@ -13,6 +13,8 @@ import org.springframework.web.client.RestTemplate;
 import com.alibaba.fastjson2.JSON;
 import com.alibaba.fastjson2.JSONArray;
 import com.alibaba.fastjson2.JSONObject;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
 
 @Component
 public class RemoteUtil {
@@ -101,5 +103,21 @@ public class RemoteUtil {
 		}
 		return null;
 	}
+	
+	public JSONObject postDeviceDataToHospital(String data) {
+
+		HttpHeaders headers = new HttpHeaders();
+	    headers.setContentType(MediaType.APPLICATION_JSON);
+	    
+		HttpEntity<String> request = new HttpEntity<String>(data, headers);
+		String result = restTemplate.postForObject("https://nuc.xzfkyy.cn:8090/gateway/ztb/xzyy/acceptance", request, String.class);
+//		String result = restTemplate.postForObject("http://192.168.104.3:8585/open/testRecevice", request, String.class);
+		System.out.println("result========="+result);
+		JSONObject json = JSONObject.parseObject(result);
+		if(json.containsKey("data")) {
+			return json.getJSONObject("data");
+		}
+		return null;
+	}
 
 }

+ 1 - 1
src/main/resources/application.yml

@@ -112,7 +112,7 @@ register:
 
 #阿里云配置
 aliyun1:
-  enable: true
+  enable: false
   accessKey: LTAI4G7FA9ytMc76oNkJ45YJ
   accessSecret: R7hOvMfiHb0PYroDqUDXAYgB9htQss
   consumerGroupId: Zlpp6svZNbJN4slY0rwJ000100

+ 2 - 0
src/main/resources/db/migration/V1.0.3__device.sql

@@ -0,0 +1,2 @@
+ALTER TABLE `forward`.`device` 
+ADD COLUMN `net_mac` VARCHAR(45) NULL COMMENT '通信模块mac' AFTER `data`;

+ 2 - 0
src/main/resources/db/migration/V1.0.4__user.sql

@@ -0,0 +1,2 @@
+ALTER TABLE `forward`.`user` 
+ADD COLUMN `invalid_count` INT NULL DEFAULT 0 COMMENT '无效登录次数' AFTER `token`;

+ 39 - 3
src/main/resources/mapper/DeviceMapper.xml

@@ -4,6 +4,10 @@
     <resultMap id="BaseResultMap" type="com.tuoren.forward.entity.Device">
         <id column="id" jdbcType="VARCHAR" property="id"/>
         <result column="mac" jdbcType="VARCHAR" property="mac"/>
+        <result column="net_mac" jdbcType="VARCHAR" property="netMac"/>
+        <result column="gate_way" jdbcType="VARCHAR" property="gateWay"/>
+        <result column="net_mask" jdbcType="VARCHAR" property="netMask"/>
+        <result column="ip_address" jdbcType="VARCHAR" property="ipAddress"/>
         <result column="name" jdbcType="VARCHAR" property="name"/>
         <result column="alias" jdbcType="VARCHAR" property="alias"/>
         <result column="is_delete" jdbcType="CHAR" property="isDelete"/>
@@ -23,7 +27,7 @@
     </resultMap>
 
     <sql id="Base_Column_List">
-        id, mac, name, is_delete, sim, product_id, description, createtime, modifytime, tenant_id
+        id, mac, net_mac,gate_way,net_mask,ip_address,name, is_delete, sim, product_id, description, createtime, modifytime, tenant_id
     </sql>
     <sql id="Blob_Column_List">
         data
@@ -129,6 +133,12 @@
             <if test="mac != null">
                 mac,
             </if>
+            <if test="ipAddress != null">
+                ip_address,
+            </if>
+            <if test="netMac != null">
+                net_mac,
+            </if>
             <if test="name != null">
                 name,
             </if>
@@ -179,6 +189,12 @@
             <if test="mac != null">
                 #{mac,jdbcType=VARCHAR},
             </if>
+            <if test="netMac != null">
+                #{netMac,jdbcType=VARCHAR},
+            </if>
+            <if test="ipAddress != null">
+                #{ipAddress,jdbcType=VARCHAR},
+            </if>
             <if test="name != null">
                 #{name,jdbcType=VARCHAR},
             </if>
@@ -229,8 +245,17 @@
             <if test="mac != null">
                 mac = #{mac,jdbcType=VARCHAR},
             </if>
-            <if test="name != null">
-                name = #{name,jdbcType=VARCHAR},
+            <if test="netMac != null">
+                net_mac = #{netMac,jdbcType=VARCHAR},
+            </if>
+            <if test="gateWay != null">
+                gate_way = #{gateWay,jdbcType=VARCHAR},
+            </if>
+            <if test="netMask != null">
+                net_mask = #{netMask,jdbcType=VARCHAR},
+            </if>
+            <if test="ipAddress != null">
+                ip_address = #{ipAddress,jdbcType=VARCHAR},
             </if>
             <if test="alias != null">
                 alias = #{alias,jdbcType=VARCHAR},
@@ -289,6 +314,12 @@
             <if test="sim != null">
                 sim = #{sim,jdbcType=VARCHAR},
             </if>
+            <if test="netMac != null">
+                net_mac = #{netMac,jdbcType=VARCHAR},
+            </if>
+            <if test="ipAddress != null">
+                ip_address = #{ipAddress,jdbcType=VARCHAR},
+            </if>
             <if test="productId != null">
                 product_id = #{productId,jdbcType=VARCHAR},
             </if>
@@ -325,6 +356,9 @@
             <if test="mac != null">
                 mac = #{mac,jdbcType=VARCHAR},
             </if>
+            <if test="netMac != null">
+                net_mac = #{netMac,jdbcType=VARCHAR},
+            </if>
             <if test="name != null">
                 name = #{name,jdbcType=VARCHAR},
             </if>
@@ -373,6 +407,7 @@
     <update id="updateByPrimaryKeyWithBLOBs" parameterType="com.tuoren.forward.entity.Device">
         update device
         set mac         = #{mac,jdbcType=VARCHAR},
+            net_mac      = #{netMac,jdbcType=VARCHAR},
             name        = #{name,jdbcType=VARCHAR},
             alias       = #{alias,jdbcType=VARCHAR},
             is_delete   = #{isDelete,jdbcType=CHAR},
@@ -392,6 +427,7 @@
     <update id="updateByPrimaryKey" parameterType="com.tuoren.forward.entity.Device">
         update device
         set mac         = #{mac,jdbcType=VARCHAR},
+            net_mac      = #{netMac,jdbcType=VARCHAR},
             name        = #{name,jdbcType=VARCHAR},
             alias       = #{alias,jdbcType=VARCHAR},
             is_delete   = #{isDelete,jdbcType=CHAR},

+ 8 - 0
src/main/resources/mapper/DeviceRelevancyMapper.xml

@@ -4,6 +4,10 @@
     <resultMap id="BaseResultMap" type="com.tuoren.forward.entity.resp.DeviceRelevancyResp">
         <id column="deivce_id" jdbcType="VARCHAR" property="deviceId"/>
         <result column="mac" jdbcType="VARCHAR" property="mac"/>
+        <result column="net_mac" jdbcType="VARCHAR" property="netMac"/>
+        <result column="gate_way" jdbcType="VARCHAR" property="gateWay"/>
+        <result column="net_mask" jdbcType="VARCHAR" property="netMask"/>
+        <result column="ip_address" jdbcType="VARCHAR" property="ipAddress"/>
         <result column="is_delete" jdbcType="VARCHAR" property="isDelete"/>
         <result column="sim" jdbcType="VARCHAR" property="sim"/>
         <result column="description" jdbcType="VARCHAR" property="description"/>
@@ -21,6 +25,10 @@
         select
         d.id as deivce_id,
         d.mac as mac,
+        d.net_mac,
+        d.gate_way,
+        d.net_mask,
+        d.ip_address as ip_address,
         d.is_delete as is_delete,
         d.sim as sim,
         d.description as description,

+ 8 - 2
src/main/resources/mapper/UserMapper.xml

@@ -14,9 +14,11 @@
     <result column="code" jdbcType="VARCHAR" property="code" />
     <result column="region_code" jdbcType="VARCHAR" property="regionCode" />
     <result column="address" jdbcType="VARCHAR" property="address" />
+    <result column="token" jdbcType="VARCHAR" property="address" />
+    <result column="invalid_count" jdbcType="INTEGER" property="invalidCount" />
   </resultMap>
   <sql id="Base_Column_List">
-    id, username, password, mobile, email, salt, enabled, createtime, lasttime,code,region_code,address,token
+    id, username, password, mobile, email, salt, enabled, createtime, lasttime,code,region_code,address,token,invalid_count
   </sql>
   <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
     select 
@@ -213,6 +215,9 @@
       <if test="token != null">
         token = #{token,jdbcType=VARCHAR},
       </if>
+      <if test="invalidCount != null">
+        invalid_count = #{invalidCount,jdbcType=INTEGER},
+      </if>
     </set>
     where id = #{id,jdbcType=VARCHAR}
   </update>
@@ -229,7 +234,8 @@
       code = #{code,jdbcType=VARCHAR},
       region_code = #{regionCode,jdbcType=VARCHAR},
       address = #{address,jdbcType=VARCHAR},
-      token = #{token,jdbcType=VARCHAR}
+      token = #{token,jdbcType=VARCHAR},
+      invalid_count = #{invalidCount,jdbcType=INTEGER}
     where id = #{id,jdbcType=VARCHAR}
   </update>
 </mapper>