Commit 4a6d6726514eeb0b9be5572281343000b907ba15
1 parent
efa9935f
Exists in
master
优化定时服务和片网络图片映射
Showing
13 changed files
with
109 additions
and
44 deletions
Show diff stats
.gitignore
cloud/dahua/src/main/java/com/example/dahua/MyTask.java
... | ... | @@ -232,7 +232,7 @@ public class MyTask implements ApplicationRunner { |
232 | 232 | } |
233 | 233 | } |
234 | 234 | |
235 | - public void reloadPic() { | |
235 | + public synchronized void reloadPic() { | |
236 | 236 | |
237 | 237 | /* Set<String> set = lLongMap.keySet(); |
238 | 238 | Iterator<String> iterator = set.iterator(); |
... | ... | @@ -244,16 +244,17 @@ public class MyTask implements ApplicationRunner { |
244 | 244 | GateModule.realLoadPic(0,analyzerCallback,lLongMap.get(deviceId)); |
245 | 245 | }*/ |
246 | 246 | |
247 | - for (DeviceInfoBean dev : | |
248 | - deviceInfoBeans) { | |
249 | - System.out.println("dev:" + dev.toString() + " -------llong:" + lLongMap.get(dev.getDevcieId())); | |
250 | - FileUtils.getInstance().writeLogs(dev.getDevcieId() + "------" + lLongMap.get(dev.getDevcieId()), FileUtils.device_login); | |
251 | - if (lLongMap.get(dev.getDevcieId()).intValue() > 0) | |
252 | - GateModule.realLoadPic(0, analyzerCallback, lLongMap.get(dev.getDevcieId())); | |
247 | + if (null!=deviceInfoBeans){ | |
248 | + for (DeviceInfoBean dev : | |
249 | + deviceInfoBeans) { | |
250 | + FileUtils.getInstance().writeLogs(dev.getDevcieId() + "------" + lLongMap.get(dev.getDevcieId()), FileUtils.device_login); | |
251 | + if (lLongMap.get(dev.getDevcieId()).intValue() > 0) | |
252 | + GateModule.realLoadPic(0, analyzerCallback, lLongMap.get(dev.getDevcieId())); | |
253 | 253 | |
254 | - } | |
254 | + } | |
255 | 255 | |
256 | - isHasNewDevice = false; | |
256 | + isHasNewDevice = false; | |
257 | + } | |
257 | 258 | } |
258 | 259 | |
259 | 260 | |
... | ... | @@ -299,7 +300,8 @@ public class MyTask implements ApplicationRunner { |
299 | 300 | card=cardNo(card); |
300 | 301 | CardBean cardBean = userDao.getCards(card);//根据卡号获取身份信息 |
301 | 302 | String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); |
302 | - snapPicPath = snapPicPath.replace("E:\\wwwhtdocs\\SmartCampus", "http://campus.myjxt.com"); | |
303 | + snapPicPath = snapPicPath.replaceFirst("\\.", "http://121.40.109.21:8991"); | |
304 | + snapPicPath = snapPicPath.replace("FaceRecoder","image"); | |
303 | 305 | if (cardBean.getType() == 0) {//老师 |
304 | 306 | TeacherBean teacherBean = userDao.getTeacherWithId(cardBean.getUser_id()); |
305 | 307 | sendRecordDao.addFaceRecoder("", teacherBean.getUser_id(), teacherBean.getName(), snapPicPath, 1, time, card); | ... | ... |
cloud/dahua/src/main/java/com/example/dahua/WebMvcConfigurer.java
0 → 100644
... | ... | @@ -0,0 +1,29 @@ |
1 | +package com.example.dahua; | |
2 | + | |
3 | +import org.springframework.context.annotation.Configuration; | |
4 | +import org.springframework.web.servlet.config.annotation.InterceptorRegistry; | |
5 | +import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; | |
6 | +import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport; | |
7 | + | |
8 | +import java.io.File; | |
9 | + | |
10 | +@Configuration | |
11 | +public class WebMvcConfigurer extends WebMvcConfigurationSupport { | |
12 | + | |
13 | + | |
14 | + @Override | |
15 | + protected void addResourceHandlers(ResourceHandlerRegistry registry) { | |
16 | + super.addResourceHandlers(registry); | |
17 | + | |
18 | +// File file = new File("D:\\cloud\\FaceRecoder\\"); | |
19 | +// String imageSource = "C:\\Users\\taohandong\\Pictures\\"; | |
20 | +// if (file.exists())imageSource = file.getAbsolutePath(); | |
21 | + registry.addResourceHandler("/image/**").addResourceLocations("file:D:\\cloud\\FaceRecoder\\"); | |
22 | + //swagger界面 | |
23 | + registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/"); | |
24 | + registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/"); | |
25 | + | |
26 | + } | |
27 | + | |
28 | + | |
29 | +} | ... | ... |
cloud/dahua/src/main/java/com/example/dahua/async/MyScheduledTask.java
... | ... | @@ -6,6 +6,7 @@ import com.example.dahua.bean.StudentBean; |
6 | 6 | import com.example.dahua.bean.UserInfoBean; |
7 | 7 | import com.example.dahua.bean.WGBean; |
8 | 8 | import com.example.dahua.dao.UserDao; |
9 | +import com.example.dahua.lib.Utils; | |
9 | 10 | import com.example.dahua.mqtt.MqttManager; |
10 | 11 | import com.example.dahua.utils.FileUtils; |
11 | 12 | import com.example.dahua.xiananDao.SendRecordDao; |
... | ... | @@ -168,6 +169,11 @@ public class MyScheduledTask { |
168 | 169 | |
169 | 170 | private synchronized void dealData(){ |
170 | 171 | |
172 | + String ip = new Utils().getHostAddress(); | |
173 | + System.out.println("ip:"+ip); | |
174 | + if (ip.startsWith("192")) | |
175 | + return; | |
176 | + | |
171 | 177 | /** |
172 | 178 | * 微耕 |
173 | 179 | */ | ... | ... |
cloud/dahua/src/main/java/com/example/dahua/async/SendUserInfoTask.java
... | ... | @@ -27,10 +27,7 @@ import org.springframework.web.client.RestTemplate; |
27 | 27 | |
28 | 28 | import java.io.*; |
29 | 29 | import java.text.SimpleDateFormat; |
30 | -import java.util.ArrayList; | |
31 | -import java.util.Calendar; | |
32 | -import java.util.Date; | |
33 | -import java.util.List; | |
30 | +import java.util.*; | |
34 | 31 | |
35 | 32 | /** |
36 | 33 | * 下发卡号的异步操作 |
... | ... | @@ -565,9 +562,30 @@ public class SendUserInfoTask { |
565 | 562 | break; |
566 | 563 | } |
567 | 564 | String filePath = String.format("E:\\wwwhtdocs\\SmartCampus\\face17e5\\School%s\\%s\\%s.jpg", sendRecordBean.getSchoolId(), userTy, userDao.getStudentCode(sendRecordBean.getCustomerid())); |
568 | - String url = String.format("http://114.55.30.100:8089/facereco/sendStuCardAndImg?card=%s&deviceId=%s&endTime=%s&filePath=%s&name=%s&userType=%s&validTimeEnabled=%s&startTime=%s" | |
569 | - , sendRecordBean.getNum(), sendRecordBean.getDeviceID(), "2033-10-01 10:00:00", filePath, sendRecordBean.getName(), "2", "1", "2019-10-01 10:00:00"); | |
570 | - boolean result1 = restTemplate.getForObject(url, Boolean.class); | |
565 | + String url = "http://114.55.30.100:8089/facereco/sendStuCardAndImg?card={card}&deviceId={deviceId}&endTime={endTime}&" + | |
566 | + "filePath={filePath}&name={name}&userType={userType}&validTimeEnabled={validTimeEnabled}&startTime={startTime}"; | |
567 | + | |
568 | + Map<String,Object> map = new HashMap<>(); | |
569 | + | |
570 | + map.put("card",sendRecordBean.getNum()); | |
571 | + map.put("deviceId",sendRecordBean.getDeviceID()); | |
572 | + map.put("endTime","2033-10-01 10:00:00"); | |
573 | + map.put("filePath",filePath); | |
574 | + map.put("name",sendRecordBean.getName()); | |
575 | + map.put("userType",userType); | |
576 | + map.put("validTimeEnabled","1"); | |
577 | + map.put("startTime","2019-10-01 10:00:00"); | |
578 | + | |
579 | + ResponseEntity<String> responseEntity = restTemplate.getForEntity(url,String.class,map); | |
580 | + | |
581 | + System.out.println("responseEntity:---------------------------"+map.toString()); | |
582 | + | |
583 | + String result = responseEntity.getBody(); | |
584 | + result = result.replace("<Boolean>",""); | |
585 | + result = result.replace("</Boolean>",""); | |
586 | + | |
587 | + boolean result1 = Boolean.parseBoolean(result); | |
588 | + | |
571 | 589 | if (result1) { |
572 | 590 | System.out.println("下发成功:" + url); |
573 | 591 | } else { | ... | ... |
cloud/dahua/src/main/resources/application.yaml
cloud/dahua/src/test/java/com/example/dahua/DahuaApplicationTests.java
... | ... | @@ -310,36 +310,16 @@ public class DahuaApplicationTests { |
310 | 310 | |
311 | 311 | @Test |
312 | 312 | public void test2() { |
313 | - /* File file = new File("C:\\Users\\taohandong\\Desktop\\教师自拍(1)(1)\\教师自拍(1)"); | |
314 | - File[] files = file.listFiles(); | |
315 | - | |
316 | - for (int i = 0; i < files.length; i++) { | |
317 | - File file1 = files[i]; | |
318 | 313 | |
319 | - try { | |
320 | - FileInputStream fileInputStream = new FileInputStream(file1); | |
314 | + RestTemplate restTemplate = new RestTemplate(); | |
321 | 315 | |
322 | - FileOutputStream fileOutputStream = new FileOutputStream(new File(file.getAbsolutePath(),file1.getName().split("\\.")[0]+".png")); | |
323 | 316 | |
324 | - int length = 0; | |
317 | + String url = "http://localhost:8991/user/checkFace?url=C:\\Users\\taohandong\\Pictures\\test.jpg"; | |
325 | 318 | |
326 | - byte[] bytes = new byte[1024]; | |
327 | 319 | |
328 | - while ((length=fileInputStream.read(bytes))!=-1){ | |
329 | - fileOutputStream.write(bytes,0,length); | |
330 | - } | |
320 | + System.out.println("result:"+ restTemplate.getForObject(url,String.class)); | |
331 | 321 | |
332 | - fileInputStream.close(); | |
333 | - fileOutputStream.close(); | |
334 | - file1.deleteOnExit(); | |
335 | 322 | |
336 | - } catch (FileNotFoundException e) { | |
337 | - e.printStackTrace(); | |
338 | - } catch (IOException e) { | |
339 | - e.printStackTrace(); | |
340 | - } | |
341 | - | |
342 | - }*/ | |
343 | 323 | } |
344 | 324 | |
345 | 325 | @Test | ... | ... |
41.7 KB
... | ... | @@ -0,0 +1,14 @@ |
1 | +2019-12-24 17:19:39 2019-12-24 17:19:39 30 | |
2 | + | |
3 | +2019-12-24 17:21:01 2019-12-24 17:21:01 30 | |
4 | + | |
5 | +2019-12-24 17:21:31 2019-12-24 17:21:31 30 | |
6 | + | |
7 | +2019-12-24 17:22:24 2019-12-24 17:22:24 30 | |
8 | + | |
9 | +2019-12-24 17:31:52 2019-12-24 17:31:52 30 | |
10 | + | |
11 | +2019-12-24 17:36:02 2019-12-24 17:36:02 30 | |
12 | + | |
13 | +2019-12-24 17:53:49 2019-12-24 17:53:49 30 | |
14 | + | ... | ... |
... | ... | @@ -0,0 +1,10 @@ |
1 | +2019-12-25 14:29:00 检测成功:C:\Users\taohandong\Pictures\test.jpg | |
2 | + | |
3 | +2019-12-25 14:31:49 检测成功:C:\Users\taohandong\Pictures\test.jpg | |
4 | + | |
5 | +2019-12-25 14:32:36 检测成功:C:\Users\taohandong\Pictures\test.jpg | |
6 | + | |
7 | +2019-12-25 14:36:12 检测成功:C:\Users\taohandong\Pictures\test.jpg | |
8 | + | |
9 | +2019-12-25 14:36:58 检测成功:C:\Users\taohandong\Pictures\test.jpg | |
10 | + | ... | ... |
cloud/mypulsar/pom.xml
... | ... | @@ -142,15 +142,14 @@ |
142 | 142 | <artifactId>spring-boot-maven-plugin</artifactId> |
143 | 143 | <configuration> |
144 | 144 | <includeSystemScope>true</includeSystemScope> |
145 | - <!-- | |
146 | 145 | <layout>ZIP</layout> |
147 | 146 | <includes> |
148 | 147 | <include> |
149 | - <!– 排除所有Jar –> | |
148 | + <!-- 排除所有Jar --> | |
150 | 149 | <groupId>nothing</groupId> |
151 | 150 | <artifactId>nothing</artifactId> |
152 | 151 | </include> |
153 | - </includes>--> | |
152 | + </includes> | |
154 | 153 | </configuration> |
155 | 154 | </plugin> |
156 | 155 | </plugins> | ... | ... |
cloud/mypulsar/src/main/java/com/example/mypulsar/MyRunnerableInt.java
... | ... | @@ -261,7 +261,7 @@ public class MyRunnerableInt implements ApplicationRunner { |
261 | 261 | |
262 | 262 | break; |
263 | 263 | case "pir"://人体感应 |
264 | - log("人体感应:" + (value.equals("pir") ? "有人" : "无人")); | |
264 | + log("人体感应:" + value); | |
265 | 265 | value = (value.equals("pir") ? "有人" : "无人"); |
266 | 266 | deviceBean.setValue(value); |
267 | 267 | calOpenOrCloseDevWithPir(deviceBean); | ... | ... |