Commit 4a6d6726514eeb0b9be5572281343000b907ba15

Authored by 陶汉栋
1 parent efa9935f
Exists in master

优化定时服务和片网络图片映射

1 cloud.zip 1 cloud.zip
2 cloud/haikangface/log/2019-11-15/13_文件保存回调.txt 2 cloud/haikangface/log/2019-11-15/13_文件保存回调.txt
  3 +cloud/mypulsar/mypulsar-1.0.0/
  4 +cloud/mypulsar/mypulsar-1.0.0.jar
cloud/dahua/src/main/java/com/example/dahua/MyTask.java
@@ -232,7 +232,7 @@ public class MyTask implements ApplicationRunner { @@ -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 /* Set<String> set = lLongMap.keySet(); 237 /* Set<String> set = lLongMap.keySet();
238 Iterator<String> iterator = set.iterator(); 238 Iterator<String> iterator = set.iterator();
@@ -244,16 +244,17 @@ public class MyTask implements ApplicationRunner { @@ -244,16 +244,17 @@ public class MyTask implements ApplicationRunner {
244 GateModule.realLoadPic(0,analyzerCallback,lLongMap.get(deviceId)); 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,7 +300,8 @@ public class MyTask implements ApplicationRunner {
299 card=cardNo(card); 300 card=cardNo(card);
300 CardBean cardBean = userDao.getCards(card);//根据卡号获取身份信息 301 CardBean cardBean = userDao.getCards(card);//根据卡号获取身份信息
301 String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); 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 if (cardBean.getType() == 0) {//老师 305 if (cardBean.getType() == 0) {//老师
304 TeacherBean teacherBean = userDao.getTeacherWithId(cardBean.getUser_id()); 306 TeacherBean teacherBean = userDao.getTeacherWithId(cardBean.getUser_id());
305 sendRecordDao.addFaceRecoder("", teacherBean.getUser_id(), teacherBean.getName(), snapPicPath, 1, time, card); 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 @@ @@ -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 +6,7 @@ import com.example.dahua.bean.StudentBean;
6 import com.example.dahua.bean.UserInfoBean; 6 import com.example.dahua.bean.UserInfoBean;
7 import com.example.dahua.bean.WGBean; 7 import com.example.dahua.bean.WGBean;
8 import com.example.dahua.dao.UserDao; 8 import com.example.dahua.dao.UserDao;
  9 +import com.example.dahua.lib.Utils;
9 import com.example.dahua.mqtt.MqttManager; 10 import com.example.dahua.mqtt.MqttManager;
10 import com.example.dahua.utils.FileUtils; 11 import com.example.dahua.utils.FileUtils;
11 import com.example.dahua.xiananDao.SendRecordDao; 12 import com.example.dahua.xiananDao.SendRecordDao;
@@ -168,6 +169,11 @@ public class MyScheduledTask { @@ -168,6 +169,11 @@ public class MyScheduledTask {
168 169
169 private synchronized void dealData(){ 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,10 +27,7 @@ import org.springframework.web.client.RestTemplate;
27 27
28 import java.io.*; 28 import java.io.*;
29 import java.text.SimpleDateFormat; 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,9 +562,30 @@ public class SendUserInfoTask {
565 break; 562 break;
566 } 563 }
567 String filePath = String.format("E:\\wwwhtdocs\\SmartCampus\\face17e5\\School%s\\%s\\%s.jpg", sendRecordBean.getSchoolId(), userTy, userDao.getStudentCode(sendRecordBean.getCustomerid())); 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 if (result1) { 589 if (result1) {
572 System.out.println("下发成功:" + url); 590 System.out.println("下发成功:" + url);
573 } else { 591 } else {
cloud/dahua/src/main/resources/application.yaml
@@ -57,3 +57,6 @@ mybatis: @@ -57,3 +57,6 @@ mybatis:
57 #haikangpic: E:\wwwhtdocs\HFface\FaceLogs\ 57 #haikangpic: E:\wwwhtdocs\HFface\FaceLogs\
58 58
59 #haikangfaceurl: http://60.190.202.57:8899 59 #haikangfaceurl: http://60.190.202.57:8899
  60 +
  61 +
  62 +
cloud/dahua/src/test/java/com/example/dahua/DahuaApplicationTests.java
@@ -310,36 +310,16 @@ public class DahuaApplicationTests { @@ -310,36 +310,16 @@ public class DahuaApplicationTests {
310 310
311 @Test 311 @Test
312 public void test2() { 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 @Test 325 @Test
cloud/huoti/test.jpg 0 → 100644

41.7 KB

cloud/log/2019-12-24/下发指令.txt 0 → 100644
@@ -0,0 +1,14 @@ @@ -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 +
cloud/log/2019-12-25/10_sendUserInfo.txt 0 → 100644
@@ -0,0 +1,2 @@ @@ -0,0 +1,2 @@
  1 +2019-12-25 10:42:40 filePath:1 card:11111111 name:1 deviceId:11
  2 +
cloud/log/2019-12-25/检测成功.txt 0 → 100644
@@ -0,0 +1,10 @@ @@ -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,15 +142,14 @@
142 <artifactId>spring-boot-maven-plugin</artifactId> 142 <artifactId>spring-boot-maven-plugin</artifactId>
143 <configuration> 143 <configuration>
144 <includeSystemScope>true</includeSystemScope> 144 <includeSystemScope>true</includeSystemScope>
145 - <!--  
146 <layout>ZIP</layout> 145 <layout>ZIP</layout>
147 <includes> 146 <includes>
148 <include> 147 <include>
149 - &lt;!&ndash; 排除所有Jar &ndash;&gt; 148 + <!-- 排除所有Jar -->
150 <groupId>nothing</groupId> 149 <groupId>nothing</groupId>
151 <artifactId>nothing</artifactId> 150 <artifactId>nothing</artifactId>
152 </include> 151 </include>
153 - </includes>--> 152 + </includes>
154 </configuration> 153 </configuration>
155 </plugin> 154 </plugin>
156 </plugins> 155 </plugins>
cloud/mypulsar/src/main/java/com/example/mypulsar/MyRunnerableInt.java
@@ -261,7 +261,7 @@ public class MyRunnerableInt implements ApplicationRunner { @@ -261,7 +261,7 @@ public class MyRunnerableInt implements ApplicationRunner {
261 261
262 break; 262 break;
263 case "pir"://人体感应 263 case "pir"://人体感应
264 - log("人体感应:" + (value.equals("pir") ? "有人" : "无人")); 264 + log("人体感应:" + value);
265 value = (value.equals("pir") ? "有人" : "无人"); 265 value = (value.equals("pir") ? "有人" : "无人");
266 deviceBean.setValue(value); 266 deviceBean.setValue(value);
267 calOpenOrCloseDevWithPir(deviceBean); 267 calOpenOrCloseDevWithPir(deviceBean);