hasan 2 år sedan
förälder
incheckning
4c0ebb5e1f

+ 0 - 1
pom.xml

@@ -40,7 +40,6 @@
40 40
             <artifactId>mybatis-plus-generator</artifactId>
41 41
             <version>3.5.1</version>
42 42
         </dependency>
43
-
44 43
         <dependency>
45 44
             <groupId>org.springframework.boot</groupId>
46 45
             <artifactId>spring-boot-devtools</artifactId>

+ 5 - 4
src/main/java/com/szls/nstths/controller/DataController.java

@@ -22,6 +22,7 @@ public class DataController {
22 22
 
23 23
     /**
24 24
      * 检测后数据
25
+     *
25 26
      * @param teData
26 27
      * @return
27 28
      */
@@ -32,8 +33,8 @@ public class DataController {
32 33
         if (inum < 0) {
33 34
             return "fail";
34 35
         }
35
-        if(inum == 0){ //打点两次完毕 计算体积
36
-        	teDataService.calculateVolume(teData.getTaskID());
36
+        if (inum == 0) { //打点两次完毕 计算体积
37
+            teDataService.calculateVolume(teData.getTaskID());
37 38
         }
38 39
         return "success";
39 40
     }
@@ -46,7 +47,7 @@ public class DataController {
46 47
     public void scanning(@RequestParam(value = "height", defaultValue = "35") double height,
47 48
                          @RequestParam(value = "diameter ", defaultValue = "12") double diameter) {
48 49
 
49
-        logger.info("{},{}",height,diameter);
50
-        teDataService.scanTask(diameter,height);
50
+        logger.info("scanning height{},diameter{}", height, diameter);
51
+        teDataService.scanTask(diameter, height);
51 52
     }
52 53
 }

+ 1 - 1
src/main/java/com/szls/nstths/controller/UserController.java

@@ -2,7 +2,6 @@ package com.szls.nstths.controller;
2 2
 
3 3
 
4 4
 import com.szls.nstths.mapper.UserMapper;
5
-import com.szls.nstths.service.TeDataService;
6 5
 import org.slf4j.Logger;
7 6
 import org.slf4j.LoggerFactory;
8 7
 import org.springframework.beans.factory.annotation.Autowired;
@@ -18,6 +17,7 @@ public class UserController {
18 17
     private static final Logger logger = LoggerFactory.getLogger(UserController.class);
19 18
 
20 19
     private UserMapper userMapper;
20
+
21 21
     @Autowired
22 22
     public void setUserMapper(UserMapper userMapper) {
23 23
         this.userMapper = userMapper;

+ 2 - 2
src/main/java/com/szls/nstths/entity/ReMsg.java

@@ -9,8 +9,6 @@ import lombok.Data;
9 9
 @Data
10 10
 @TableName("re_msg")
11 11
 public class ReMsg {
12
-    @TableId(type = IdType.AUTO, value = "id")
13
-    private Long id;
14 12
     /**
15 13
      * code=0, msg='操作成功'
16 14
      * code=1, msg='设备正忙'
@@ -20,4 +18,6 @@ public class ReMsg {
20 18
     String code;
21 19
     String msg;
22 20
     String data;
21
+    @TableId(type = IdType.AUTO, value = "id")
22
+    private Long id;
23 23
 }

+ 1 - 1
src/main/java/com/szls/nstths/entity/STask.java

@@ -13,7 +13,7 @@ import java.util.Date;
13 13
 public class STask {
14 14
     @TableId(type = IdType.AUTO, value = "id")
15 15
     private Long id;
16
-    private String describe;
16
+    private String depict;
17 17
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
18 18
     private Date ctime;
19 19
 }

+ 10 - 0
src/main/java/com/szls/nstths/mapper/ReMsgMapper.java

@@ -0,0 +1,10 @@
1
+package com.szls.nstths.mapper;
2
+
3
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4
+import com.szls.nstths.entity.ReMsg;
5
+import org.springframework.stereotype.Component;
6
+
7
+@Component(value = "reMsgMapper")
8
+public interface ReMsgMapper extends BaseMapper<ReMsg> {
9
+
10
+}

+ 0 - 1
src/main/java/com/szls/nstths/mapper/STaskMapper.java

@@ -2,7 +2,6 @@ package com.szls.nstths.mapper;
2 2
 
3 3
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4 4
 import com.szls.nstths.entity.STask;
5
-import com.szls.nstths.entity.TeData;
6 5
 import org.springframework.stereotype.Component;
7 6
 
8 7
 @Component(value = "sTaskMapper")

+ 0 - 1
src/main/java/com/szls/nstths/mapper/TeDataMapper.java

@@ -2,7 +2,6 @@ package com.szls.nstths.mapper;
2 2
 
3 3
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4 4
 import com.szls.nstths.entity.TeData;
5
-import com.szls.nstths.entity.User;
6 5
 import org.springframework.stereotype.Component;
7 6
 
8 7
 @Component(value = "teDataMapper")

+ 11 - 10
src/main/java/com/szls/nstths/service/TeDataService.java

@@ -1,6 +1,5 @@
1 1
 package com.szls.nstths.service;
2 2
 
3
-import com.szls.nstths.entity.ReMsg;
4 3
 import com.szls.nstths.entity.TeData;
5 4
 import org.springframework.stereotype.Service;
6 5
 
@@ -11,35 +10,37 @@ import org.springframework.stereotype.Service;
11 10
  * 1. equipmentTestingIsReady
12 11
  * 2. equipmentTestingStart
13 12
  * 3. equipmentTestingEnd
14
- *
13
+ * <p>
15 14
  * equipmentTestingContinue
16 15
  * equipmentTestingResult
17 16
  */
18 17
 
19
-@Service(value = "teDataService")
20
-public interface TeDataService {
21 18
 
19
+public interface TeDataService {
22 20
 
23 21
 
24 22
     /**
25 23
      * 第一次待打点
26
-     * @param height 
27
-     * @param diameter 
24
+     *
25
+     * @param high
26
+     * @param diameter
28 27
      */
29
-    public void scanTask(double diameter, double high);
28
+    void scanTask(double diameter, double high);
30 29
 
31 30
     /**
32 31
      * 第二次待打点
32
+     *
33 33
      * @param teData
34 34
      * @return 数据库影响条数
35 35
      */
36
-    public int scanTask(TeData teData);
37
-    
36
+    int scanTask(TeData teData);
37
+
38 38
 
39 39
     /**
40 40
      * 计算体积
41
+     *
41 42
      * @param taskID
42 43
      */
43
-	public void calculateVolume(String taskID);
44
+    void calculateVolume(String taskID);
44 45
 
45 46
 }

+ 62 - 51
src/main/java/com/szls/nstths/service/impl/Algorithm.java

@@ -1,22 +1,22 @@
1 1
 package com.szls.nstths.service.impl;
2 2
 
3 3
 import java.math.BigDecimal;
4
+import java.math.RoundingMode;
4 5
 import java.util.ArrayList;
5 6
 import java.util.Collections;
6 7
 import java.util.List;
7 8
 
8
-import org.junit.jupiter.api.Test;
9
-
10 9
 public class Algorithm {
11 10
 
12
-	
13
-	/**
14
-	 * 打点要发送的角度
15
-	 * @param diameter
16
-	 * @param high
17
-	 * @return
18
-	 */
19
-	public static String getAveragePosition(double diameter, double high) {
11
+
12
+    /**
13
+     * 打点要发送的角度
14
+     *
15
+     * @param diameter
16
+     * @param high
17
+     * @return
18
+     */
19
+    public static String getAveragePosition(double diameter, double high) {
20 20
         StringBuffer sb = new StringBuffer();
21 21
 
22 22
         double x1 = 0;
@@ -105,21 +105,22 @@ public class Algorithm {
105 105
         //System.out.println(sb);
106 106
         System.out.println(sb);
107 107
         return sb.toString();
108
-    
109
-	}
110
-	
111
-	
112
-	/**
113
-	 * 计算  以粮面为基准面的高
114
-	 * @param list
115
-	 * @return
116
-	 */
117
-	public static double zHeight(String rotationxy,double diameter, double high) {
118
-        
119
-		List<Double> zList = new ArrayList<Double>();
120
-		
108
+
109
+    }
110
+
111
+
112
+    /**
113
+     * 计算  以粮面为基准面的高
114
+     *
115
+     * @param rotationxy
116
+     * @return
117
+     */
118
+    public static double zHeight(String rotationxy, double diameter, double high) {
119
+
120
+        List<Double> zList = new ArrayList<Double>();
121
+
121 122
         // logger.info("zHeight - list",list);
122
-		double AC = high;
123
+        double AC = high;
123 124
         double B1C = 0;//设备和粮面点之间的距离
124 125
         double A1B1 = 0;//粮面到设备的水平距离
125 126
         double z = 0; //实际点的坐标的z轴
@@ -128,17 +129,17 @@ public class Algorithm {
128 129
         double verticalAngle = 0;//垂直角度
129 130
         double levelAngle = 0;//水平角度
130 131
         double realHypotenuse = 0;//返回的距离
131
-        
132
-		
133
-		//  "18,7,17.88 - 19,6,28.88 - 17,4,39.88"  水平角度,垂直角度,返回距离 - 
134
-		String[] split = rotationxy.split("-");
135
-		for (int i = 0; i < split.length; i++) {
136
-			String[] split1 = split[i].split(",");
137
-			levelAngle = Double.parseDouble(split1[0]);
138
-			verticalAngle = Double.parseDouble(split1[1]);
139
-			realHypotenuse = Double.parseDouble(split1[2]);
140
-			
141
-			//将垂直的角度转化为弧度
132
+
133
+
134
+        //  "18,7,17.88 - 19,6,28.88 - 17,4,39.88"  水平角度,垂直角度,返回距离 -
135
+        String[] split = rotationxy.split("-");
136
+        for (int i = 0; i < split.length; i++) {
137
+            String[] split1 = split[i].split(",");
138
+            levelAngle = Double.parseDouble(split1[0]);
139
+            verticalAngle = Double.parseDouble(split1[1]);
140
+            realHypotenuse = Double.parseDouble(split1[2]);
141
+
142
+            //将垂直的角度转化为弧度
142 143
             double verticalAngleRadians = Math.toRadians(verticalAngle);
143 144
             String verticalAngleS = String.format("%.2f%n", Math.sin(verticalAngleRadians));
144 145
             double sinc = new Double(verticalAngleS);
@@ -149,14 +150,14 @@ public class Algorithm {
149 150
 
150 151
             String sinLevel = String.format("%.2f%n", Math.sin(Math.abs(levelAngle)));
151 152
             double sinLevelc = new Double(sinLevel);
152
-            
153
+
153 154
             /*
154 155
              * 对比实际的A1B1与打到墙上时最大的这个边进行比较 如果A1B1小于这个最大边则可取
155 156
              * 如果A1B1大于或等于这个最大的边 则打到了墙上 舍去
156 157
              * */
157
-           //打到墙上 最大的边
158
+            //打到墙上 最大的边
158 159
             double maxLength = sinLevelc * diameter;
159
-            
160
+
160 161
             if (A1B1 < maxLength) {
161 162
                 //实际打在粮面上的点的坐标
162 163
                 String verticalAngleC = String.format("%.2f%n", Math.cos(verticalAngleRadians));
@@ -169,9 +170,9 @@ public class Algorithm {
169 170
 
170 171
                 zList.add(z);
171 172
             }
172
-		}
173
-		
174
-		zMax = Collections.max(zList);
173
+        }
174
+
175
+        zMax = Collections.max(zList);
175 176
         zHigh = AC - zMax;
176 177
         return zHigh;
177 178
 		
@@ -199,9 +200,9 @@ public class Algorithm {
199 200
             double sinLevelc = new Double(sinLevel);
200 201
 
201 202
             *//**
202
-             * 对比实际的A1B1与打到墙上时最大的这个边进行比较 如果A1B1小于这个最大边则可取
203
-             * 如果A1B1大于或等于这个最大的边 则打到了墙上 舍去
204
-             *//*
203
+         * 对比实际的A1B1与打到墙上时最大的这个边进行比较 如果A1B1小于这个最大边则可取
204
+         * 如果A1B1大于或等于这个最大的边 则打到了墙上 舍去
205
+         *//*
205 206
             //打到墙上 最大的边
206 207
             double maxLength = sinLevelc * diameter;
207 208
 
@@ -223,15 +224,14 @@ public class Algorithm {
223 224
         return zHigh;
224 225
 */
225 226
     }
226
-	
227
-	
228
-	
229
-	/**
227
+
228
+
229
+    /**
230 230
      * 计算体积
231 231
      *
232 232
      * @param zList 粮面高集合(z值的集合)
233 233
      */
234
-    public static double calculateVolume(List<Double> zList,double diameter,double h1,double h2) {
234
+    public static double calculateVolume(List<Double> zList, double diameter, double h1, double h2) {
235 235
 
236 236
         //17.1  18.3  19.2  18.3    20.1  16.4  19.8  16.7  19.0  18.9
237 237
         Double zMin = Collections.min(zList); //z的最小值
@@ -257,8 +257,19 @@ public class Algorithm {
257 257
         double v2 = 3.14 * (diameter / 2) * (diameter / 2) * (zMin - h2 - h1);
258 258
         double v3 = (3.14 * (diameter / 2) * (diameter / 2) * h1) / 3;
259 259
         double vv = v1 + v2 + v3;
260
-        BigDecimal bdv = new BigDecimal(vv);
261
-        double v = bdv.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
260
+        BigDecimal bdv = BigDecimal.valueOf(vv);
261
+        //double v = bdv.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
262
+        double v = bdv.setScale(2, RoundingMode.HALF_UP).doubleValue();
262 263
         return v;
263 264
     }
265
+
266
+
267
+    public static void main(String[] args) {
268
+
269
+        BigDecimal bdv = BigDecimal.valueOf(12.125323);
270
+        //BigDecimal bdv = new BigDecimal(vv);
271
+        //double v = bdv.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
272
+        double v = bdv.setScale(2, RoundingMode.HALF_UP).doubleValue();
273
+        System.out.println("v = " + v);
274
+    }
264 275
 }

+ 53 - 42
src/main/java/com/szls/nstths/service/impl/TeDataServiceImpl.java

@@ -4,16 +4,19 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4 4
 import com.szls.nstths.entity.ReMsg;
5 5
 import com.szls.nstths.entity.STask;
6 6
 import com.szls.nstths.entity.TeData;
7
+import com.szls.nstths.mapper.ReMsgMapper;
7 8
 import com.szls.nstths.mapper.STaskMapper;
8 9
 import com.szls.nstths.mapper.TeDataMapper;
9 10
 import com.szls.nstths.service.TeDataService;
10 11
 import org.springframework.beans.factory.annotation.Autowired;
12
+import org.springframework.stereotype.Service;
11 13
 import org.springframework.web.client.RestTemplate;
12 14
 
13 15
 import java.util.ArrayList;
14 16
 import java.util.Date;
15 17
 import java.util.List;
16 18
 
19
+@Service(value = "teDataService")
17 20
 public class TeDataServiceImpl implements TeDataService {
18 21
 
19 22
     static String base_url = "http://local.wxlxit.com:61001/";
@@ -24,6 +27,13 @@ public class TeDataServiceImpl implements TeDataService {
24 27
     static double h2 = 3; //h2 水平地面到圆锥尖的高
25 28
     private STaskMapper sTaskMapper;
26 29
     private TeDataMapper teDataMapper;
30
+    private ReMsgMapper reMsgMapper;
31
+
32
+    public static void main(String[] args) {
33
+        String str = "18,7,17.88-19,6,28.88-17,4,39.88";
34
+
35
+        str.split("-");
36
+    }
27 37
 
28 38
     @Autowired
29 39
     public void setsTaskMapper(STaskMapper sTaskMapper) {
@@ -35,6 +45,11 @@ public class TeDataServiceImpl implements TeDataService {
35 45
         this.teDataMapper = teDataMapper;
36 46
     }
37 47
 
48
+    @Autowired
49
+    public void setReMsgMapper(ReMsgMapper reMsgMapper) {
50
+        this.reMsgMapper = reMsgMapper;
51
+    }
52
+
38 53
     /**
39 54
      * todo
40 55
      * http://local.wxlxit.com:61001/
@@ -46,11 +61,11 @@ public class TeDataServiceImpl implements TeDataService {
46 61
     @Override
47 62
     public void scanTask(double diameter, double high) {
48 63
 
49
-    	
64
+
50 65
         STask task = new STask();
51 66
         Date date = new Date();
52 67
         task.setCtime(date);
53
-        task.setDescribe("test");
68
+        task.setDepict("test");
54 69
         sTaskMapper.insert(task);
55 70
 
56 71
         TeData teData = new TeData();
@@ -70,24 +85,24 @@ public class TeDataServiceImpl implements TeDataService {
70 85
 
71 86
     @Override
72 87
     public int scanTask(TeData teData) {
73
-    	//只运行 发送一次。
88
+        //只运行 发送一次。
74 89
         if (flag) {
75
-	        teData.getEquipmentID();
76
-	        teData.getTaskID();
77
-	
78
-	        //todo 第二次待打点
79
-	        
80
-	        //计算以粮面为基准面的高
81
-	        double zHeight = Algorithm.zHeight(teData.getRotationxy(),diameter, high);
82
-	        //打点
83
-	        String rotationxy = Algorithm.getAveragePosition(diameter, zHeight);
84
-	        teData.setRotationxy(rotationxy);
85
-	        int inum = teDataMapper.insert(teData);
86
-	
87
-	        postHelper(teData);
88
-	        flag = false;
89
-	
90
-	        return inum;
90
+            teData.getEquipmentID();
91
+            teData.getTaskID();
92
+
93
+            //todo 第二次待打点
94
+
95
+            //计算以粮面为基准面的高
96
+            double zHeight = Algorithm.zHeight(teData.getRotationxy(), diameter, high);
97
+            //打点
98
+            String rotationxy = Algorithm.getAveragePosition(diameter, zHeight);
99
+            teData.setRotationxy(rotationxy);
100
+            int inum = teDataMapper.insert(teData);
101
+
102
+            postHelper(teData);
103
+            flag = false;
104
+
105
+            return inum;
91 106
         }
92 107
         return 0;
93 108
     }
@@ -95,43 +110,39 @@ public class TeDataServiceImpl implements TeDataService {
95 110
     public ReMsg postHelper(TeData teData) {
96 111
         RestTemplate restTemplate = new RestTemplate();
97 112
         ReMsg reMsg1 = restTemplate.postForObject(base_url + "equipmentTestingIsReady", teData, ReMsg.class);
113
+        //reMsgMapper.insert(reMsg1);
114
+
98 115
         if (reMsg1 != null) {
99
-            if (reMsg1.getCode().equals("0")) {
116
+            if ("0".equals(reMsg1.getCode())) {
100 117
                 ReMsg reMsg2 = restTemplate.postForObject(base_url + "equipmentTestingStart", teData, ReMsg.class);
118
+                reMsgMapper.insert(reMsg2);
101 119
                 return reMsg2;
102 120
             }
103 121
         }
104 122
         return null;
105 123
     }
106 124
 
107
-    
108 125
     @Override
109
-	public void calculateVolume(String taskID) {
110
-		// TODO Auto-generated method stub
111
-		List<Double> zList = new ArrayList<Double>();
112
-		String[] split = null;
113
-		
114
-		QueryWrapper<TeData> queryWrapper = new QueryWrapper<>();
126
+    public void calculateVolume(String taskID) {
127
+        // TODO Auto-generated method stub
128
+        List<Double> zList = new ArrayList<Double>();
129
+        String[] split = null;
130
+
131
+        QueryWrapper<TeData> queryWrapper = new QueryWrapper<>();
115 132
 
116 133
         List<TeData> teDataList = null;
117 134
         queryWrapper.eq("taskID", taskID);
118 135
         teDataList = teDataMapper.selectList(queryWrapper);
119
-		for (TeData teData : teDataList) {
120
-			split = teData.getRotationxy().split("-");
121
-			for (int i = 0; i < split.length; i++) {
122
-				String[] split1 = split[i].split(",");
123
-				//split1[2]  是返回的距离
124
-				zList.add(Double.parseDouble(split1[2]));
125
-			}
126
-		}
127
-		double v = Algorithm.calculateVolume(zList,diameter,h1,h2); //体积
128
-		
129
-	}
130
-    
131
-    public static void main(String[] args) {
132
-        String str = "18,7,17.88-19,6,28.88-17,4,39.88";
136
+        for (TeData teData : teDataList) {
137
+            split = teData.getRotationxy().split("-");
138
+            for (int i = 0; i < split.length; i++) {
139
+                String[] split1 = split[i].split(",");
140
+                //split1[2]  是返回的距离
141
+                zList.add(Double.parseDouble(split1[2]));
142
+            }
143
+        }
144
+        double v = Algorithm.calculateVolume(zList, diameter, h1, h2); //体积
133 145
 
134
-        str.split("-");
135 146
     }
136 147
 
137 148
 }

+ 12 - 0
src/main/resources/static/index.html

@@ -0,0 +1,12 @@
1
+<!DOCTYPE html>
2
+<html lang="en">
3
+<head>
4
+    <meta charset="UTF-8">
5
+    <title>admin</title>
6
+</head>
7
+<body>
8
+<a href="http://127.0.0.1:7077/scanning">本地默认扫描</a>
9
+
10
+<a href="http://112.51.248.191:7077/scanning">远程默认扫描</a>
11
+</body>
12
+</html>

+ 0 - 1
src/test/java/com/szls/nstths/NstthsApplicationTests.java

@@ -3,7 +3,6 @@ package com.szls.nstths;
3 3
 import com.baomidou.mybatisplus.generator.FastAutoGenerator;
4 4
 import com.baomidou.mybatisplus.generator.config.OutputFile;
5 5
 import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;
6
-import org.junit.jupiter.api.Test;
7 6
 import org.springframework.boot.test.context.SpringBootTest;
8 7
 
9 8
 import java.util.Collections;

+ 0 - 1
src/test/java/com/szls/nstths/SampleTest.java

@@ -2,7 +2,6 @@ package com.szls.nstths;
2 2
 
3 3
 import com.szls.nstths.entity.User;
4 4
 import com.szls.nstths.mapper.UserMapper;
5
-import org.junit.jupiter.api.Test;
6 5
 import org.springframework.boot.test.context.SpringBootTest;
7 6
 
8 7
 import javax.annotation.Resource;