Commit 6f262f5bc632a34e675e4d8a972498cc552b0132

Authored by 陶汉栋
1 parent ab4cd65a
Exists in master

网关服务优化

Showing 63 changed files with 1672 additions and 738 deletions   Show diff stats
.gitignore
... ... @@ -2,3 +2,72 @@ cloud.zip
2 2 cloud/haikangface/log/2019-11-15/13_文件保存回调.txt
3 3 cloud/mypulsar/mypulsar-1.0.0/
4 4 cloud/mypulsar/mypulsar-1.0.0.jar
  5 +cloud/dahua/sdklog/2019-11-22_08-53-36.log
  6 +cloud/dahua/sdklog/2019-11-22_08-53-55.log
  7 +cloud/dahua/sdklog/2019-11-22_08-54-42.log
  8 +cloud/dahua/sdklog/2019-11-22_08-55-16.log
  9 +cloud/dahua/sdklog/2019-11-22_08-56-13.log
  10 +cloud/dahua/sdklog/2019-12-10_11-22-45.log
  11 +cloud/dahua/sdklog/2019-12-25_14-31-48.log
  12 +cloud/dahua/sdklog/2019-12-25_14-32-35.log
  13 +cloud/dahua/sdklog/2019-12-25_14-36-10.log
  14 +cloud/dahua/sdklog/2019-12-25_14-36-57.log
  15 +cloud/haikangface/hs_err_pid21508.log
  16 +cloud/log/2019-12-25/下发指令.txt
  17 +cloud/quartz/src/pom.xml
  18 +cloud/sdklog/2019-11-25_17-32-54.log
  19 +cloud/sdklog/2019-11-28_13-51-36.log
  20 +cloud/sdklog/2019-11-28_13-55-18.log
  21 +cloud/sdklog/2019-11-28_14-13-23.log
  22 +cloud/sdklog/2019-11-28_14-14-31.log
  23 +cloud/sdklog/2019-11-28_14-52-30.log
  24 +cloud/sdklog/2019-11-28_14-53-41.log
  25 +cloud/sdklog/2019-11-28_14-54-22.log
  26 +cloud/sdklog/2019-11-28_14-55-12.log
  27 +cloud/sdklog/2019-11-28_15-06-32.log
  28 +cloud/sdklog/2019-11-29_13-58-21.log
  29 +cloud/sdklog/2019-11-29_14-04-29.log
  30 +cloud/sdklog/2019-11-29_16-33-47.log
  31 +cloud/sdklog/2019-11-29_17-27-52.log
  32 +cloud/sdklog/2019-12-04_14-29-05.log
  33 +cloud/sdklog/2019-12-11_16-36-43.log
  34 +cloud/sdklog/2019-12-11_16-53-13.log
  35 +cloud/sdklog/2019-12-11_16-56-55.log
  36 +cloud/sdklog/2019-12-11_17-06-39.log
  37 +cloud/sdklog/2019-12-11_17-14-50.log
  38 +cloud/sdklog/2019-12-11_17-39-25.log
  39 +cloud/sdklog/2019-12-11_17-42-05.log
  40 +cloud/sdklog/2019-12-11_17-43-51.log
  41 +cloud/sdklog/2019-12-11_17-45-31.log
  42 +cloud/sdklog/2019-12-11_17-46-29.log
  43 +cloud/sdklog/2019-12-11_17-47-45.log
  44 +cloud/sdklog/2019-12-11_17-49-52.log
  45 +cloud/sdklog/2019-12-11_17-50-53.log
  46 +cloud/sdklog/2019-12-11_17-57-54.log
  47 +cloud/sdklog/2019-12-11_18-02-49.log
  48 +cloud/sdklog/2019-12-24_17-19-40.log
  49 +cloud/sdklog/2019-12-24_17-21-01.log
  50 +cloud/sdklog/2019-12-24_17-21-32.log
  51 +cloud/sdklog/2019-12-24_17-22-24.log
  52 +cloud/sdklog/2019-12-24_17-31-53.log
  53 +cloud/sdklog/2019-12-24_17-36-03.log
  54 +cloud/sdklog/2019-12-24_17-53-50.log
  55 +cloud/sdklog/2019-12-24_18-04-46.log
  56 +cloud/sdklog/2019-12-24_18-06-10.log
  57 +cloud/sdklog/2019-12-24_18-14-08.log
  58 +cloud/sdklog/2019-12-25_10-21-04.log
  59 +cloud/sdklog/2019-12-25_10-24-26.log
  60 +cloud/sdklog/2019-12-25_10-42-31.log
  61 +cloud/sdklog/2019-12-25_10-54-11.log
  62 +cloud/sdklog/2019-12-25_12-03-48.log
  63 +cloud/sdklog/2019-12-25_12-04-39.log
  64 +cloud/sdklog/2019-12-25_12-09-35.log
  65 +cloud/sdklog/2019-12-25_12-12-10.log
  66 +cloud/sdklog/2019-12-25_12-25-06.log
  67 +cloud/sdklog/2019-12-25_12-26-52.log
  68 +cloud/sdklog/2019-12-25_13-44-14.log
  69 +cloud/sdklog/2019-12-25_13-47-18.log
  70 +cloud/sdklog/2019-12-25_13-48-18.log
  71 +cloud/sdklog/2019-12-25_13-49-20.log
  72 +cloud/sdklog/2019-12-25_14-24-38.log
  73 +cloud/sdklog/2019-12-25_14-33-26.log
... ...
cloud/dahua/pom.xml
... ... @@ -11,6 +11,7 @@
11 11 <artifactId>dahua</artifactId>
12 12 <version>1.0.0</version>
13 13 <name>dahua</name>
  14 + <url>http://maven.apache.org</url>
14 15 <description>Demo project for Spring Boot</description>
15 16  
16 17 <properties>
... ... @@ -117,7 +118,11 @@
117 118 <artifactId>mybatis-spring-boot-starter</artifactId>
118 119 <version>2.0.1</version>
119 120 </dependency>
120   -
  121 + <dependency>
  122 + <groupId>com.sincere</groupId>
  123 + <artifactId>common</artifactId>
  124 + <version>1.0.0</version>
  125 + </dependency>
121 126  
122 127 <!--<dependency>-->
123 128 <!--<groupId>com.drewnoakes</groupId>-->
... ... @@ -165,6 +170,12 @@
165 170 <version>4.1.0</version>
166 171 <scope>compile</scope>
167 172 </dependency>
  173 +
  174 +<!-- <dependency>-->
  175 +<!-- <groupId>com.aliyun.oss</groupId>-->
  176 +<!-- <artifactId>aliyun-sdk-oss</artifactId>-->
  177 +<!-- <version>3.8.0</version>-->
  178 +<!-- </dependency>-->
168 179 </dependencies>
169 180  
170 181  
... ... @@ -185,6 +196,27 @@
185 196 </includes>
186 197 </configuration>
187 198 </plugin>
  199 +
  200 + <plugin>
  201 + <groupId>org.apache.maven.plugins</groupId>
  202 + <artifactId>maven-dependency-plugin</artifactId>
  203 +<!-- <version>2.2</version>&lt;!&ndash;$NO-MVN-MAN-VER$ &ndash;&gt;-->
  204 + <executions>
  205 + <execution>
  206 + <id>copy-dependencies</id>
  207 + <phase>package</phase>
  208 + <goals>
  209 + <goal>copy-dependencies</goal>
  210 + </goals>
  211 + <configuration>
  212 + <outputDirectory>${project.build.directory}/libs</outputDirectory>
  213 + <overWriteReleases>true</overWriteReleases>
  214 + <overWriteSnapshots>true</overWriteSnapshots>
  215 + <overWriteIfNewer>true</overWriteIfNewer>
  216 + </configuration>
  217 + </execution>
  218 + </executions>
  219 + </plugin>
188 220 </plugins>
189 221 </build>
190 222  
... ...
cloud/dahua/src/main/java/com/example/dahua/MyTask.java
... ... @@ -71,9 +71,9 @@ public class MyTask implements ApplicationRunner {
71 71 public void run(ApplicationArguments args) throws Exception {
72 72 // 121.40.109.21
73 73  
74   - LoginModule.init(disConnect, haveReConnect); // 打开工程,初始化
  74 +// LoginModule.init(disConnect, haveReConnect); // 打开工程,初始化
75 75  
76   - autoRegister();//自注册
  76 +// autoRegister();//自注册
77 77  
78 78 // System.out.println(" sendRecordDao:"+sendRecordDao.getSenSuccess());
79 79 }
... ... @@ -233,27 +233,19 @@ public class MyTask implements ApplicationRunner {
233 233 }
234 234  
235 235 public synchronized void reloadPic() {
236   -
237   - /* Set<String> set = lLongMap.keySet();
238   - Iterator<String> iterator = set.iterator();
239   -
240   - while (iterator.hasNext()){
241   - String deviceId= iterator.next();
242   - System.out.println("deviceId:"+deviceId+" llong:"+lLongMap.get(deviceId));
243   - GateModule.stopRealLoadPic(lLongMap.get(deviceId));
244   - GateModule.realLoadPic(0,analyzerCallback,lLongMap.get(deviceId));
245   - }*/
246   -
247   - if (null!=deviceInfoBeans){
  236 + isHasNewDevice = false;
  237 + if (null!=deviceInfoBeans&&deviceInfoBeans.size()>0){
248 238 for (DeviceInfoBean dev :
249 239 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()));
  240 +// FileUtils.getInstance().writeLogs(dev.getDevcieId() + "------" + lLongMap.get(dev.getDevcieId()), FileUtils.device_login);
  241 + if (lLongMap.get(dev.getDevcieId()).intValue() > 0){
  242 + NetSDKLib.LLong lLong = GateModule.realLoadPic(0, analyzerCallback, lLongMap.get(dev.getDevcieId()));
  243 + if (lLong.intValue()!=-1){
  244 + deviceInfoBeans.remove(dev);
  245 + }
  246 + }
253 247  
254 248 }
255   -
256   - isHasNewDevice = false;
257 249 }
258 250 }
259 251  
... ...
cloud/dahua/src/main/java/com/example/dahua/Test.java
1 1 package com.example.dahua;
2 2  
3   -import com.drew.imaging.jpeg.JpegMetadataReader;
4   -import com.drew.imaging.jpeg.JpegProcessingException;
5   -import com.drew.metadata.Directory;
6   -import com.drew.metadata.Metadata;
7   -import com.drew.metadata.Tag;
8   -import com.example.dahua.bean.AttendanceRecords;
9   -import com.example.dahua.bean.UserInfoBean;
10   -import com.example.dahua.dao.UserDao;
11   -import com.example.dahua.xiananDao.SendRecordDao;
12   -import org.springframework.beans.factory.annotation.Autowired;
13   -
14   -import java.io.File;
15   -import java.io.IOException;
16   -import java.text.SimpleDateFormat;
17   -import java.util.ArrayList;
18   -import java.util.Date;
19   -import java.util.List;
20 3  
21 4 public class Test {
22 5  
23   - @Autowired
24   - SendRecordDao sendRecordDao;
25   -
26   - @Autowired
27   - UserDao userDao;
28   -
29 6 public static void main(String[] args) {
30 7  
31   -// new Test().getData();
32   - File file = new File("C:\\TaoHandong\\copy\\School951\\Student\\505766.jpg");
33   -
34   - try {
35   - Metadata metadata = JpegMetadataReader.readMetadata(file);
36   - for ( Directory directory : metadata.getDirectories() ) {
37   - for (Tag tag : directory.getTags()) {
38   - //格式化输出[directory.getName()] - tag.getTagName() = tag.getDescription()
39   - System.out.format("[%s] - %s = %s\n",
40   - directory.getName(), tag.getTagName(), tag.getDescription());
41   - if (tag.getTagName().contains("Date")){
42   -
43   - SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
44   - System.out.println(tag.getDescription());
45   - Date date= new Date(new Test().getData(tag.getDescription()));
46   - System.out.println(simpleDateFormat.format(date));
47   -
48   - }
49   - }
50   - }
51   -
52   -
53   - } catch (JpegProcessingException e) {
54   - e.printStackTrace();
55   - } catch (IOException e) {
56   - e.printStackTrace();
57   - }
58 8  
59 9 }
60 10  
61   - private String getData(String content) {
62   -
63   - content = content.replace("星期一","Mon");
64   - content = content.replace("星期二","Tues");
65   - content = content.replace("星期三","Wed");
66   - content = content.replace("星期四","Thur");
67   - content = content.replace("星期五","Fri");
68   - content = content.replace("星期六","Sat");
69   - content = content.replace("星期日","Sun");
70   -
71   -
72   - content = content.replace("一月","Jan");
73   - content = content.replace("二月","Feb");
74   - content = content.replace("三月","Mar");
75   - content = content.replace("四月","Apr");
76   - content = content.replace("五月","May");
77   - content = content.replace("六月","Jun");
78   - content = content.replace("七月","Jul");
79   - content = content.replace("八月","Aug");
80   - content = content.replace("九月","Sep");
81   - content = content.replace("十月","Oct");
82   - content = content.replace("十一月","Nov");
83   - content = content.replace("十二月","Dec");
84   -
85   - return content;
86   - }
87 11  
88 12 }
... ...
cloud/dahua/src/main/java/com/example/dahua/async/MyScheduledTask.java
... ... @@ -38,6 +38,7 @@ import java.util.List;
38 38 @EnableScheduling
39 39 public class MyScheduledTask {
40 40  
  41 +
41 42 @Autowired
42 43 SendRecordDao sendRecordDao;
43 44  
... ... @@ -77,7 +78,7 @@ public class MyScheduledTask {
77 78 SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH");
78 79 int hour = Integer.parseInt(simpleDateFormat.format(new Date()));
79 80  
80   - if (hour == 7 && !isCloseYT) {
  81 + /*if (hour == 7 && !isCloseYT) {
81 82 isCloseYT = true;
82 83 close(31, 97);
83 84 }
... ... @@ -85,7 +86,7 @@ public class MyScheduledTask {
85 86 if (hour == 17 && isCloseYT) {
86 87 isCloseYT = false;
87 88 close(30, 97);
88   - }
  89 + }*/
89 90  
90 91 /* if (hour == 6 && !isClose) {
91 92 isClose = true;
... ... @@ -101,7 +102,7 @@ public class MyScheduledTask {
101 102 dealData();
102 103 } else if (hour >= 13 && hour < 14) {
103 104 dealData();
104   - } else if (hour >= 18 || hour < 5) {
  105 + } else if (hour >= 20 || hour < 5) {
105 106 dealData();
106 107 }
107 108  
... ... @@ -121,6 +122,7 @@ public class MyScheduledTask {
121 122 File file = new File(imgFilPath);
122 123 File[] files = file.listFiles();
123 124 Date currentDate = new Date();
  125 + if (null!=files)
124 126 for (int i = 0; i < files.length; i++) {
125 127 File imgFile = files[i];
126 128 String name = imgFile.getName().split("\\.")[0];
... ... @@ -171,7 +173,7 @@ public class MyScheduledTask {
171 173  
172 174 String ip = new Utils().getHostAddress();
173 175 System.out.println("ip:"+ip);
174   - if (ip.startsWith("192"))
  176 + if (ip.startsWith("192")||ip.contains("172.16.247.64"))
175 177 return;
176 178  
177 179 /**
... ...
cloud/dahua/src/main/java/com/example/dahua/async/SendUserInfoTask.java
... ... @@ -42,7 +42,7 @@ public class SendUserInfoTask {
42 42 SendRecordDao sendRecordDao;
43 43  
44 44 @Async("taskExecutor")
45   - public void doTaskOne(String file, List<AttendanceBean> attendanceBeans, UserInfoBean userInfoBean, String schoolId, int failType,int userType) throws Exception {
  45 + public void doTaskOne(String file, List<AttendanceBean> attendanceBeans, UserInfoBean userInfoBean, String schoolId, int failType, int userType) throws Exception {
46 46 File studentFile = new File(file);
47 47 String studentCode = studentFile.getName().split("\\.")[0];
48 48 //判断是否是副卡
... ... @@ -60,13 +60,13 @@ public class SendUserInfoTask {
60 60 sendRecordBean.setSchoolId(Integer.parseInt(schoolId));
61 61 sendRecordBean.setSchoolName(userDao.getSchoolName(schoolId));
62 62 sendRecordBean.setTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
63   - sendRecordBean.setUserType(2);
  63 + sendRecordBean.setUserType(userType);
64 64 sendRecordBean.setNum(userInfoBean.getStudent_num());
65 65 sendRecordBean.setName(userInfoBean.getName());
66 66 sendRecordBean.setImgPath(file);
67 67 sendRecordBean.setCustomerid(userInfoBean.getStudent_id());
68 68 sendRecordBean.setFailType(failType);
69   - sendUserInfoToDev(file, attendanceBeans, userInfoBean, userType+"", sendRecordBean);
  69 + sendUserInfoToDev(file, attendanceBeans, userInfoBean, userType + "", sendRecordBean);
70 70 }
71 71  
72 72 @Async("taskExecutor")
... ... @@ -153,7 +153,7 @@ public class SendUserInfoTask {
153 153  
154 154 if (type == 0 || type == 1) {//学生信息或家长信息
155 155 userInfoBean = userDao.getUserInfo(schoolId, studentCode);
156   - HttpUtils.uploadImgs(studentFile,schoolId,studentCode,clint_type,2);
  156 + HttpUtils.uploadImgs(studentFile, schoolId, studentCode, clint_type, 2);
157 157 } else if (type == 2) {//教师信息
158 158 TeacherBean teacher = userDao.getTeacher(schoolId, studentCode);
159 159 if (null != teacher) {
... ... @@ -164,7 +164,7 @@ public class SendUserInfoTask {
164 164 userInfoBean.setStudentcode(teacher.getNum());
165 165 userInfoBean.setStudent_id(teacher.getTeacher_id());
166 166 }
167   - HttpUtils.uploadImgs(studentFile,schoolId,studentCode,clint_type,1);
  167 + HttpUtils.uploadImgs(studentFile, schoolId, studentCode, clint_type, 1);
168 168 }
169 169  
170 170 //判断用户是否存在
... ... @@ -274,6 +274,7 @@ public class SendUserInfoTask {
274 274 } catch (Exception e) {
275 275 e.printStackTrace();
276 276 }
  277 +
277 278 for (AttendanceBean attendanceBean :
278 279 attendanceBeans) {
279 280 pushCardAndFace(attendanceBean, userInfoBean.getUser_id(), userInfoBean.getStudent_num(), userInfoBean.getName(), memory, sendRecordBean);
... ... @@ -310,16 +311,19 @@ public class SendUserInfoTask {
310 311  
311 312 String cardNum = cardNo(student_num);
312 313 if (bCardFlags != -1) {//修改卡信息
313   - GateModule.deleteCard(bCardFlags, loginHandleLong);
314   - userDao.deleteRecordNo(user_id, bCardFlags);
315   -
316   - bCardFlags = GateModule.insertCard(cardNum, user_id, name, "123456"
317   - , Res.string().getCardStatusInt(1), Res.string().getCardTypeInt(1), 0, 0
318   - , 1, startTime, endTime, loginHandleLong);
319   -
320   - if (bCardFlags != -1) {
321   - int index = userDao.saveRecordNo(user_id, bCardFlags, name, attendanceBean.getClint_id());//存储记录集编号
322   - }
  314 +// GateModule.deleteCard(bCardFlags, loginHandleLong);
  315 + GateModule.modifyCard(bCardFlags,cardNum,user_id,name,"123456",Res.string().getCardStatusInt(1),Res.string().getCardTypeInt(1),
  316 + 0,0,1,startTime,endTime,loginHandleLong);
  317 + userDao.updateRecordNo(user_id,bCardFlags,attendanceBean.getClint_id());
  318 +// userDao.deleteRecordNo(user_id, bCardFlags);
  319 +
  320 +// bCardFlags = GateModule.insertCard(cardNum, user_id, name, "123456"
  321 +// , Res.string().getCardStatusInt(1), Res.string().getCardTypeInt(1), 0, 0
  322 +// , 1, startTime, endTime, loginHandleLong);
  323 +
  324 +// if (bCardFlags != -1) {
  325 +// int index = userDao.saveRecordNo(user_id, bCardFlags, name, attendanceBean.getClint_id());//存储记录集编号
  326 +// }
323 327 bFaceFalgs = GateModule.modifyFaceInfo(user_id, memory, loginHandleLong);
324 328 //卡号添加成功,但是人脸不成功的话,就需要新增人脸
325 329 if (!bFaceFalgs)
... ... @@ -370,7 +374,7 @@ public class SendUserInfoTask {
370 374 if (bCardFlags == -1 && !bFaceFalgs) {
371 375 FileUtils.getInstance().writeLogs("下发人脸和卡号失败:" + cardNum + " " + attendanceBean.getClint_id(), FileUtils.sendUserErrTxt);
372 376 // System.out.println("添加卡信息和人脸失败");
373   - System.out.println("下发人脸和卡号失败" + "sendRecordBean:" + sendRecordBean);
  377 + System.out.println("下发人脸和卡号失败" + "sendRecordBean:" + sendRecordBean.getDeviceID()+" ,"+sendRecordBean.getNum()+","+loginHandleLong+",bCardFlags:"+bCardFlags+"\r\n");
374 378 sendRecordBean.setFailContent("下发人脸和卡号失败");
375 379 sendRecordDao.updateFace(sendRecordBean.getNum(), sendRecordBean.getDeviceID(), sendRecordBean.getFailType(), 7);//更新下发失败状态
376 380 sendRecordBean.setFailType(8);
... ... @@ -381,7 +385,7 @@ public class SendUserInfoTask {
381 385 if (bCardFlags != -1 && !bFaceFalgs) {
382 386 FileUtils.getInstance().writeLogs("下发卡号成功,人脸失败:" + cardNum + " " + attendanceBean.getClint_id(), FileUtils.sendUserErrTxt);
383 387 // System.out.println("添加卡信息成功,添加人脸失败");
384   - System.out.println("customerId:" + sendRecordBean.getCustomerid() + " deviceId:" + sendRecordBean.getDeviceID() + " failType:" + sendRecordBean.getFailType());
  388 + System.out.println("customerId:" + sendRecordBean.getCustomerid() + " deviceId:" + sendRecordBean.getDeviceID() + " failType:" + sendRecordBean.getFailType()+"\r\n");
385 389 sendRecordDao.updateFace(sendRecordBean.getNum(), sendRecordBean.getDeviceID(), sendRecordBean.getFailType(), 5);//更新下发失败状态
386 390 sendRecordBean.setFailContent("下发卡号成功,人脸失败:照片特征值提取失败");
387 391 sendRecordBean.setFailType(5);
... ... @@ -391,7 +395,7 @@ public class SendUserInfoTask {
391 395 // 卡信息已存在,添加人脸成功
392 396 if (bCardFlags == -1 && bFaceFalgs) {
393 397 FileUtils.getInstance().writeLogs("下发人脸成功:" + cardNum + " " + attendanceBean.getClint_id(), FileUtils.sendUserSucTxt);
394   - System.out.println("卡信息已存在,添加人脸成功");
  398 + System.out.println("卡信息已存在,添加人脸成功-----------\n");
395 399 }
396 400 }
397 401  
... ... @@ -412,8 +416,11 @@ public class SendUserInfoTask {
412 416  
413 417 if (sendRecordBean.getFailType() == 5) sendRecordBean.setFailType(8);
414 418  
  419 + String imagePath = sendRecordBean.getImgPath().replace("C:/imgCom",
  420 + String.format("E:\\wwwhtdocs\\smartcampus\\face17e5\\School%s\\%s", sendRecordBean.getSchoolId(), sendRecordBean.getUserType() == 1 ? "Teacher" : "Student"));
  421 +
415 422 sendRecordDao.addFaceFail(sendRecordBean.getCustomerid(), sendRecordBean.getDeviceID(), sendRecordBean.getNum(), sendRecordBean.getName(), sendRecordBean.getTime(),
416   - sendRecordBean.getSchoolName(), sendRecordBean.getImgPath(), sendRecordBean.getSchoolId(), sendRecordBean.getFailContent(), sendRecordBean.getFailType(), sendRecordBean.getUserType(), 22);
  423 + sendRecordBean.getSchoolName(), imagePath , sendRecordBean.getSchoolId(), sendRecordBean.getFailContent(), sendRecordBean.getFailType(), sendRecordBean.getUserType(), 22);
417 424 // }
418 425 }
419 426  
... ... @@ -452,15 +459,15 @@ public class SendUserInfoTask {
452 459  
453 460 for (int i = 0; i < sendRecordBeanList.size(); i++) {
454 461 SendRecordBean sendRecordBean = sendRecordBeanList.get(i);
455   - String imgPath = sendRecordBean.getImgPath().replace("face17e50","face17e5");
  462 + String imgPath = sendRecordBean.getImgPath().replace("face17e50", "face17e5");
456 463 File file = new File(imgPath);
457   - System.out.println("file:"+file.getAbsolutePath());
  464 + System.out.println("file:" + file.getAbsolutePath());
458 465 if (file.exists()) {
459 466 try {
460 467 FileInputStream fileInputStream = new FileInputStream(file);
461 468 String fileName = file.getName();
462   - fileName = fileName.replace("jpg","png");
463   - fileName = fileName.replace("jpeg","png");
  469 + fileName = fileName.replace("jpg", "png");
  470 + fileName = fileName.replace("jpeg", "png");
464 471 File targetFile = new File(targetrFile, fileName);
465 472 if (!targetFile.exists()) targetFile.createNewFile();
466 473 FileOutputStream fileOutputStream = new FileOutputStream(targetFile);
... ... @@ -498,23 +505,30 @@ public class SendUserInfoTask {
498 505 // int bCardFlags = -1;//记录集编号,存在于设备的
499 506 int bCardFlags = userDao.getRecordNo(user_id, deviceId) == null ? -1 : Integer.parseInt(userDao.getRecordNo(user_id, deviceId));
500 507 System.out.println("bCardFlags:" + bCardFlags);
  508 + if (bCardFlags == -1)bCardFlags = 10;
501 509 if (bCardFlags != -1) {
502 510 GateModule.deleteCard(bCardFlags, MyTask.lLongMap.get(deviceId));
503 511 }
504 512  
505 513 }
  514 +
506 515 @Async("taskExecutor")
507   - public void addWeiGen(){
508   - List<String> customerIDs = sendRecordDao.getWGFail();
  516 + public void addWeiGen() {
  517 + //获取到的设备id集合
  518 + List<String> deviceIds = sendRecordDao.getWGFail();
  519 + String url = "http://121.40.109.21:9000/cleanFail?deviceId=";
  520 + RestTemplate restTemplate = new RestTemplate();
509 521  
510   - for (int i = 0; i < customerIDs.size(); i++) {
511   - String customerID = customerIDs.get(i);
512   - addKard(customerID, "2");//微耕
  522 + for (int i = 0; i < deviceIds.size(); i++) {
  523 + String deviceId = deviceIds.get(i);
  524 +// addKard(customerID, "2");//微耕
  525 + String result = restTemplate.getForObject(url + deviceId, String.class);
  526 + System.out.println("微耕result:" + result);
513 527 }
514 528 MyScheduledTask.isSendWeigeng = false;
515 529 }
516 530  
517   - String url = "http://campus.myjxt.com/api/OneCard/UpdateDataBK";
  531 + /* String url = "http://campus.myjxt.com/api/OneCard/UpdateDataBK";
518 532 private synchronized void addKard(String customerId, String TerminalType) {
519 533 StudentBean studentBean = userDao.getStudentUpdate(customerId);
520 534 if (studentBean != null && studentBean.getStudentCode() != null) {
... ... @@ -538,10 +552,10 @@ public class SendUserInfoTask {
538 552 } else if (studentBean != null && studentBean.getStudentCode() == null) {
539 553 // System.out.println(studentBean.getName()+"学籍号不存在");
540 554 }
541   - }
  555 + }*/
542 556  
543 557 @Async("taskExecutor")
544   - public void addHaikangface(){
  558 + public void addHaikangface() {
545 559  
546 560 List<SendRecordBean> sendRecordBeanList = sendRecordDao.getSenFailHK("18", "9");
547 561 RestTemplate restTemplate = new RestTemplate();
... ... @@ -561,28 +575,29 @@ public class SendUserInfoTask {
561 575 userTy = "Parent";
562 576 break;
563 577 }
564   - String filePath = String.format("E:\\wwwhtdocs\\SmartCampus\\face17e5\\School%s\\%s\\%s.jpg", sendRecordBean.getSchoolId(), userTy, userDao.getStudentCode(sendRecordBean.getCustomerid()));
  578 +// String filePath = String.format("E:\\wwwhtdocs\\SmartCampus\\face17e5\\School%s\\%s\\%s.png", sendRecordBean.getSchoolId(), userTy, userDao.getStudentCode(sendRecordBean.getCustomerid()));
  579 + String filePath = sendRecordBean.getImgPath();
565 580 String url = "http://114.55.30.100:8089/facereco/sendStuCardAndImg?card={card}&deviceId={deviceId}&endTime={endTime}&" +
566 581 "filePath={filePath}&name={name}&userType={userType}&validTimeEnabled={validTimeEnabled}&startTime={startTime}";
567 582  
568   - Map<String,Object> map = new HashMap<>();
  583 + Map<String, Object> map = new HashMap<>();
569 584  
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");
  585 + map.put("card", sendRecordBean.getNum());
  586 + map.put("deviceId", sendRecordBean.getDeviceID());
  587 + map.put("endTime", "2033-10-01 10:00:00");
  588 + map.put("filePath", filePath);
  589 + map.put("name", sendRecordBean.getName());
  590 + map.put("userType", userType);
  591 + map.put("validTimeEnabled", "1");
  592 + map.put("startTime", "2019-10-01 10:00:00");
578 593  
579   - ResponseEntity<String> responseEntity = restTemplate.getForEntity(url,String.class,map);
  594 + ResponseEntity<String> responseEntity = restTemplate.getForEntity(url, String.class, map);
580 595  
581   - System.out.println("responseEntity:---------------------------"+map.toString());
  596 + System.out.println("responseEntity:---------------------------" + map.toString());
582 597  
583 598 String result = responseEntity.getBody();
584   - result = result.replace("<Boolean>","");
585   - result = result.replace("</Boolean>","");
  599 + result = result.replace("<Boolean>", "");
  600 + result = result.replace("</Boolean>", "");
586 601  
587 602 boolean result1 = Boolean.parseBoolean(result);
588 603  
... ... @@ -597,7 +612,7 @@ public class SendUserInfoTask {
597 612 }
598 613  
599 614 @Async("taskExecutor")
600   - public void addDahuaFace(){
  615 + public void addDahuaFace() {
601 616  
602 617 List<SendRecordBean> sendRecordBeanList = sendRecordDao.getSenFail("22");
603 618 for (int i = 0; i < sendRecordBeanList.size(); i++) {
... ... @@ -641,7 +656,7 @@ public class SendUserInfoTask {
641 656 if (img.startsWith("http"))
642 657 img = img.replace("http://campus.myjxt.com//", "E://wwwhtdocs/SmartCampus/");
643 658 doTaskOne(img, userDao.getAttendanceBeans(String.valueOf(sendRecordBean.getSchoolId()), "22")
644   - , userInfoBean, sendRecordBean.getSchoolId() + "", sendRecordBean.getFailType(),sendRecordBean.getUserType());
  659 + , userInfoBean, sendRecordBean.getSchoolId() + "", sendRecordBean.getFailType(), sendRecordBean.getUserType());
645 660 }
646 661  
647 662 }
... ...
cloud/dahua/src/main/java/com/example/dahua/control/FileControl.java
1 1 package com.example.dahua.control;
2 2  
  3 +import com.example.dahua.async.SendUserInfoTask;
3 4 import com.example.dahua.bean.UploadImg;
4 5 import com.example.dahua.service.UserService;
5 6 import io.swagger.annotations.Api;
  7 +import io.swagger.annotations.ApiOperation;
6 8 import org.springframework.beans.factory.annotation.Autowired;
  9 +import org.springframework.http.MediaType;
7 10 import org.springframework.web.bind.annotation.*;
8 11 import org.springframework.web.multipart.MultipartFile;
9 12  
... ... @@ -14,12 +17,15 @@ import java.io.IOException;
14 17  
15 18 @RestController
16 19 @Api("文件管理器")
17   -@RequestMapping("file/*")
  20 +@RequestMapping(value = "file/*",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
18 21 public class FileControl {
19 22  
20 23 @Autowired
21 24 UserService userService;
22 25  
  26 + @Autowired
  27 + SendUserInfoTask sendUserInfoTask;
  28 +
23 29 @RequestMapping(method = RequestMethod.POST, value = "uploadImg")
24 30 public String uploadImg(@RequestParam("file") MultipartFile file, @RequestParam("schoolId") String schoolId, @RequestParam("studentCode") String studentCode,
25 31 @RequestParam("clint_type") String clint_type,@RequestParam("userType") int userType) {
... ... @@ -33,7 +39,8 @@ public class FileControl {
33 39 FileOutputStream fileOutputStream = new FileOutputStream(dest);
34 40  
35 41 fileOutputStream.write(file.getBytes());
36   - userService.uploadImgAndUserInfo(dest.getAbsolutePath(), schoolId, studentCode, clint_type,userType);
  42 + fileOutputStream.close();
  43 + userService.uploadImgAndUserInfo(dest.getAbsolutePath(), schoolId, studentCode, clint_type,userType,"");
37 44 return "1";
38 45 } catch (FileNotFoundException e) {
39 46 e.printStackTrace();
... ... @@ -42,4 +49,40 @@ public class FileControl {
42 49 }
43 50 return "0";
44 51 }
  52 +
  53 +
  54 + @RequestMapping(method = RequestMethod.POST, value = "uploadImgToDev")
  55 + public String uploadImgToDev(@RequestParam("file") MultipartFile file, @RequestParam("schoolId") String schoolId, @RequestParam("studentCode") String studentCode,
  56 + @RequestParam("clint_type") String clint_type,@RequestParam("userType") int userType,@RequestParam("devid")String devid) {
  57 + String fileName = file.getOriginalFilename();//文件名
  58 +
  59 + File outFile = new File("C://imgCom");
  60 + if (!outFile.exists()) outFile.mkdirs();
  61 + try {
  62 + File dest = new File(outFile, fileName);
  63 + FileOutputStream fileOutputStream = new FileOutputStream(dest);
  64 +
  65 + fileOutputStream.write(file.getBytes());
  66 + fileOutputStream.close();
  67 + userService.uploadImgAndUserInfo(dest.getAbsolutePath(), schoolId, studentCode, clint_type,userType,devid);
  68 + return "1";
  69 + } catch (FileNotFoundException e) {
  70 + e.printStackTrace();
  71 + } catch (IOException e) {
  72 + e.printStackTrace();
  73 + }
  74 + return "0";
  75 + }
  76 +
  77 + @RequestMapping(value = "deleteFace", method = RequestMethod.GET)
  78 + @ApiOperation("删除人脸")
  79 + public void deleteFace(@RequestParam("cardNum") String cardNum, @RequestParam("deviceId") String deviceId) {
  80 +
  81 + sendUserInfoTask.deleteFace(cardNum, deviceId);
  82 +
  83 + }
  84 +
  85 +
  86 +
  87 +
45 88 }
... ...
cloud/dahua/src/main/java/com/example/dahua/control/UserControl.java
... ... @@ -6,6 +6,7 @@ import com.example.dahua.async.SendUserInfoTask;
6 6 import com.example.dahua.lib.CompressPic;
7 7 import com.example.dahua.service.UserService;
8 8 import com.example.dahua.utils.*;
  9 +import com.sincere.common.util.AuthService;
9 10 import io.swagger.annotations.Api;
10 11 import io.swagger.annotations.ApiImplicitParam;
11 12 import io.swagger.annotations.ApiImplicitParams;
... ... @@ -36,11 +37,9 @@ import java.util.*;
36 37 */
37 38 @RestController("/user/")
38 39 @Api(tags = "下发用户信息")
39   -@RequestMapping("/user/")
  40 +@RequestMapping(value = "/user/*",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
40 41 public class UserControl {
41 42  
42   - private int count = 0;
43   -
44 43 @Autowired
45 44 UserService userService;
46 45  
... ... @@ -50,14 +49,12 @@ public class UserControl {
50 49 @Autowired
51 50 MyTask myTasks;
52 51  
53   -// @Value("${haikangfaceurl}")
54   -// private String haikangfaceurl;
55 52  
56 53 @RequestMapping(value = "uploadImgAndUserInfo", method = RequestMethod.GET)
57 54 @ApiOperation(value = "上传用户信息")
58 55 public boolean uploadImgAndUserInfo(@RequestParam("file") String file, @RequestParam("schoolId") String schoolId, @RequestParam("studentCode") String studentCode, @RequestParam("clint_type") String clint_type) {
59 56 // return userService.uploadImgAndUserInfo(file, schoolId, studentCode, clint_type);
60   - return HttpUtils.uploadImgs(new File(file),schoolId,studentCode,clint_type,2);
  57 + return HttpUtils.uploadImgs(new File(file),schoolId,studentCode,clint_type,file.contains("Teacher")?1:2);
61 58 }
62 59  
63 60  
... ... @@ -364,13 +361,13 @@ public class UserControl {
364 361 }
365 362 }
366 363  
367   - @RequestMapping(value = "deleteFace", method = RequestMethod.GET)
368   - @ApiOperation("删除人脸")
369   - public void deleteFace(@RequestParam("cardNum") String cardNum, @RequestParam("deviceId") String deviceId) {
370   -
371   - sendUserInfoTask.deleteFace(cardNum, deviceId);
372   -
373   - }
  364 +// @RequestMapping(value = "deleteFace", method = RequestMethod.GET)
  365 +// @ApiOperation("删除人脸")
  366 +// public void deleteFace(@RequestParam("cardNum") String cardNum, @RequestParam("deviceId") String deviceId) {
  367 +//
  368 +// sendUserInfoTask.deleteFace(cardNum, deviceId);
  369 +//
  370 +// }
374 371  
375 372  
376 373 @RequestMapping(value = "movePic", method = RequestMethod.GET)
... ... @@ -447,12 +444,12 @@ public class UserControl {
447 444 } catch (IOException e) {
448 445 e.printStackTrace();
449 446 }
450   -return "解析失败";
  447 + return "解析失败";
451 448 }
452 449  
453 450  
454 451  
455   - private String url = "https://aip.baidubce.com/rest/2.0/ocr/v1/general_basic?access_token=24.12f07855bae00621f319d10f00f6aaa2.2592000.1576727813.282335-15990462";
  452 + private String url = "https://aip.baidubce.com/rest/2.0/ocr/v1/general_basic?access_token="+ AuthService.getAuth();
456 453  
457 454 private String getAnswer(String imgUrl, int type) {
458 455 RestTemplate restTemplate = new RestTemplate();
... ...
cloud/dahua/src/main/java/com/example/dahua/dao/UserDao.java
... ... @@ -17,6 +17,9 @@ public interface UserDao {
17 17 @Select("select * from SZ_Attendance where school_id = #{school_id} and clint_type = #{clint_type}")
18 18 List<AttendanceBean> getAttendanceBeans(@Param("school_id")String school_id,@Param("clint_type")String clint_type);
19 19  
  20 + @Select("select * from SZ_Attendance where school_id = #{school_id} and clint_type = #{clint_type} and clint_id = #{clint_id}")
  21 + List<AttendanceBean> getAttendanceBeanWithId(@Param("school_id")String school_id,@Param("clint_type")String clint_type,@Param("clint_id")String clint_id);
  22 +
20 23 @Select(" select * from SZ_V_School_Student where school_id = #{school_id} and studentcode = #{studentcode}")
21 24 UserInfoBean getUserInfo(@Param("school_id")String school_id,@Param("studentcode")String studentcode);
22 25  
... ... @@ -46,6 +49,9 @@ public interface UserDao {
46 49 @Delete("delete from SZ_Student_RecoderNo where user_id = #{user_id} and recordNo = #{recordNo}")
47 50 void deleteRecordNo(@Param("user_id") String user_id, @Param("recordNo") int recordNo);
48 51  
  52 + @Update("update SZ_Student_RecoderNo set user_id = #{user_id} where deviceId = #{deviceId} and recordNo = #{recordNo}")
  53 + void updateRecordNo(@Param("user_id") String user_id, @Param("recordNo") int recordNo,@Param("deviceId")String deviceId);
  54 +
49 55  
50 56 @Select("select clint_id from SZ_Attendance where clint_type = #{clint_type} and school_id = #{school_id}")
51 57 List<String> getDeviceIds(@Param("clint_type")String clint_type ,@Param("school_id") int school_id);
... ...
cloud/dahua/src/main/java/com/example/dahua/service/UserService.java
... ... @@ -16,7 +16,7 @@ public interface UserService {
16 16 * @param clint_type
17 17 * @return
18 18 */
19   - List<AttendanceBean> getAttendanceBeans(String schoolId,String clint_type);
  19 + List<AttendanceBean> getAttendanceBeans(String schoolId,String clint_type,String devid);
20 20  
21 21 /**
22 22 * 获取学生基本信息
... ... @@ -34,7 +34,7 @@ public interface UserService {
34 34 * @return
35 35 */
36 36 // boolean uploadImgAndUserInfo(MultipartFile file,String schoolId,String studentCode,String clint_type);
37   - boolean uploadImgAndUserInfo(String file,String schoolId,String studentCode,String clint_type,int userType);
  37 + boolean uploadImgAndUserInfo(String file,String schoolId,String studentCode,String clint_type,int userType,String devid);
38 38  
39 39  
40 40 /**
... ...
cloud/dahua/src/main/java/com/example/dahua/service/UserServiceImp.java
... ... @@ -5,6 +5,7 @@ import com.example.dahua.bean.AttendanceBean;
5 5 import com.example.dahua.bean.TeacherBean;
6 6 import com.example.dahua.bean.UserInfoBean;
7 7 import com.example.dahua.dao.UserDao;
  8 +import org.apache.commons.lang.StringUtils;
8 9 import org.springframework.beans.factory.annotation.Autowired;
9 10 import org.springframework.stereotype.Repository;
10 11 import org.springframework.stereotype.Service;
... ... @@ -22,7 +23,10 @@ public class UserServiceImp implements UserService {
22 23 SendUserInfoTask myTask;
23 24  
24 25 @Override
25   - public List<AttendanceBean> getAttendanceBeans(String schoolId, String clint_type) {
  26 + public List<AttendanceBean> getAttendanceBeans(String schoolId, String clint_type,String devid) {
  27 +
  28 + if (!StringUtils.isEmpty(devid))return userDao.getAttendanceBeanWithId(schoolId,clint_type,devid);
  29 +
26 30 return userDao.getAttendanceBeans(schoolId, clint_type);
27 31 }
28 32  
... ... @@ -41,9 +45,9 @@ public class UserServiceImp implements UserService {
41 45 * @return
42 46 */
43 47 @Override
44   - public boolean uploadImgAndUserInfo(String file, String schoolId, String studentCode, String clint_type, int userType) {
  48 + public boolean uploadImgAndUserInfo(String file, String schoolId, String studentCode, String clint_type, int userType,String devid) {
  49 + List<AttendanceBean> attendanceBeans = getAttendanceBeans(schoolId, clint_type,devid);//获取学校下的大华设备
45 50  
46   - List<AttendanceBean> attendanceBeans = getAttendanceBeans(schoolId, clint_type);//获取学校下的大华设备
47 51 UserInfoBean userInfoBean = null;
48 52 try {
49 53 if (userType == 2) {
... ...
cloud/dahua/src/main/java/com/example/dahua/xiananDao/SendRecordDao.java
... ... @@ -22,59 +22,62 @@ public interface SendRecordDao {
22 22  
23 23 @Insert("insert into Face_SendSuccess values(#{deviceID},#{customerid},#{num},#{name},#{time},#{schoolName},#{imgPath},#{schoolId},#{userType},#{deviceType})")
24 24 int addFaceSuccess(@Param("customerid") String customerid, @Param("deviceID") String deviceID, @Param("num") String num, @Param("name") String name,
25   - @Param("time") String time, @Param("schoolName") String schoolName, @Param("imgPath") String imgPath, @Param("schoolId") int schoolId,
26   - @Param("userType") int userType,@Param("deviceType")int deviceType);
  25 + @Param("time") String time, @Param("schoolName") String schoolName, @Param("imgPath") String imgPath, @Param("schoolId") int schoolId,
  26 + @Param("userType") int userType, @Param("deviceType") int deviceType);
27 27  
28 28 @Select("select * from Face_SendSuccess where num = #{num} and deviceID = #{deviceID} and schoolId = #{schoolId}")
29   - List<SendRecordBean> getFaceSucceIsexit(@Param("deviceID") String clint_id, @Param("schoolId") String school_id,@Param("num") String num);
  29 + List<SendRecordBean> getFaceSucceIsexit(@Param("deviceID") String clint_id, @Param("schoolId") String school_id, @Param("num") String num);
30 30  
31 31 @Delete("delete Face_SendSuccess where num = #{num} and deviceID = #{deviceID} ")
32   - void deleteFaceSuccess(@Param("deviceID") String clint_id,@Param("num") String num);
  32 + void deleteFaceSuccess(@Param("deviceID") String clint_id, @Param("num") String num);
33 33  
34 34 @Update("update Face_SendSuccess set time = #{time} where num = #{num} and deviceID = #{deviceID} ")
35   - void updateFaceSuccess(@Param("time")String time,@Param("deviceID") String clint_id,@Param("num") String num);
  35 + void updateFaceSuccess(@Param("time") String time, @Param("deviceID") String clint_id, @Param("num") String num);
36 36  
37 37  
38 38 @Insert("insert into Face_SendFail values(#{deviceID},#{customerid},#{num},#{name},#{time},#{schoolName},#{imgPath},#{schoolId},#{failContent},#{failType},#{userType},#{deviceType})")
39 39 void addFaceFail(@Param("customerid") String customerid, @Param("deviceID") String deviceID, @Param("num") String num, @Param("name") String name,
40 40 @Param("time") String time, @Param("schoolName") String schoolName, @Param("imgPath") String imgPath, @Param("schoolId") int schoolId, @Param("failContent") String failContent,
41   - @Param("failType") int failType, @Param("userType") int userType,@Param("deviceType")int deviceType);
  41 + @Param("failType") int failType, @Param("userType") int userType, @Param("deviceType") int deviceType);
42 42  
43 43  
44 44 @Select("select * from Face_SendFail where deviceType = #{deviceType}")
45   - List<SendRecordBean> getSenFail(@Param("deviceType")String deviceType);
  45 + List<SendRecordBean> getSenFail(@Param("deviceType") String deviceType);
46 46  
47 47 @Select("select * from Face_SendFail where deviceType = #{deviceType} and failType = #{failType}")
48   - List<SendRecordBean> getSenFailHK(@Param("deviceType")String deviceType,@Param("failType")String failType);
  48 + List<SendRecordBean> getSenFailHK(@Param("deviceType") String deviceType, @Param("failType") String failType);
  49 +
  50 +// @Select("select a.customerID from [dbo].[WG_SendFail] a inner join DBlan137.smartcampus.dbo.SZ_Attendance b on a.deviceID=b.clint_id and b.isConnection=1 order by createTime desc")
  51 +// List<String> getWGFail();
49 52  
50   - @Select("select a.customerID from [dbo].[WG_SendFail] a inner join DBlan137.smartcampus.dbo.SZ_Attendance b on a.deviceID=b.clint_id and b.isConnection=1 order by createTime desc")
51   - List<String> getWGFail();
52 53  
  54 + @Select("select DISTINCT a.deviceId from [dbo].[WG_SendFail] a inner join DBlan137.smartcampus.dbo.SZ_Attendance b on a.deviceID=b.clint_id and b.isConnection=1")
  55 + List<String> getWGFail();
53 56  
54 57 @Select("select Top(1) deviceID from Face_SendFail where deviceID = #{deviceID} and schoolId = #{schoolId}")
55 58 String getFailIsExit(@Param("deviceID") String clint_id, @Param("schoolId") String school_id);
56 59  
57 60 @Select("select Top(1) Name from Face_SendFail where deviceID = #{deviceID} and num = #{num} and failType = #{failType}")
58   - String getFailNameIsExit(@Param("deviceID") String deviceID,@Param("num") String num, @Param("failType") int failType);
  61 + String getFailNameIsExit(@Param("deviceID") String deviceID, @Param("num") String num, @Param("failType") int failType);
59 62  
60 63 @Select("select * from Face_SendFail where deviceID = #{deviceID} and customerid = #{customerid}")
61   - List<SendRecordBean> getFaceFailIsExit(@Param("deviceID") String deviceID,@Param("customerid") String customerid);
  64 + List<SendRecordBean> getFaceFailIsExit(@Param("deviceID") String deviceID, @Param("customerid") String customerid);
62 65  
63 66 @Delete("delete Face_SendFail where deviceID = #{deviceID} and num = #{num}")
64 67 void deleteFaceFail(@Param("num") String num, @Param("deviceID") String deviceID);
65 68  
66 69 @Update("update Face_SendFail set failType = #{upfailType} where num = #{num} and deviceID = #{deviceID} and failType = #{failType}")
67   - void updateFace(@Param("num") String num, @Param("deviceID") String deviceID, @Param("failType") int failType,@Param("upfailType") int upfailType);
  70 + void updateFace(@Param("num") String num, @Param("deviceID") String deviceID, @Param("failType") int failType, @Param("upfailType") int upfailType);
68 71  
69 72 @Select("select schoolName from Face_SendFail where schoolId = #{schoolId} and failType = #{failType}")
70 73 String getSchoolDevice(@Param("schoolId") int schoolId, @Param("failType") int failType);
71 74  
72 75 @Select("select * from Face_SendFail where schoolId = #{schoolId} and userType = #{userType} and deviceID = #{deviceID}")
73   - List<SendRecordBean> getFaceFails(@Param("userType")int userType,@Param("schoolId")int schoolId,@Param("deviceID")String deviceID);
  76 + List<SendRecordBean> getFaceFails(@Param("userType") int userType, @Param("schoolId") int schoolId, @Param("deviceID") String deviceID);
74 77  
75 78 @Insert("insert into Face_Recoder values(#{deviceId},#{user_id},#{name},#{imgurl},#{inOrOut},#{time},#{cardNum})")
76   - void addFaceRecoder(@Param("deviceId") String deviceId, @Param("user_id")String user_id, @Param("name")String name,
77   - @Param("imgurl")String imgurl, @Param("inOrOut")int inOrOut, @Param("time")String time,
78   - @Param("cardNum")String cardNum);
  79 + void addFaceRecoder(@Param("deviceId") String deviceId, @Param("user_id") String user_id, @Param("name") String name,
  80 + @Param("imgurl") String imgurl, @Param("inOrOut") int inOrOut, @Param("time") String time,
  81 + @Param("cardNum") String cardNum);
79 82 }
80 83  
... ...
cloud/dahua/src/test/java/com/example/dahua/DahuaApplicationTests.java
... ... @@ -311,13 +311,13 @@ public class DahuaApplicationTests {
311 311 @Test
312 312 public void test2() {
313 313  
314   - RestTemplate restTemplate = new RestTemplate();
  314 + /* RestTemplate restTemplate = new RestTemplate();
315 315  
316 316  
317 317 String url = "http://localhost:8991/user/checkFace?url=C:\\Users\\taohandong\\Pictures\\test.jpg";
318 318  
319 319  
320   - System.out.println("result:"+ restTemplate.getForObject(url,String.class));
  320 + System.out.println("result:"+ restTemplate.getForObject(url,String.class));*/
321 321  
322 322  
323 323 }
... ... @@ -325,6 +325,12 @@ public class DahuaApplicationTests {
325 325 @Test
326 326 public void test1() {
327 327  
  328 +
  329 + String url = "http://121.40.109.21:9000/cleanFail?deviceId=";
  330 + RestTemplate restTemplate = new RestTemplate();
  331 +
  332 + String result = restTemplate.getForObject(url+"253164293",String.class);
  333 +System.out.println("result:"+result);
328 334 /* try {
329 335 BufferedReader bufferedReader = new BufferedReader(new FileReader("C:\\TaoHandong\\copy\\宿舍.txt"));
330 336 String content = null;
... ...
cloud/geteway/pom.xml
... ... @@ -7,7 +7,7 @@
7 7 <artifactId>cloud</artifactId>
8 8 <version>1.0.0</version>
9 9 </parent>
10   - <groupId>com.example</groupId>
  10 + <groupId>com.example.geteway</groupId>
11 11 <artifactId>geteway</artifactId>
12 12 <version>1.0.0</version>
13 13 <name>geteway</name>
... ... @@ -19,39 +19,41 @@
19 19 </properties>
20 20  
21 21 <dependencies>
22   -
  22 + <!--gateway 网关依赖,内置webflux 依赖-->
23 23 <dependency>
24 24 <groupId>org.springframework.cloud</groupId>
25   - <artifactId>spring-cloud-starter-netflix-zuul</artifactId>
  25 + <artifactId>spring-cloud-starter-gateway</artifactId>
26 26 </dependency>
27   -
28 27 <dependency>
29   - <groupId>io.springfox</groupId>
30   - <artifactId>springfox-swagger2</artifactId>
31   - <version>2.9.2</version>
  28 + <groupId>org.springframework.boot</groupId>
  29 + <artifactId>spring-boot-starter-data-redis-reactive</artifactId>
32 30 </dependency>
33   -
34 31 <dependency>
35 32 <groupId>io.springfox</groupId>
36 33 <artifactId>springfox-swagger-ui</artifactId>
37 34 <version>2.9.2</version>
38 35 </dependency>
39   -
40   -
41 36 <dependency>
42   - <groupId>org.springframework.boot</groupId>
43   - <artifactId>spring-boot-starter-test</artifactId>
44   - <scope>test</scope>
  37 + <groupId>io.springfox</groupId>
  38 + <artifactId>springfox-swagger2</artifactId>
  39 + <version>2.9.2</version>
45 40 </dependency>
46 41 </dependencies>
47 42  
48   - <build>
49   - <plugins>
50   - <plugin>
51   - <groupId>org.springframework.boot</groupId>
52   - <artifactId>spring-boot-maven-plugin</artifactId>
53   - </plugin>
54   - </plugins>
55   - </build>
  43 +<!-- <build>-->
  44 +<!-- <plugins>-->
  45 +<!-- <plugin>-->
  46 +<!-- <groupId>org.springframework.boot</groupId>-->
  47 +<!-- <artifactId>spring-boot-maven-plugin</artifactId>-->
  48 +<!-- <executions>-->
  49 +<!-- <execution>-->
  50 +<!-- <goals>-->
  51 +<!-- <goal>repackage</goal>-->
  52 +<!-- </goals>-->
  53 +<!-- </execution>-->
  54 +<!-- </executions>-->
  55 +<!-- </plugin>-->
  56 +<!-- </plugins>-->
  57 +<!-- </build>-->
56 58  
57 59 </project>
... ...
cloud/geteway/src/main/java/com/example/geteway/DocumentationConfig.java
... ... @@ -1,53 +0,0 @@
1   -package com.example.geteway;
2   -
3   -import org.springframework.cloud.netflix.zuul.filters.Route;
4   -import org.springframework.cloud.netflix.zuul.filters.RouteLocator;
5   -import org.springframework.context.annotation.Primary;
6   -import org.springframework.stereotype.Component;
7   -import springfox.documentation.swagger.web.SwaggerResource;
8   -import springfox.documentation.swagger.web.SwaggerResourcesProvider;
9   -
10   -import java.util.ArrayList;
11   -import java.util.List;
12   -
13   -@Component
14   -@Primary
15   -public class DocumentationConfig implements SwaggerResourcesProvider {
16   -
17   - private RouteLocator routeLocator;
18   -
19   - public DocumentationConfig(RouteLocator routeLocator){
20   - this.routeLocator = routeLocator;
21   - }
22   -
23   - @Override
24   - public List<SwaggerResource> get() {
25   -
26   - List resources = new ArrayList();
27   -
28   - List<Route> routes = routeLocator.getRoutes();
29   -
30   - System.out.println("routes:"+routes.toString());
31   -
32   - for (Route route :
33   - routes) {
34   - resources.add(swaggerResource(route.getId(), route.getFullPath().replace("**", "v2/api-docs"), "1.0"));
35   - }
36   -
37   -// resources.add(swaggerResource("海康指纹接口","/mygateway/haikangserver/v2/api-docs","1.0"));
38   -
39   -// resources.add(swaggerResource("大华人脸接口","","1.0"));
40   -
41   - return resources;
42   - }
43   -
44   - private SwaggerResource swaggerResource(String name,String location,String version){
45   -
46   - SwaggerResource swaggerResource = new SwaggerResource();
47   - swaggerResource.setName(name);
48   - swaggerResource.setLocation(location);
49   - swaggerResource.setSwaggerVersion(version);
50   - return swaggerResource;
51   -
52   - }
53   -}
cloud/geteway/src/main/java/com/example/geteway/GetewayApplication.java
... ... @@ -2,20 +2,12 @@ package com.example.geteway;
2 2  
3 3 import org.springframework.boot.SpringApplication;
4 4 import org.springframework.cloud.client.SpringCloudApplication;
5   -import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
6   -import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
7   -import org.springframework.context.annotation.Bean;
8   -import org.springframework.web.cors.CorsConfiguration;
9   -import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
10   -import org.springframework.web.filter.CorsFilter;
11 5  
12 6 /**
13 7 * 统一网关配置
14 8 * 通过服务路由的功能,在对外提供服务的时候,只需要通过暴露Zuul中配置的调用地址就可以让调用方统一的来访问我们的服务;
15 9 */
16 10 @SpringCloudApplication
17   -@EnableDiscoveryClient
18   -@EnableZuulProxy
19 11 public class GetewayApplication {
20 12  
21 13 public static void main(String[] args) {
... ... @@ -23,18 +15,4 @@ public class GetewayApplication {
23 15 }
24 16  
25 17  
26   - // 跨域访问
27   - @Bean
28   - public CorsFilter corsFilter() {
29   - final UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
30   - final CorsConfiguration config = new CorsConfiguration();
31   - config.setAllowCredentials(true);
32   - config.addAllowedOrigin("*");
33   - config.addAllowedHeader("*");
34   - config.addAllowedMethod("*");
35   - config.setMaxAge(3600L);
36   - source.registerCorsConfiguration("/**", config);
37   - return new CorsFilter(source);
38   - }
39   -
40 18 }
... ...
cloud/geteway/src/main/java/com/example/geteway/Swagger2.java
... ... @@ -1,37 +0,0 @@
1   -package com.example.geteway;
2   -
3   -import org.springframework.context.annotation.Bean;
4   -import org.springframework.context.annotation.Configuration;
5   -import springfox.documentation.builders.ApiInfoBuilder;
6   -import springfox.documentation.builders.PathSelectors;
7   -import springfox.documentation.builders.RequestHandlerSelectors;
8   -import springfox.documentation.service.ApiInfo;
9   -import springfox.documentation.spi.DocumentationType;
10   -import springfox.documentation.spring.web.plugins.Docket;
11   -import springfox.documentation.swagger2.annotations.EnableSwagger2;
12   -
13   -@Configuration
14   -@EnableSwagger2
15   -public class Swagger2 {
16   -
17   - @Bean
18   - public Docket createRestApi() {
19   - return new Docket(DocumentationType.SWAGGER_2)
20   - .apiInfo(apiInfo())
21   - .select()
22   - .apis(RequestHandlerSelectors.basePackage("com.example.geteway.control"))
23   - .paths(PathSelectors.any())
24   - .build();
25   - }
26   -
27   - private ApiInfo apiInfo() {
28   - return new ApiInfoBuilder()
29   - .title("网关服务统一接口")
30   - .contact("sincere")
31   - .description("")
32   - .termsOfServiceUrl("")
33   - .version("1.0")
34   - .build();
35   - }
36   -
37   -}
cloud/geteway/src/main/java/com/example/geteway/client/config/SwaggerProvider.java 0 → 100644
... ... @@ -0,0 +1,48 @@
  1 +package com.example.geteway.client.config;
  2 +
  3 +import lombok.AllArgsConstructor;
  4 +import org.springframework.cloud.gateway.config.GatewayProperties;
  5 +import org.springframework.cloud.gateway.route.RouteLocator;
  6 +import org.springframework.cloud.gateway.support.NameUtils;
  7 +import org.springframework.context.annotation.Primary;
  8 +import org.springframework.stereotype.Component;
  9 +import springfox.documentation.swagger.web.SwaggerResource;
  10 +import springfox.documentation.swagger.web.SwaggerResourcesProvider;
  11 +
  12 +import java.util.ArrayList;
  13 +import java.util.List;
  14 +
  15 +/**
  16 + * @author Sywd
  17 + */
  18 +@Component
  19 +@Primary
  20 +@AllArgsConstructor
  21 +public class SwaggerProvider implements SwaggerResourcesProvider {
  22 + public static final String API_URI = "/v2/api-docs";
  23 + private final RouteLocator routeLocator;
  24 + private final GatewayProperties gatewayProperties;
  25 +
  26 +
  27 + @Override
  28 + public List<SwaggerResource> get() {
  29 + List<SwaggerResource> resources = new ArrayList<>();
  30 + List<String> routes = new ArrayList<>();
  31 + routeLocator.getRoutes().subscribe(route -> routes.add(route.getId()));
  32 + gatewayProperties.getRoutes().stream().filter(routeDefinition -> routes.contains(routeDefinition.getId()))
  33 + .forEach(routeDefinition -> routeDefinition.getPredicates().stream()
  34 + .filter(predicateDefinition -> ("Path").equalsIgnoreCase(predicateDefinition.getName()))
  35 + .forEach(predicateDefinition -> resources.add(swaggerResource(routeDefinition.getId(),
  36 + predicateDefinition.getArgs().get(NameUtils.GENERATED_NAME_PREFIX + "0")
  37 + .replace("/**", API_URI)))));
  38 + return resources;
  39 + }
  40 +
  41 + private SwaggerResource swaggerResource(String name, String location) {
  42 + SwaggerResource swaggerResource = new SwaggerResource();
  43 + swaggerResource.setName(name);
  44 + swaggerResource.setLocation(location);
  45 + swaggerResource.setSwaggerVersion("2.0");
  46 + return swaggerResource;
  47 + }
  48 +}
... ...
cloud/geteway/src/main/java/com/example/geteway/client/filter/SwaggerHeaderFilter.java 0 → 100644
... ... @@ -0,0 +1,36 @@
  1 +package com.example.geteway.client.filter;
  2 +
  3 +import com.example.geteway.client.config.SwaggerProvider;
  4 +import org.springframework.cloud.gateway.filter.GatewayFilter;
  5 +import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory;
  6 +import org.springframework.http.server.reactive.ServerHttpRequest;
  7 +import org.springframework.stereotype.Component;
  8 +import org.springframework.util.StringUtils;
  9 +import org.springframework.web.server.ServerWebExchange;
  10 +
  11 +/**
  12 + * Spring 已修复该功能
  13 + */
  14 +@Component
  15 +@Deprecated
  16 +public class SwaggerHeaderFilter extends AbstractGatewayFilterFactory {
  17 + private static final String HEADER_NAME = "X-Forwarded-Prefix";
  18 +
  19 + @Override
  20 + public GatewayFilter apply(Object config) {
  21 + return (exchange, chain) -> {
  22 + ServerHttpRequest request = exchange.getRequest();
  23 + String path = request.getURI().getPath();
  24 + if (!StringUtils.endsWithIgnoreCase(path, SwaggerProvider.API_URI)) {
  25 + return chain.filter(exchange);
  26 + }
  27 +
  28 + String basePath = path.substring(0, path.lastIndexOf(SwaggerProvider.API_URI));
  29 +
  30 +
  31 + ServerHttpRequest newRequest = request.mutate().header(HEADER_NAME, basePath).build();
  32 + ServerWebExchange newExchange = exchange.mutate().request(newRequest).build();
  33 + return chain.filter(newExchange);
  34 + };
  35 + }
  36 +}
... ...
cloud/geteway/src/main/java/com/example/geteway/client/handler/SwaggerHandler.java 0 → 100644
... ... @@ -0,0 +1,45 @@
  1 +package com.example.geteway.client.handler;
  2 +
  3 +import org.springframework.beans.factory.annotation.Autowired;
  4 +import org.springframework.http.HttpStatus;
  5 +import org.springframework.http.ResponseEntity;
  6 +import org.springframework.web.bind.annotation.GetMapping;
  7 +import org.springframework.web.bind.annotation.RequestMapping;
  8 +import org.springframework.web.bind.annotation.RestController;
  9 +import reactor.core.publisher.Mono;
  10 +import springfox.documentation.swagger.web.*;
  11 +
  12 +import java.util.Optional;
  13 +
  14 +@RestController
  15 +@RequestMapping("/swagger-resources")
  16 +public class SwaggerHandler {
  17 + @Autowired(required = false)
  18 + private SecurityConfiguration securityConfiguration;
  19 + @Autowired(required = false)
  20 + private UiConfiguration uiConfiguration;
  21 + private final SwaggerResourcesProvider swaggerResources;
  22 +
  23 + @Autowired
  24 + public SwaggerHandler(SwaggerResourcesProvider swaggerResources) {
  25 + this.swaggerResources = swaggerResources;
  26 + }
  27 +
  28 +
  29 + @GetMapping("/configuration/security")
  30 + public Mono<ResponseEntity<SecurityConfiguration>> securityConfiguration() {
  31 + return Mono.just(new ResponseEntity<>(
  32 + Optional.ofNullable(securityConfiguration).orElse(SecurityConfigurationBuilder.builder().build()), HttpStatus.OK));
  33 + }
  34 +
  35 + @GetMapping("/configuration/ui")
  36 + public Mono<ResponseEntity<UiConfiguration>> uiConfiguration() {
  37 + return Mono.just(new ResponseEntity<>(
  38 + Optional.ofNullable(uiConfiguration).orElse(UiConfigurationBuilder.builder().build()), HttpStatus.OK));
  39 + }
  40 +
  41 + @GetMapping("")
  42 + public Mono<ResponseEntity> swaggerResources() {
  43 + return Mono.just((new ResponseEntity<>(swaggerResources.get(), HttpStatus.OK)));
  44 + }
  45 +}
... ...
cloud/geteway/src/main/resources/application.yaml
... ... @@ -1,56 +0,0 @@
1   -server:
2   - port: 8083
3   -
4   -eureka:
5   - client:
6   - fetch-registry: true
7   - register-with-eureka: true
8   - service-url:
9   -# defaultZone: http://localhost:8761/eureka/
10   - defaultZone: http://121.40.109.21:8761/eureka/,http://121.40.109.21:8762/eureka/
11   - instance:
12   - hostname: localhost
13   - lease-expiration-duration-in-seconds: 90
14   - lease-renewal-interval-in-seconds: 30
15   - prefer-ip-address: true
16   -
17   -spring:
18   - application:
19   - name: sincere_geteway
20   -
21   -
22   -zuul:
23   - routes:
24   - api-dahua-url:
25   - path: /dahua/**
26   - serviceId: dahuaserver
27   - api-haikang-url:
28   - path: /haikang/**
29   - serviceId: haikangserver
30   - api-iot-url:
31   - path: /iot/**
32   - serviceId: NetCoreService
33   - api-mypulsar-url:
34   - path: /mypulsar/**
35   - serviceId: mypulsar
36   - prefix: /mygateway
37   -
38   -
39   -ribbon:
40   - eureka:
41   - enabled: false
42   -
43   -haikangserver:
44   - ribbon:
45   - listOfServers: http://121.40.109.21:9898
46   -
47   -dahuaserver:
48   - ribbon:
49   - listOfServers: http://114.55.30.100:8991
50   -
51   -mypulsar:
52   - ribbon:
53   - listOfServers: http://121.40.109.21:10009
54   -
55   -
56   -
cloud/geteway/src/main/resources/application.yml 0 → 100644
... ... @@ -0,0 +1,23 @@
  1 +eureka:
  2 + client:
  3 + fetch-registry: true
  4 + register-with-eureka: true
  5 + service-url:
  6 +# defaultZone: http://localhost:8761/eureka/
  7 + defaultZone: http://localhost:8761/eureka/,http://localhost:8762/eureka/
  8 + instance:
  9 + hostname: localhost
  10 + lease-expiration-duration-in-seconds: 90
  11 + lease-renewal-interval-in-seconds: 10
  12 + prefer-ip-address: true
  13 +
  14 +spring:
  15 + cloud:
  16 + gateway:
  17 + routes:
  18 + - id: haikangserver
  19 + uri: lb://haikangserver
  20 + predicates:
  21 + - Path=/haikangserver/**
  22 + filters:
  23 + - StripPrefix=1
... ...
cloud/geteway/src/main/resources/bootstrap.yml 0 → 100644
... ... @@ -0,0 +1,23 @@
  1 +#端口
  2 +server:
  3 + port: 8083
  4 +
  5 +#服务名称
  6 +spring:
  7 + application:
  8 + name: sincere_geteway
  9 + main:
  10 + allow-bean-definition-overriding: true
  11 +
  12 +
  13 +management:
  14 + endpoints:
  15 + web:
  16 + exposure:
  17 + include: "*"
  18 + endpoint:
  19 + health:
  20 + show-details: always
  21 +
  22 +
  23 +
0 24 \ No newline at end of file
... ...
cloud/haikangface/src/main/java/com/sincere/haikangface/CMSServer.java
... ... @@ -115,7 +115,7 @@ public class CMSServer implements ApplicationRunner {
115 115 public class FRegisterCallBack implements HCEHomeCMS.DEVICE_REGISTER_CB {
116 116 public boolean invoke(NativeLong lUserID, int dwDataType, Pointer pOutBuffer, int dwOutLen, HCEHomeCMS.NET_EHOME_SERVER_INFO pInBuffer, int dwInLen, Pointer pUser) {
117 117 String deviceId = "";
118   -// System.out.println("dwDataType:" + dwDataType);
  118 + System.out.println("dwDataType:" + dwDataType);
119 119 if (dwDataType == 0) {
120 120 HCEHomeCMS.NET_EHOME_DEV_REG_INFO strDevRegInfo = new HCEHomeCMS.NET_EHOME_DEV_REG_INFO();
121 121 strDevRegInfo.write();
... ... @@ -457,6 +457,8 @@ public class CMSServer implements ApplicationRunner {
457 457 face_recoder.setDeviceId(deviceID);
458 458 face_recoder.setTime(time);
459 459 face_recoder.setName(studentBean.getName());
  460 + //114.55.30.100
  461 +// String imgUrl = "http://120.26.116.253:8081/kms/services/rest/dataInfoService/downloadFile?id=" + picDataUrlId;
460 462 String imgUrl = "http://114.55.30.100:8081/kms/services/rest/dataInfoService/downloadFile?id=" + picDataUrlId;
461 463 face_recoder.setImgurl(imgUrl);
462 464 face_recoder.setUser_id(studentBean.getUser_id());
... ... @@ -469,7 +471,6 @@ public class CMSServer implements ApplicationRunner {
469 471  
470 472 }
471 473  
472   -
473 474 /**
474 475 * 生成图片服务路径
475 476 *
... ... @@ -636,6 +637,7 @@ public class CMSServer implements ApplicationRunner {
636 637 int iErr = hCEhomeCMS.NET_ECMS_GetLastError();
637 638 if (validTimeEnabled == 0) System.err.println("删除卡号失败,错误号:" + iErr + "card:" + card);
638 639 else System.err.println("下发卡号失败,错误号:" + iErr + "card:" + card);
  640 + if (iErr==10)map.remove(deviceId);
639 641 } else {
640 642 if (validTimeEnabled == 0) System.out.println("删除卡号成功");
641 643 else System.out.println("下发卡号成功");
... ...
cloud/haikangface/src/main/java/com/sincere/haikangface/async/SendUserAsync.java
... ... @@ -9,7 +9,9 @@ import com.sincere.haikangface.xiananDao.SendRecordDao;
9 9 import org.json.JSONArray;
10 10 import org.json.JSONObject;
11 11 import org.springframework.beans.factory.annotation.Autowired;
  12 +import org.springframework.scheduling.annotation.Async;
12 13 import org.springframework.stereotype.Component;
  14 +import org.springframework.web.bind.annotation.RequestParam;
13 15  
14 16 import javax.imageio.stream.FileImageInputStream;
15 17 import java.io.*;
... ... @@ -66,4 +68,33 @@ public class SendUserAsync {
66 68  
67 69 }
68 70  
  71 +
  72 + /**
  73 + * 调用传图片接口
  74 + * @param filePath
  75 + * @param card
  76 + * @param name
  77 + * @param deviceId
  78 + * @param startTime
  79 + * @param endTime
  80 + * @param validTimeEnabled
  81 + * @param userType
  82 + */
  83 + @Async("taskExecutor")
  84 + public void uploadImgs(String filePath,String card,String name,String deviceId,String startTime,String endTime,int validTimeEnabled,String userType){
  85 +
  86 + HttpUtil.uploadImgs(filePath,card,name,deviceId,startTime,endTime,validTimeEnabled,userType);
  87 + }
  88 +
  89 + @Async("taskExecutor")
  90 + public void deleteCard(String deviceId, String card){
  91 + HttpUtil.deleteCard(deviceId,card);
  92 + }
  93 +
  94 +
  95 + @Async("taskExecutor")
  96 + public boolean IsDeviceOnline( String deviceId){
  97 + return HttpUtil.IsDeviceOnline(deviceId);
  98 + }
  99 +
69 100 }
... ...
cloud/haikangface/src/main/java/com/sincere/haikangface/bean/StudentBean.java
... ... @@ -53,6 +53,26 @@ public class StudentBean implements Serializable {
53 53  
54 54 private String photo;
55 55  
  56 + private String teacher_num;
  57 +
  58 + private String num;
  59 +
  60 + public String getNum() {
  61 + return num;
  62 + }
  63 +
  64 + public void setNum(String num) {
  65 + this.num = num;
  66 + }
  67 +
  68 + public String getTeacher_num() {
  69 + return teacher_num;
  70 + }
  71 +
  72 + public void setTeacher_num(String teacher_num) {
  73 + this.teacher_num = teacher_num;
  74 + }
  75 +
56 76 public String getPhoto() {
57 77 return photo;
58 78 }
... ... @@ -256,12 +276,13 @@ public class StudentBean implements Serializable {
256 276 @Override
257 277 public String toString() {
258 278 return "StudentBean{" +
259   - ", CustomerId='" + CustomerId + '\'' +
260 279 ", name='" + name + '\'' +
  280 + ", ClassName='" + ClassName + '\'' +
  281 + ", Card='" + Card + '\'' +
261 282 ", SchoolId=" + SchoolId +
262 283 ", school_id=" + school_id +
263   - ", studentcode='" + studentcode + '\'' +
264   - ", student_num='" + student_num + '\'' +
  284 + ", teacher_num='" + teacher_num + '\'' +
  285 + ", num='" + num + '\'' +
265 286 '}';
266 287 }
267 288 }
... ...
cloud/haikangface/src/main/java/com/sincere/haikangface/control/FileControl.java
... ... @@ -48,10 +48,11 @@ public class FileControl {
48 48 File dest = new File(outFile, fileName);
49 49 FileOutputStream fileOutputStream = new FileOutputStream(dest);
50 50 fileOutputStream.write(file.getBytes());
  51 + fileOutputStream.close();
51 52 String filePath = dest.getAbsolutePath();
52 53 FileUtils.getInstance().writeLogs("filePath:" + filePath + " card:" + card + " name:" + name + " deviceId:" + deviceId, FileUtils.sendUserInfo);
53 54 long time = System.currentTimeMillis();
54   -// if (filePath.contains(".jpg")) filePath = filePath.replace(".jpg", ".png");
  55 + if (filePath.contains(".jpg")) filePath = filePath.replace(".jpg", ".png");
55 56 if (new File(filePath.trim()).exists()) {
56 57 String targetPath = FileUtils.picPathComp + new File(filePath).getName();
57 58 try {
... ... @@ -86,7 +87,23 @@ public class FileControl {
86 87 @RequestMapping(value = "IsDeviceOnline", method = RequestMethod.GET)
87 88 @ApiOperation("判断设备是否在线")
88 89 public String IsDeviceOnline(@RequestParam("deviceId") String deviceId) {
89   - return cmsServer.getIsDeviceOnline(deviceId)?"1":"0";
  90 + return cmsServer.getIsDeviceOnline(deviceId) ? "1" : "0";
  91 + }
  92 +
  93 +
  94 + @RequestMapping(value = "DeleteCard", method = RequestMethod.GET)
  95 + @ApiOperation("删除人脸")
  96 + public String deleteCard(@RequestParam("deviceId") String deviceId, @RequestParam("card") String card) {
  97 + cmsServer.deleteCard(deviceId, Long.parseLong(getCard(card), 16) + "");
  98 + return "1";
  99 + }
  100 +
  101 + @RequestMapping(value = "getCard", method = RequestMethod.GET)
  102 + @ApiOperation("获取设备人脸是否存在")
  103 + public String getCard(@RequestParam("deviceId") String deviceId, @RequestParam("card") String card) {
  104 + if (cmsServer.getFace(deviceId, Long.parseLong(getCard(card), 16) + "") )
  105 + return "1";
  106 + return "0";
90 107 }
91 108  
92 109  
... ...
cloud/haikangface/src/main/java/com/sincere/haikangface/control/UserControl.java
1 1 package com.sincere.haikangface.control;
2 2  
  3 +import com.netflix.ribbon.proxy.annotation.Http;
3 4 import com.sincere.common.dto.smartCampus.SZ_AttendanceDto;
4 5 import com.sincere.common.util.BaiduApiUtiols;
5 6 import com.sincere.haikangface.CMSServer;
6 7 import com.sincere.haikangface.async.SendUserAsync;
  8 +import com.sincere.haikangface.bean.StudentBean;
7 9 import com.sincere.haikangface.bean.StudentInfo;
8 10 import com.sincere.haikangface.dao.UserDao;
9 11 import com.sincere.haikangface.fegin.HaikangfaceFegin;
10 12 import com.sincere.haikangface.utils.*;
11 13 import com.sincere.haikangface.xiananDao.SendRecordDao;
12 14 import io.swagger.annotations.Api;
  15 +import io.swagger.annotations.ApiImplicitParam;
  16 +import io.swagger.annotations.ApiImplicitParams;
13 17 import io.swagger.annotations.ApiOperation;
14 18 import org.springframework.beans.factory.annotation.Autowired;
  19 +import org.springframework.http.MediaType;
15 20 import org.springframework.util.StringUtils;
16 21 import org.springframework.web.bind.annotation.RequestMapping;
17 22 import org.springframework.web.bind.annotation.RequestMethod;
... ... @@ -22,10 +27,13 @@ import sun.rmi.runtime.Log;
22 27  
23 28 import java.io.*;
24 29 import java.math.BigInteger;
  30 +import java.text.SimpleDateFormat;
  31 +import java.util.Calendar;
  32 +import java.util.Date;
25 33 import java.util.List;
26 34  
27 35 @RestController
28   -@RequestMapping("/facereco/*")
  36 +@RequestMapping(value = "/facereco/*", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
29 37 @Api("用户控制")
30 38 public class UserControl {
31 39  
... ... @@ -54,43 +62,127 @@ public class UserControl {
54 62 @RequestParam("endTime") String endTime, @RequestParam("validTimeEnabled") int validTimeEnabled, @RequestParam("userType") String userType) {
55 63  
56 64 try {
57   - FileUtils.getInstance().writeLogs("filePath:" + filePath + " card:" + card + " name:" + name + " deviceId:" + deviceId, FileUtils.sendUserInfo);
58   - long time = System.currentTimeMillis();
59   -// if (filePath.contains(".jpg")) filePath = filePath.replace(".jpg", ".png");
  65 +
  66 + if (filePath.contains(".jpg")) filePath = filePath.replace(".jpg", ".png");
60 67 if (new File(filePath.trim()).exists()) {
61   - String targetPath = FileUtils.picPathComp + new File(filePath).getName();
62   - try {
63   - int isPiliang = 0;//0:批量,1:单张
64   - if (filePath.contains("face17e50")) {//批量发送
65   - isPiliang = 0;
66   - } else {//单图发送
67   - isPiliang = 1;
68   - }
69   - sendUserAsync.sendStuToHaiKang(filePath, targetPath, Long.parseLong(getCard(card), 16)+"", startTime, endTime, validTimeEnabled, name, deviceId, userType, isPiliang);
70   -
71   - System.out.println("time:" + (System.currentTimeMillis() - time) / 1000);
72   -
73   - } catch (Exception e) {
74   - e.printStackTrace();
75   - return false;
76   - }
77   - } else {
78 68  
  69 + return sendImg(filePath, deviceId, card, name, userType);
  70 +
  71 + } else {
79 72 if (null == sendRecoderUtils) sendRecoderUtils = new SendRecoderUtils();
80   - sendRecoderUtils.sendFail(sendRecordDao, Long.parseLong(getCard(card), 16)+"", filePath, deviceId, userDao, "文件不存在", userType);
  73 + sendRecoderUtils.sendFail(sendRecordDao, Long.parseLong(getCard(card), 16) + "", filePath, deviceId, userDao, "文件不存在", userType);
81 74 System.out.println("文件不存在:" + filePath);
82 75 }
83 76 } catch (Exception e) {
84 77 e.printStackTrace();
85 78 }
86 79 return true;
87   -// return HttpUtil.uploadImgs(filePath,card,name,deviceId,startTime,endTime,validTimeEnabled,userType);
88 80 }
89 81  
90   - @RequestMapping(value = "DeleteCard", method = RequestMethod.GET)
  82 + private boolean sendImg(String filePath, String deviceId, String card, String name, String userType) {
  83 + long time = System.currentTimeMillis();
  84 + String startTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:dd").format(new Date());
  85 + Calendar calendar = Calendar.getInstance();
  86 + calendar.add(Calendar.YEAR, 10);
  87 + String endTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:dd").format(calendar.getTime());
  88 +
  89 + String targetPath = FileUtils.picPathComp + new File(filePath).getName();
  90 + try {
  91 + int isPiliang = 0;//0:批量,1:单张
  92 + if (filePath.contains("face17e50")) {//批量发送
  93 + isPiliang = 0;
  94 + } else {//单图发送
  95 + isPiliang = 1;
  96 + }
  97 + if (cmsServer.getIsDeviceOnline(deviceId))
  98 + sendUserAsync.sendStuToHaiKang(filePath, targetPath, Long.parseLong(getCard(card), 16) + "", startTime, endTime, 1, name, deviceId, userType, isPiliang);
  99 + else {
  100 + sendUserAsync.uploadImgs(filePath, card, name, deviceId, startTime, endTime, 1, userType);
  101 + }
  102 + System.out.println("time:" + (System.currentTimeMillis() - time) / 1000);
  103 + return true;
  104 + } catch (Exception e) {
  105 + e.printStackTrace();
  106 + return false;
  107 + }
  108 +
  109 + }
  110 +
  111 + @RequestMapping(value = "sendFaces", method = RequestMethod.GET)
  112 + @ApiOperation(value = "下发学校下所有人脸给指定设备", notes = "下发所有人脸给指定设备")
  113 + public void sendFaces(@RequestParam("deviceIds") String deviceIds, @RequestParam("schoolId") String schoolId, @RequestParam("userType") String userType) {
  114 +
  115 + String typeName = userType.equals("1") ? "Teacher" : "Student";
  116 +
  117 + String imgPath = "E:\\wwwhtdocs\\SmartCampus\\face17e50\\School" + schoolId + "\\" + typeName;
  118 +
  119 + File imgPathFile = new File(imgPath);//目录
  120 +
  121 + String[] deviceIdsStr = deviceIds.split(",");
  122 +
  123 +
  124 + if (imgPathFile.exists()) {
  125 + File[] imgfiles = imgPathFile.listFiles();
  126 + if (null != imgfiles) {
  127 +
  128 + for (int i = 0; i < imgfiles.length; i++) {
  129 + File file = imgfiles[i];//图片
  130 + if (file.exists())
  131 + for (int j = 0; j < deviceIdsStr.length; j++) {
  132 + String deviceId = deviceIdsStr[j];
  133 +
  134 + StudentBean studentBean = null;
  135 + String card = "", name = "";
  136 + if (userType.equals("1")) {
  137 + studentBean = userDao.getTeacherWithstudentcode(file.getName().split("\\.")[0],schoolId);
  138 + if (null!=studentBean){
  139 + card = studentBean.getTeacher_num();
  140 + name = studentBean.getName();
  141 + }
  142 + } else if (userType.equals("2")) {
  143 + studentBean = userDao.getStudentWithstudentcode(file.getName().split("\\.")[0],schoolId);
  144 + if (null != studentBean) {
  145 + card = studentBean.getStudent_num();
  146 + name = studentBean.getName();
  147 + }
  148 + }
  149 +
  150 + if (!StringUtils.isEmpty(card))
  151 + sendImg(file.getAbsolutePath(), deviceId, card, name, userType);
  152 +
  153 + }
  154 +
  155 + }
  156 +
  157 + }
  158 + }
  159 +
  160 + }
  161 +
  162 + @RequestMapping(value = "sendFaceToDevices", method = RequestMethod.GET)
  163 + @ApiOperation(value = "下发单个用户给指定设备", notes = "下发单个用户给指定设备")
  164 + @ApiImplicitParams({@ApiImplicitParam(name = "deviceIds",value = "设备id用逗号,拼接"),
  165 + @ApiImplicitParam(name = "file",value = "100服务器上图片绝对路径")})
  166 + public void sendFaceToDevices(@RequestParam("deviceIds") String deviceIds, @RequestParam("userType") String userType,@RequestParam("file") String file,
  167 + @RequestParam("card") String card,@RequestParam("name") String name) {
  168 +
  169 + String[] deviceIdsStr = deviceIds.split(",");
  170 +
  171 + for (int i = 0; i < deviceIdsStr.length; i++) {
  172 + String deviceId = deviceIdsStr[i];
  173 + sendImg(file, deviceId, card, name, userType);
  174 + }
  175 +
  176 + }
  177 +
  178 +
  179 +
  180 + @RequestMapping(value = "DeleteCard", method = RequestMethod.GET)
91 181 @ApiOperation("删除人脸")
92 182 public boolean deleteCard(@RequestParam("deviceId") String deviceId, @RequestParam("card") String card) {
93   - cmsServer.deleteCard(deviceId, Long.parseLong(getCard(card), 16) + "");
  183 + if (cmsServer.getIsDeviceOnline(deviceId))
  184 + cmsServer.deleteCard(deviceId, Long.parseLong(getCard(card), 16) + "");
  185 + else HttpUtil.deleteCard(deviceId, card);
94 186 return true;
95 187 }
96 188  
... ... @@ -98,6 +190,7 @@ public class UserControl {
98 190 @ApiOperation("获取设备人脸是否存在")
99 191 public boolean getCard(@RequestParam("deviceId") String deviceId, @RequestParam("card") String card) {
100 192 cmsServer.getFace(deviceId, Long.parseLong(getCard(card), 16) + "");
  193 +// HttpUtil.getCard(deviceId,card);
101 194 return true;
102 195 }
103 196  
... ... @@ -107,13 +200,8 @@ public class UserControl {
107 200 if (cmsServer.getIsDeviceOnline(deviceId)) {
108 201 return true;
109 202 } else {
110   - return false;
  203 + return sendUserAsync.IsDeviceOnline(deviceId);
111 204 }
112   - /*if ( HttpUtil.IsDeviceOnline(deviceId)) {
113   - return true;
114   - } else {
115   - return false;
116   - }*/
117 205 }
118 206  
119 207 @RequestMapping(value = "FaceUploadFile", method = RequestMethod.POST)
... ... @@ -122,7 +210,7 @@ public class UserControl {
122 210  
123 211 String targetPath = FileUtils.picPathComp;
124 212 System.out.println("fileName:" + file.getOriginalFilename());
125   - return "";
  213 + return "sss";
126 214  
127 215 }
128 216  
... ... @@ -131,7 +219,7 @@ public class UserControl {
131 219 @ApiOperation("根据设备获取考勤模板")
132 220 public String getKaoqinTem(@RequestParam("deviceId") String deviceId) {
133 221 SZ_AttendanceDto attendanceBean = haikangfaceFegin.selectAttendaceWithId(deviceId);
134   - System.out.println("isKaoqin:"+attendanceBean.toString());
  222 + System.out.println("isKaoqin:" + attendanceBean.toString());
135 223 int isKaoqin = attendanceBean.getIsKaoqin();//获取考勤模板id
136 224 List<SZ_AttendanceDto> attendanceBeans = haikangfaceFegin.getAttensWithIsKaoqin(isKaoqin);//获取同一模板下的设备
137 225 String content = "";
... ...
cloud/haikangface/src/main/java/com/sincere/haikangface/control/ZuoYeControl.java
1 1 package com.sincere.haikangface.control;
2 2  
  3 +import com.sincere.common.util.AuthService;
3 4 import com.sincere.haikangface.admindao.ZuoyeAdminDao;
4 5 import com.sincere.haikangface.bean.UserBean;
5 6 import com.sincere.haikangface.bean.homework.AddQuestion;
... ... @@ -268,7 +269,7 @@ public class ZuoYeControl {
268 269 return null;
269 270 }
270 271  
271   - private String url = "https://aip.baidubce.com/rest/2.0/ocr/v1/general_basic?access_token=24.26683b650b73b63e0b08afa7ac36e880.2592000.1571310480.282335-15990462";
  272 + private String url = "https://aip.baidubce.com/rest/2.0/ocr/v1/general_basic?access_token="+ AuthService.getAuth();
272 273  
273 274 private String getAnswer(String imgUrl, int type) {
274 275 RestTemplate restTemplate = new RestTemplate();
... ...
cloud/haikangface/src/main/java/com/sincere/haikangface/dao/UserDao.java
... ... @@ -2,6 +2,7 @@ package com.sincere.haikangface.dao;
2 2  
3 3 import com.sincere.haikangface.bean.*;
4 4 import org.apache.ibatis.annotations.*;
  5 +import org.springframework.security.core.parameters.P;
5 6 import org.springframework.stereotype.Repository;
6 7  
7 8 import java.util.List;
... ... @@ -169,7 +170,8 @@ public interface UserDao {
169 170 @Select(" select * from SZ_V_School_Student where school_id = 562 and student_num is not null and photo is not null and len(photo)>0")
170 171 List<StudentInfo> getAllStus();
171 172  
172   - @Select("select DISTINCT user_id from SZ_V_School_Teacher where school_id = 885")
  173 + @Select("select user_id\n" +
  174 + "from SZ_V_School_Student where school_id = 13 and student_type =2 and len(student_num)=0\n")
173 175 List<String> getUserids();
174 176  
175 177 @Insert("insert into HS_ResRalation (FileId,AddTime,UserId) values (#{FileId},#{AddTime},#{userId})")
... ... @@ -192,4 +194,21 @@ public interface UserDao {
192 194 " from SS_Room\n" +
193 195 " where SchoolId = 479 and SS_Room.Pid =10284 )")
194 196 List<String> getStudentIdWithRoom();
  197 +
  198 + @Select("select CardNum from Virtual_Card where state =0 and id < 5475 ;")
  199 + List<String> getVirCards();
  200 +
  201 + @Update("update SZ_V_School_Student set student_num =#{student_num} where school_id = 13 and student_type =2 and len(student_num)=0 and user_id = #{user_id}")
  202 + void updateStuCards(@Param("student_num") String card,@Param("user_id")String user_id);
  203 +
  204 +
  205 + @Select("select Top(1)*\n" +
  206 + "from SZ_V_School_Student\n" +
  207 + "where studentcode = #{studentcode} and school_id = #{schoolId}")
  208 + StudentBean getStudentWithstudentcode(@Param("studentcode") String studentcode, @Param("schoolId")String schoolId);
  209 +
  210 + @Select("select Top(1)*\n" +
  211 + "from SZ_V_School_Teacher\n" +
  212 + "where num = #{num} and school_id = #{schoolId}")
  213 + StudentBean getTeacherWithstudentcode(@Param("num") String num,@Param("schoolId")String schoolId);
195 214 }
... ...
cloud/haikangface/src/main/java/com/sincere/haikangface/utils/CompressPic.java
... ... @@ -16,7 +16,7 @@ import java.io.InputStream;
16 16 public class CompressPic {
17 17  
18 18 public static String CompressPic(String srcPath, String targetPath) throws Exception {
19   - double cutPercent = 0.1;
  19 + double cutPercent = 0.4;
20 20 File file = new File(srcPath.trim());
21 21 FileInputStream fileInputStreamSrc = new FileInputStream(file);
22 22 BufferedImage bufferedImage = ImageIO.read(fileInputStreamSrc);
... ...
cloud/haikangface/src/main/java/com/sincere/haikangface/utils/HttpUtil.java
... ... @@ -95,7 +95,7 @@ public class HttpUtil {
95 95 return false;
96 96 }
97 97  
98   - String url = "http://121.40.109.21:8089/file/uploadImg";
  98 + String url = "http://120.26.116.253:8089/file/uploadImg";
99 99  
100 100 RestTemplate restTemplate = new RestTemplate();
101 101  
... ... @@ -129,16 +129,37 @@ public class HttpUtil {
129 129  
130 130 public static boolean IsDeviceOnline(String deviceId){
131 131  
132   - String url = "http://121.40.109.21:8089/file/getCard";
  132 + String url = "http://120.26.116.253:8089/file/IsDeviceOnline?deviceId="+deviceId;
133 133  
134 134 RestTemplate restTemplate = new RestTemplate();
135 135  
136   - Map<String,Object> map = new HashMap<>();
  136 +// Map<String,Object> map = new HashMap<>();
137 137  
138   - map.put("deviceId",deviceId);
  138 +// map.put("deviceId",deviceId);
139 139  
140   - String res = restTemplate.getForObject(url,String.class,map);
  140 + String res = restTemplate.getForObject(url,String.class);
141 141 return res.equals("1");
142 142 }
143 143  
  144 + public static boolean deleteCard(String deviceId, String card){
  145 +
  146 + String url = "http://120.26.116.253:8089/file/DeleteCard?deviceId="+deviceId+"&card="+card;
  147 +
  148 + RestTemplate restTemplate = new RestTemplate();
  149 +
  150 + String res = restTemplate.getForObject(url,String.class);
  151 +
  152 + return res.equals("1");
  153 + }
  154 +
  155 + public static boolean getCard(String deviceId, String card){
  156 +
  157 + String url = "http://120.26.116.253:8089/file/getCard?deviceId="+deviceId+"&card="+card;
  158 +
  159 + RestTemplate restTemplate = new RestTemplate();
  160 +
  161 +// String res = restTemplate.getForObject(url,String.class,map);
  162 + return restTemplate.getForObject(url,String.class).equals("1");
  163 + }
  164 +
144 165 }
... ...
cloud/haikangface/src/main/java/com/sincere/haikangface/xiananDao/SendRecordDao.java
... ... @@ -27,7 +27,7 @@ public interface SendRecordDao {
27 27 @Param("userType") int userType, @Param("deviceType") int deviceType);
28 28  
29 29  
30   - @Select("select * from Face_SendSuccess where schoolId = 1066 ")
  30 + @Select("select * from Face_SendSuccess where schoolId = 870 ")
31 31 List<SendRecordBean> getSenSuccess();
32 32  
33 33 @Select("select * from Face_SendSuccess where deviceID = #{deviceID} and schoolId = #{schoolId}")
... ...
cloud/haikangface/src/main/resources/application.yaml
... ... @@ -38,8 +38,8 @@ eureka:
38 38 lease-renewal-interval-in-seconds: 10
39 39 client:
40 40 service-url:
41   - defaultZone: http://121.40.109.21:8761/eureka/,http://121.40.109.21:8762/eureka/
42   -# defaultZone: http://localhost:8761/eureka/,http://localhost:8762/eureka/
  41 +# defaultZone: http://121.40.109.21:8761/eureka/,http://121.40.109.21:8762/eureka/
  42 + defaultZone: http://localhost:8761/eureka/,http://localhost:8762/eureka/
43 43  
44 44 mybatis:
45 45 campus:
... ...
cloud/haikangface/src/test/java/com/sincere/haikangface/HaikangfaceApplicationTests.java
... ... @@ -33,6 +33,8 @@ import org.springframework.util.MultiValueMap;
33 33 import org.springframework.util.StringUtils;
34 34 import org.springframework.web.client.RestTemplate;
35 35  
  36 +import javax.imageio.stream.FileImageInputStream;
  37 +import javax.imageio.stream.FileImageOutputStream;
36 38 import javax.ws.rs.core.MultivaluedMap;
37 39 import java.io.*;
38 40 import java.math.BigInteger;
... ... @@ -70,6 +72,23 @@ public class HaikangfaceApplicationTests {
70 72 @Test
71 73 public void send() {
72 74  
  75 +// List<String> virCards = userDao.getVirCards();
  76 +// List<String> userIds = userDao.getUserids();
  77 +// for (int i = 0; i < virCards.size(); i++) {
  78 +// String card = virCards.get(i);
  79 +//
  80 +// userDao.updateStuCards(card,userIds.get(i));
  81 +// }
  82 +
  83 + /* List<SendRecordBean> sendRecordBeanList = sendRecordDao.getSenSuccess();
  84 +
  85 + for (int i = 0; i < sendRecordBeanList.size(); i++) {
  86 + SendRecordBean sendRecordBean = sendRecordBeanList.get(i);
  87 +
  88 + sendRecordDao.deleteFaceFail(sendRecordBean.getNum(),sendRecordBean.getDeviceID());
  89 + }*/
  90 +
  91 +
73 92 //补发失败人脸
74 93 /*RestTemplate restTemplate = new RestTemplate();
75 94 //失败人脸补发
... ... @@ -242,26 +261,109 @@ public class HaikangfaceApplicationTests {
242 261  
243 262 @Test
244 263 public void fileRes() {
245   -// List<QuestionBean> questionBeans = zuoYeDao.getQuestionsRecent();
246   - /* List<QuestionBean> questionBeans = zuoYeDao.getQuestionsRecent();
247   - String dateTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
248   -
249   - for (QuestionBean ques :
250   - questionBeans) {
251   - zuoyeAdminDao.addQuestionStem("请回答下列问题", "1", dateTime);
252   - int stemId = zuoyeAdminDao.getStemId();
253   - String intime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
254   - zuoyeAdminDao.addQuestion(ques.getQuestion(),ques.getQtype(),ques.getAnswer(),ques.getCorrectAnswer(),ques.getAnalysis(),
255   - ques.getState(),intime,stemId+"",ques.getExamineFlag(),ques.getSubjectId(),"10","1",ques.getChapterId(),ques.getGradeId()+"","1","","1");
256   - }*/
257 264  
258   -//List<Long> queIds = zuoyeAdminDao.getQueIds();
  265 + File filebianhao = new File("C:\\Users\\Administrator\\Desktop\\中专照片汇总200204\\bianhao.txt");
  266 + File filecard = new File("C:\\Users\\Administrator\\Desktop\\中专照片汇总200204\\card.txt");
  267 +
  268 + try {
  269 + BufferedReader bufferedReaderBianhao = new BufferedReader(new FileReader(filebianhao));
  270 + BufferedReader bufferedReaderCard = new BufferedReader(new FileReader(filecard));
  271 +
  272 + String lineBianhao = null;
  273 +
  274 + List<String> listBianhao = new ArrayList<>();
  275 +
  276 + while ((lineBianhao = bufferedReaderBianhao.readLine()) != null) {
  277 +
  278 + listBianhao.add(lineBianhao);
  279 +
  280 + }
  281 +
  282 + String lineCard = null;
  283 +
  284 + List<String> listCard = new ArrayList<>();
  285 +
  286 + while ((lineCard = bufferedReaderCard.readLine()) != null) {
  287 +
  288 + listCard.add(lineCard);
  289 +
  290 + }
  291 +
  292 + File filePath = new File("C:\\Users\\Administrator\\Desktop\\中专照片汇总200204\\中专照片汇总200204");
  293 +
  294 + File[] fileImgs = filePath.listFiles();
  295 +
259 296  
  297 + File fileOut = new File("C:\\Users\\Administrator\\Desktop\\中专照片汇总200204");
260 298  
261   -// for (int i = queIds.size()-1; i >=0 ; i--) {
262   -// zuoyeAdminDao.addYYQuestionAndKnowledg(queIds.get(i), Long.parseLong(questionBeans.get(questionBeans.size()-1-i).getKnowledgeId()),0,1);
263   -// }
  299 + for (int i = 0; i < fileImgs.length; i++) {
  300 + File img = fileImgs[i];
264 301  
  302 + String bianhao = img.getName().split("\\.")[0];
  303 +
  304 + for (int j = 0; j < listBianhao.size(); j++) {
  305 + if (bianhao.equals(listBianhao.get(j))) {
  306 + StudentBean studentBean = userDao.getTeacherWithCard(listCard.get(j));
  307 + if (studentBean == null) {//学生
  308 + studentBean = userDao.getStudentWithCard(listCard.get(j));
  309 +
  310 + if (studentBean == null) {
  311 +// System.out.println(listCard.get(j));
  312 + } else {
  313 + File fileOutStu = new File(fileOut.getAbsolutePath(), "Student");
  314 + if (!fileOutStu.exists()) fileOutStu.mkdirs();
  315 + File fileOutStu1 = new File(fileOutStu, studentBean.getStudentcode() + ".png");
  316 + if (!fileOutStu1.exists()) fileOutStu1.createNewFile();
  317 + writeImg(fileOutStu1.getAbsolutePath(), img.getAbsolutePath());
  318 + }
  319 +
  320 +
  321 + } else {//老师
  322 + File fileOutTea = new File(fileOut.getAbsolutePath(), "Teacher");
  323 + if (!fileOutTea.exists()) fileOutTea.mkdirs();
  324 + File fileOutStu1 = new File(fileOutTea, studentBean.getNum() + ".png");
  325 + if (!fileOutStu1.exists()) fileOutStu1.createNewFile();
  326 + writeImg(fileOutStu1.getAbsolutePath(), img.getAbsolutePath());
  327 + System.out.println(studentBean==null?listCard.get(j):"");
  328 + }
  329 + }
  330 + }
  331 + }
  332 +
  333 +
  334 + } catch (FileNotFoundException e) {
  335 + e.printStackTrace();
  336 + } catch (IOException e) {
  337 + e.printStackTrace();
  338 + }
  339 +
  340 + }
  341 +
  342 +
  343 + private void writeImg(String imgPath, String srcPath) {
  344 +
  345 + try {
  346 + FileImageOutputStream fileImageOutputStream = new FileImageOutputStream(new File(imgPath));
  347 +
  348 + FileImageInputStream fileImageInputStream = new FileImageInputStream(new File(srcPath));
  349 +
  350 + byte[] bytes = new byte[1024];
  351 +
  352 + int length = -1;
  353 +
  354 + while ((length = fileImageInputStream.read(bytes)) != -1) {
  355 + fileImageOutputStream.write(bytes, 0, length);
  356 + }
  357 +
  358 +
  359 + fileImageInputStream.close();
  360 + fileImageOutputStream.close();
  361 +
  362 +
  363 + } catch (IOException e) {
  364 + e.printStackTrace();
  365 + }
265 366  
266 367 }
  368 +
267 369 }
... ...
cloud/mypulsar/pom.xml
... ... @@ -58,34 +58,15 @@
58 58 <groupId>org.springframework.boot</groupId>
59 59 <artifactId>spring-boot-starter-web</artifactId>
60 60  
61   - <!-- 移除嵌入式tomcat插件 -->
62   - <!--<exclusions>-->
63   - <!--<exclusion>-->
64   - <!--<groupId>org.springframework.boot</groupId>-->
65   - <!--<artifactId>spring-boot-starter-tomcat</artifactId>-->
66   - <!--</exclusion>-->
67   - <!--</exclusions>-->
68   -
69 61 </dependency>
70 62  
71   - <!--<dependency>-->
72   - <!--<groupId>org.springframework.boot</groupId>-->
73   - <!--<artifactId>spring-boot-starter-tomcat</artifactId>-->
74   - <!--<scope>provided</scope>-->
75   - <!--</dependency>-->
76   -
77   - <dependency>
78   - <groupId>org.springframework.boot</groupId>
79   - <artifactId>spring-boot-starter-test</artifactId>
80   - <scope>test</scope>
81   - </dependency>
  63 +<!-- <dependency>-->
  64 +<!-- <groupId>org.springframework.boot</groupId>-->
  65 +<!-- <artifactId>spring-boot-starter-test</artifactId>-->
  66 +<!-- <scope>test</scope>-->
  67 +<!-- </dependency>-->
82 68  
83 69 <dependency>
84   - <groupId>org.apache.pulsar</groupId>
85   - <artifactId>pulsar-client</artifactId>
86   - <version>2.3.2</version>
87   - </dependency>
88   - <dependency>
89 70 <groupId>com.alibaba</groupId>
90 71 <artifactId>fastjson</artifactId>
91 72 <version>1.2.46</version>
... ... @@ -116,6 +97,17 @@
116 97 <groupId>org.springframework.cloud</groupId>
117 98 <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
118 99 </dependency>
  100 + <dependency>
  101 + <groupId>org.springframework.boot</groupId>
  102 + <artifactId>spring-boot-autoconfigure</artifactId>
  103 + </dependency>
  104 +
  105 + <dependency>
  106 + <groupId>org.apache.pulsar</groupId>
  107 + <artifactId>pulsar-client</artifactId>
  108 + <version>2.4.2</version>
  109 + </dependency>
  110 +
119 111 <!--<dependency>-->
120 112 <!--<groupId>com.gitee.sunchenbin.mybatis.actable</groupId>-->
121 113 <!--<artifactId>mybatis-enhance-actable</artifactId>-->
... ...
cloud/mypulsar/src/main/java/com/example/mypulsar/MyRunnerableInt.java
... ... @@ -278,6 +278,9 @@ public class MyRunnerableInt implements ApplicationRunner {
278 278 // value = value.equals("0")?"0":Integer.parseInt(value) / 10 + "A";
279 279 // log(devId + " 当前电流:" + Integer.parseInt(value) / 10 + "A");
280 280 break;
  281 + case "router_mgr"://网关路由
  282 +
  283 + break;
281 284 }
282 285 updateDevStatus(deviceBean);
283 286 }
... ... @@ -294,7 +297,7 @@ public class MyRunnerableInt implements ApplicationRunner {
294 297 if (deviceBean.getValue().equals("有人")) deviceBean.setValue("1");
295 298 else deviceBean.setValue("0");
296 299  
297   - ControlUtils.getInstance().conTemper(calDevContrls, deviceBean);
  300 + ControlUtils.getInstance(deviceDao).conTemper(calDevContrls, deviceBean);
298 301 }
299 302 }
300 303  
... ... @@ -308,7 +311,7 @@ public class MyRunnerableInt implements ApplicationRunner {
308 311  
309 312 List<CalDevContrl> calDevContrls = deviceDao.getCalDevContrlWidthDevId(deviceBean.getDevId());
310 313 if (null != calDevContrls && calDevContrls.size() > 0)
311   - ControlUtils.getInstance().conTemper(calDevContrls, deviceBean);
  314 + ControlUtils.getInstance(deviceDao).conTemper(calDevContrls, deviceBean);
312 315  
313 316 }
314 317  
... ...
cloud/mypulsar/src/main/java/com/example/mypulsar/Test.java
1 1 package com.example.mypulsar;
2 2  
  3 +import com.example.mypulsar.dao.UserDao;
3 4 import com.example.mypulsar.utils.HttpUtil;
  5 +import org.mybatis.spring.annotation.MapperScan;
  6 +import org.springframework.beans.factory.annotation.Autowired;
  7 +import org.springframework.boot.SpringApplication;
  8 +import org.springframework.boot.autoconfigure.SpringBootApplication;
  9 +import org.springframework.boot.configurationprocessor.json.JSONArray;
  10 +import org.springframework.boot.configurationprocessor.json.JSONException;
  11 +import org.springframework.boot.configurationprocessor.json.JSONObject;
  12 +import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
4 13  
  14 +import java.io.*;
5 15 import java.text.ParseException;
6 16 import java.text.SimpleDateFormat;
  17 +import java.util.ArrayList;
  18 +import java.util.Calendar;
7 19 import java.util.Date;
  20 +import java.util.List;
  21 +
  22 +
  23 +public class Test extends SpringBootServletInitializer {
  24 +
  25 + public static void main(String[] args) {
  26 +
8 27  
9   -public class Test {
10 28  
11   - public static void main(String[] args){
12   -// 3307102084f3eb3547e7
13   -// HttpUtil.controlDev("6cb748ca397c2f03b1nqbh","switch_1","false");
14   - /*HttpUtil.addAirCode("{\n" +
15   - "\"remote_index\":\"null\",\n" +
16   - "\"remote_id\":\"null\",\n" +
17   - "\"power\":\"1\",\n" +
18   - "\"mode\":\"null\",\n" +
19   - "\"temp\":\"null\",\n" +
20   - "\"wind\":\"null\"\n" +
21   - "}\n","45424060b4e62d2183ec");*/
22 29  
23 30 }
24 31  
  32 +
25 33 }
... ...
cloud/mypulsar/src/main/java/com/example/mypulsar/bean/CalDevBeContrl.java 0 → 100644
... ... @@ -0,0 +1,98 @@
  1 +package com.example.mypulsar.bean;
  2 +
  3 +public class CalDevBeContrl {
  4 +
  5 + private int id;
  6 +
  7 + private String ConDevId;
  8 +
  9 + private String ConCode;
  10 +
  11 + private String ConValue;
  12 +
  13 + private String CreateTime;
  14 +
  15 + private String CreateUserId;
  16 +
  17 + private int State;
  18 +
  19 + private int ModeId;
  20 +
  21 + public int getId() {
  22 + return id;
  23 + }
  24 +
  25 + public void setId(int id) {
  26 + this.id = id;
  27 + }
  28 +
  29 + public String getConDevId() {
  30 + return ConDevId;
  31 + }
  32 +
  33 + public void setConDevId(String conDevId) {
  34 + ConDevId = conDevId;
  35 + }
  36 +
  37 + public String getConCode() {
  38 + return ConCode;
  39 + }
  40 +
  41 + public void setConCode(String conCode) {
  42 + ConCode = conCode;
  43 + }
  44 +
  45 + public String getConValue() {
  46 + return ConValue;
  47 + }
  48 +
  49 + public void setConValue(String conValue) {
  50 + ConValue = conValue;
  51 + }
  52 +
  53 + public String getCreateTime() {
  54 + return CreateTime;
  55 + }
  56 +
  57 + public void setCreateTime(String createTime) {
  58 + CreateTime = createTime;
  59 + }
  60 +
  61 + public String getCreateUserId() {
  62 + return CreateUserId;
  63 + }
  64 +
  65 + public void setCreateUserId(String createUserId) {
  66 + CreateUserId = createUserId;
  67 + }
  68 +
  69 + public int getState() {
  70 + return State;
  71 + }
  72 +
  73 + public void setState(int state) {
  74 + State = state;
  75 + }
  76 +
  77 + public int getModeId() {
  78 + return ModeId;
  79 + }
  80 +
  81 + public void setModeId(int modeId) {
  82 + ModeId = modeId;
  83 + }
  84 +
  85 + @Override
  86 + public String toString() {
  87 + return "CalDevBeContrl{" +
  88 + "id=" + id +
  89 + ", ConDevId='" + ConDevId + '\'' +
  90 + ", ConCode='" + ConCode + '\'' +
  91 + ", ConValue='" + ConValue + '\'' +
  92 + ", CreateTime='" + CreateTime + '\'' +
  93 + ", CreateUserId='" + CreateUserId + '\'' +
  94 + ", State=" + State +
  95 + ", ModeId=" + ModeId +
  96 + '}';
  97 + }
  98 +}
... ...
cloud/mypulsar/src/main/java/com/example/mypulsar/bean/CalDevContrl.java
... ... @@ -14,17 +14,19 @@ public class CalDevContrl implements Serializable {
14 14  
15 15 private String ThreValue;
16 16  
17   - private String ConDevId;
  17 + private String CreateTime;
18 18  
19   - private String ConCode;
  19 + private String CreateUserId;
20 20  
21   - private String ConValue;
  21 + private String InUserTime;
22 22  
23   - private String CreateTime;
  23 + private int Status ;
24 24  
25   - private String CreateUserId;
  25 + private String DevBeId;//控制的设备id
  26 +
  27 + private int ModeId;//联动模板id
26 28  
27   - private String InUseTime;
  29 + private String AssDevice;//联动传感器设备
28 30  
29 31 public String getDevid() {
30 32 return Devid;
... ... @@ -42,6 +44,22 @@ public class CalDevContrl implements Serializable {
42 44 ModelType = modelType;
43 45 }
44 46  
  47 + public String getInUserTime() {
  48 + return InUserTime;
  49 + }
  50 +
  51 + public String getThreValue() {
  52 + return ThreValue;
  53 + }
  54 +
  55 + public void setThreValue(String threValue) {
  56 + ThreValue = threValue;
  57 + }
  58 +
  59 + public void setInUserTime(String inUserTime) {
  60 + InUserTime = inUserTime;
  61 + }
  62 +
45 63 public int getComPre() {
46 64 return ComPre;
47 65 }
... ... @@ -58,63 +76,54 @@ public class CalDevContrl implements Serializable {
58 76 CompreType = compreType;
59 77 }
60 78  
61   - public String getThresholdValue() {
62   - return ThreValue;
63   - }
64   -
65   - public void setThresholdValue(String thresholdValue) {
66   - ThreValue = thresholdValue;
67   - }
68   -
69   - public String getConDevId() {
70   - return ConDevId;
  79 + public String getCreateTime() {
  80 + return CreateTime;
71 81 }
72 82  
73   - public void setConDevId(String conDevId) {
74   - ConDevId = conDevId;
  83 + public void setCreateTime(String createTime) {
  84 + CreateTime = createTime;
75 85 }
76 86  
77   - public String getConCode() {
78   - return ConCode;
  87 + public String getCreateUserId() {
  88 + return CreateUserId;
79 89 }
80 90  
81   - public void setConCode(String conCode) {
82   - ConCode = conCode;
  91 + public void setCreateUserId(String createUserId) {
  92 + CreateUserId = createUserId;
83 93 }
84 94  
85   - public String getConValue() {
86   - return ConValue;
  95 + public int getStatus() {
  96 + return Status;
87 97 }
88 98  
89   - public void setConValue(String conValue) {
90   - ConValue = conValue;
  99 + public void setStatus(int status) {
  100 + Status = status;
91 101 }
92 102  
93   - public String getCreateTime() {
94   - return CreateTime;
  103 + public String getDevBeId() {
  104 + return DevBeId;
95 105 }
96 106  
97   - public void setCreateTime(String createTime) {
98   - CreateTime = createTime;
  107 + public void setDevBeId(String devBeId) {
  108 + DevBeId = devBeId;
99 109 }
100 110  
101   - public String getCreateUserId() {
102   - return CreateUserId;
  111 + public int getModeId() {
  112 + return ModeId;
103 113 }
104 114  
105   - public void setCreateUserId(String createUserId) {
106   - CreateUserId = createUserId;
  115 + public void setModeId(int modeId) {
  116 + ModeId = modeId;
107 117 }
108 118  
109   - public String getInUseTime() {
110   - return InUseTime;
  119 + public String getAssDevice() {
  120 + return AssDevice;
111 121 }
112 122  
113   - public void setInUseTime(String inUseTime) {
114   - InUseTime = inUseTime;
  123 + public void setAssDevice(String assDevice) {
  124 + AssDevice = assDevice;
115 125 }
116 126  
117   -
118 127 @Override
119 128 public String toString() {
120 129 return "CalDevContrl{" +
... ... @@ -122,13 +131,14 @@ public class CalDevContrl implements Serializable {
122 131 ", ModelType=" + ModelType +
123 132 ", ComPre=" + ComPre +
124 133 ", CompreType=" + CompreType +
125   - ", ThresholdValue='" + ThreValue + '\'' +
126   - ", ConDevId='" + ConDevId + '\'' +
127   - ", ConCode='" + ConCode + '\'' +
128   - ", ConValue='" + ConValue + '\'' +
  134 + ", ThreValue='" + ThreValue + '\'' +
129 135 ", CreateTime='" + CreateTime + '\'' +
130 136 ", CreateUserId='" + CreateUserId + '\'' +
131   - ", InUseTime='" + InUseTime + '\'' +
  137 + ", InUseTime='" + InUserTime + '\'' +
  138 + ", Status=" + Status +
  139 + ", DevBeId='" + DevBeId + '\'' +
  140 + ", ModeId=" + ModeId +
  141 + ", AssDevice='" + AssDevice + '\'' +
132 142 '}';
133 143 }
134 144 }
... ...
cloud/mypulsar/src/main/java/com/example/mypulsar/bean/InUserTime.java 0 → 100644
... ... @@ -0,0 +1,46 @@
  1 +package com.example.mypulsar.bean;
  2 +
  3 +import java.io.Serializable;
  4 +
  5 +public class InUserTime implements Serializable {
  6 +
  7 +// [{"Week":"5","StartTime":"14:02","EndTime":"14:06"}]
  8 + private String Week;
  9 +
  10 + private String StartTime;
  11 +
  12 + private String EndTime;
  13 +
  14 + public String getWeek() {
  15 + return Week;
  16 + }
  17 +
  18 + public void setWeek(String week) {
  19 + Week = week;
  20 + }
  21 +
  22 + public String getStartTime() {
  23 + return StartTime;
  24 + }
  25 +
  26 + public void setStartTime(String startTime) {
  27 + StartTime = startTime;
  28 + }
  29 +
  30 + public String getEndTime() {
  31 + return EndTime;
  32 + }
  33 +
  34 + public void setEndTime(String endTime) {
  35 + EndTime = endTime;
  36 + }
  37 +
  38 + @Override
  39 + public String toString() {
  40 + return "InUserTime{" +
  41 + "Week='" + Week + '\'' +
  42 + ", StartTime='" + StartTime + '\'' +
  43 + ", EndTime='" + EndTime + '\'' +
  44 + '}';
  45 + }
  46 +}
... ...
cloud/mypulsar/src/main/java/com/example/mypulsar/bean/InUserTimeList.java 0 → 100644
... ... @@ -0,0 +1,24 @@
  1 +package com.example.mypulsar.bean;
  2 +
  3 +import java.io.Serializable;
  4 +import java.util.List;
  5 +
  6 +public class InUserTimeList implements Serializable {
  7 +
  8 +private List<InUserTime> inUserTimes;
  9 +
  10 + public List<InUserTime> getInUserTimes() {
  11 + return inUserTimes;
  12 + }
  13 +
  14 + public void setInUserTimes(List<InUserTime> inUserTimes) {
  15 + this.inUserTimes = inUserTimes;
  16 + }
  17 +
  18 + @Override
  19 + public String toString() {
  20 + return "InUserTimeList{" +
  21 + "inUserTimes=" + inUserTimes +
  22 + '}';
  23 + }
  24 +}
... ...
cloud/mypulsar/src/main/java/com/example/mypulsar/dao/DeviceDao.java
1 1 package com.example.mypulsar.dao;
2 2  
  3 +import com.example.mypulsar.bean.CalDevBeContrl;
3 4 import com.example.mypulsar.bean.CalDevContrl;
4 5 import com.example.mypulsar.bean.DeviceBean;
5 6 import org.apache.ibatis.annotations.*;
... ... @@ -35,9 +36,13 @@ public interface DeviceDao {
35 36 List<DeviceBean> getDevice(@Param("devId") String devId);
36 37  
37 38 //获取联动控制模板
38   - @Select("select * from CalDevContrl")
  39 + @Select("select * from CalDevContrl ")
39 40 List<CalDevContrl> getCalDevContrl();
40 41  
41   - @Select("select * from CalDevContrl where Devid = #{Devid}")
  42 +
  43 + @Select("select * from CalDevContrl where Devid = #{Devid} and Status = 1")
42 44 List<CalDevContrl> getCalDevContrlWidthDevId(@Param("Devid") String devId);
  45 +
  46 + @Select("select * from CalDevContrl where State = 1 and Id = #{Id}")
  47 + CalDevBeContrl getCalDevBeControl(@Param("Id") String Id);
43 48 }
... ...
cloud/mypulsar/src/main/java/com/example/mypulsar/utils/ControlUtils.java
1 1 package com.example.mypulsar.utils;
2 2  
3   -import com.example.mypulsar.bean.CalDevContrl;
4   -import com.example.mypulsar.bean.DeviceBean;
  3 +import com.example.mypulsar.bean.*;
  4 +import com.example.mypulsar.dao.DeviceDao;
  5 +import org.apache.pulsar.shade.com.google.gson.Gson;
  6 +import org.springframework.boot.configurationprocessor.json.JSONArray;
  7 +import org.springframework.boot.configurationprocessor.json.JSONException;
  8 +import org.springframework.boot.configurationprocessor.json.JSONObject;
5 9  
6 10 import java.text.ParseException;
7 11 import java.text.SimpleDateFormat;
8   -import java.util.Date;
9   -import java.util.List;
  12 +import java.util.*;
10 13  
11 14 public class ControlUtils {
12 15  
  16 + private Set<CalDevContrl> deviceSet = new HashSet<>();//保存符合条件的传感器
  17 +
13 18 private static ControlUtils controlUtils;
14 19  
15   - public static ControlUtils getInstance(){
16   - if (null==controlUtils){
17   - synchronized (ControlUtils.class){
18   - if (null==controlUtils)controlUtils = new ControlUtils();
  20 + private DeviceDao deviceDao;
  21 +
  22 + public static ControlUtils getInstance(DeviceDao deviceDao) {
  23 + if (null == controlUtils) {
  24 + synchronized (ControlUtils.class) {
  25 + if (null == controlUtils) controlUtils = new ControlUtils(deviceDao);
19 26 }
20 27 }
21 28 return controlUtils;
22 29 }
23 30  
  31 + public ControlUtils(DeviceDao deviceDao) {
  32 +
  33 + this.deviceDao = deviceDao;
  34 +
  35 +
  36 + }
  37 +
24 38 /**
25 39 * 根据温度变化操纵
  40 + *
26 41 * @param calDevContrls 联动模板
27   - * @param deviceBean 温度传感器对象
  42 + * @param deviceBean 温度传感器对象
28 43 */
29   - public void conTemper(List<CalDevContrl> calDevContrls, DeviceBean deviceBean){
  44 + public void conTemper(List<CalDevContrl> calDevContrls, DeviceBean deviceBean) {
30 45  
31 46 for (CalDevContrl cal :
32 47 calDevContrls) {
33 48  
34   - String inUseTime = cal.getInUseTime();//联动的时间范围,8:00-18:00
  49 + String inUseTime = cal.getInUserTime();//联动的时间范围,[{"Week":"5","StartTime":"14:02","EndTime":"14:06"}]
  50 + if (inUseTime == null) break;
  51 + try {
  52 + JSONArray jsonArray = new JSONArray(inUseTime);
35 53  
36   - String[] inUseTimes = inUseTime.split("-");
  54 + for (int i = 0; i < jsonArray.length(); i++) {
  55 + JSONObject jsonObject = jsonArray.getJSONObject(i);
37 56  
38   - String startTime = inUseTimes[0];
  57 + int week = jsonObject.getInt("Week");
39 58  
40   - String endTime = inUseTimes[1];
  59 + String startTime = jsonObject.getString("StartTime");
41 60  
42   - SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH:mm");
  61 + String endTime = jsonObject.getString("EndTime");
43 62  
44   - try {
  63 + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH:mm");
  64 + SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat("HH:mm:ss");
45 65  
46   - Date startDate = simpleDateFormat.parse(startTime);
47   - Date endDate = simpleDateFormat.parse(endTime);
48   - Date date = simpleDateFormat.parse(new Date().getHours()+":"+new Date().getMinutes());
  66 + int indexWeek = Calendar.getInstance().get(Calendar.DAY_OF_WEEK);
49 67  
50   - long starTime = startDate.getTime();
  68 + if (week == indexWeek) {
51 69  
52   - if (date.getTime()<endDate.getTime()&&date.getTime()>starTime){
53   - //比较器类型
54   - int compreType = cal.getCompreType();
  70 + Date startDate = simpleDateFormat.parse(startTime);
  71 + Date endDate = simpleDateFormat.parse(endTime);
  72 + Date date = simpleDateFormat1.parse(new Date().getHours() + ":" + new Date().getMinutes() + ":" + new Date().getSeconds());
55 73  
56   - switch (compreType){
57   - case 1://固定值
58   - calCompre(cal,deviceBean);
59   - break;
60   - case 2://当天日期
  74 + long starTime = startDate.getTime();
  75 + System.out.println("startDate:" + starTime);
  76 + System.out.println("endDate:" + endDate.getTime());
  77 + System.out.println("date:" + date.getTime());
  78 +
  79 + if (date.getTime() < endDate.getTime() && date.getTime() > starTime) {
  80 + //比较器类型
  81 + int compreType = cal.getCompreType();
  82 +
  83 + switch (compreType) {
  84 + case 1://固定值
  85 + calCompre(cal, deviceBean);
  86 + break;
  87 + case 2://当天日期
  88 +
  89 + break;
  90 + }
  91 + }
61 92  
62   - break;
63 93 }
  94 +
  95 + System.out.println("jsonObject:" + jsonObject.toString());
64 96 }
65 97  
  98 + } catch (JSONException e) {
  99 + e.printStackTrace();
66 100 } catch (ParseException e) {
67 101 e.printStackTrace();
68 102 }
69 103  
70   -
71 104 }
72 105  
73 106 }
74 107  
75 108 /**
76   - *
77   - * @param cal 联动模板
  109 + * @param cal 联动模板
78 110 * @param deviceBean 控制设备
79 111 */
80 112 private void calCompre(CalDevContrl cal, DeviceBean deviceBean) {
81   - int thrsoldValue = Integer.parseInt(cal.getThresholdValue());//设定的阈值
  113 +
  114 +
  115 + int thrsoldValue = 0;
  116 +
  117 + if (cal.getModelType() == 10) {//人体感应
  118 + if (cal.getThreValue().equals("有人")) thrsoldValue = 1;
  119 + else thrsoldValue = 0;
  120 + } else {
  121 + thrsoldValue = Integer.parseInt(cal.getThreValue());//设定的阈值
  122 + }
  123 +
82 124 int value = Integer.parseInt(deviceBean.getValue());//实际的值
83   - System.out.println("thrsoldValue:"+thrsoldValue+" value:"+value+" cal:"+cal.toString());
84   - switch (cal.getComPre()){
  125 + System.out.println("thrsoldValue:" + thrsoldValue + " value:" + value + " cal:" + cal.toString());
  126 + switch (cal.getComPre()) {
85 127 case 1://大于
86   - if (value>thrsoldValue)//启动触发条件
  128 + if (value > thrsoldValue)//启动触发条件
87 129 startDevice(cal);//开启联动的设备
88 130 break;
89 131 case 2://等于
90 132  
91   - if(value == thrsoldValue)
  133 + if (value == thrsoldValue)
92 134 startDevice(cal);//开启联动的设备
93 135  
94 136 break;
95 137 case 3://小于
96 138  
97   - if(value < thrsoldValue)
  139 + if (value < thrsoldValue)
98 140 startDevice(cal);//开启联动的设备
99 141  
100 142 break;
  143 + default://不触发条件
  144 +
  145 + removeSet(cal);
  146 +
  147 + break;
  148 + }
  149 +
  150 + }
  151 +
  152 + /**
  153 + * 移除设备
  154 + *
  155 + * @param calDevContrl
  156 + */
  157 + private void removeSet(CalDevContrl calDevContrl) {
  158 +
  159 + Iterator<CalDevContrl> calDevContrlIterator = deviceSet.iterator();
  160 +
  161 + while (calDevContrlIterator.hasNext()) {
  162 +
  163 + CalDevContrl calDevContrl1 = calDevContrlIterator.next();
  164 + if (calDevContrl1.getDevid().equals(calDevContrl.getDevid()) && calDevContrl.getComPre() == calDevContrl1.getComPre()) {
  165 + calDevContrlIterator.remove();
  166 + }
101 167 }
102 168  
103 169 }
104 170  
105 171 /**
106   - * 执行计划
  172 + * 执行计划,并判断联动的设备是否满足条件;
  173 + *
107 174 * @param cal
108 175 */
109 176 private void startDevice(CalDevContrl cal) {
110 177  
111 178 int modelType = cal.getModelType();
112   - String conDevId = cal.getConDevId();//被控制的设备id
113   - String conValue =cal.getConValue();
114   - String conCode = cal.getConCode();
115   - switch (modelType){
116   - case 1://开关
117   - HttpUtil.controlDev(conDevId,conCode,conValue);
118   - break;
119   - case 2://插座
120   - HttpUtil.controlDev(conDevId,conCode,conValue);
121   - break;
122   - case 3://排插
123   - HttpUtil.controlDev(conDevId,conCode,conValue);
124   - break;
125   - case 7://空调伴侣
126   - HttpUtil.addAirCode(conValue,conDevId);
127   - break;
128   - case 10://开关
129   - HttpUtil.controlDev(conDevId,conCode,conValue);
130   - break;
131   - case 12://万能遥控器
132   - HttpUtil.addAirCode(conValue,conDevId);
133   - break;
  179 +
  180 + deviceSet.add(cal);
  181 +
  182 + String assDevice = cal.getAssDevice();//联动的设备id
  183 +
  184 + boolean isExit = isExist(assDevice.split(","));
  185 +
  186 + System.out.println("是否符合联动条件:" + isExit);
  187 +
  188 + if (isExit) {//符合联动条件
  189 +
  190 + List<CalDevBeContrl> calDevBeContrlList = getCalDevBeCon(assDevice);
  191 +
  192 + for (int i = 0; i < calDevBeContrlList.size(); i++) {
  193 + CalDevBeContrl calDevBeContrl = calDevBeContrlList.get(i);
  194 + System.out.println("控制对象:" + calDevBeContrl.toString());
  195 + String conDevId = calDevBeContrl.getConDevId();//被控制的设备id
  196 + String conValue = calDevBeContrl.getConValue();
  197 + String conCodes = calDevBeContrl.getConCode();
  198 +
  199 + String[] conCodeStr = conCodes.split(",");
  200 +
  201 + for (int j = 0; j < conCodeStr.length; j++) {
  202 + String conCode = conCodeStr[j];
  203 + switch (modelType) {
  204 + case 1://开关
  205 + HttpUtil.controlDev(conDevId, conCode, conValue);
  206 + break;
  207 + case 2://插座
  208 + HttpUtil.controlDev(conDevId, conCode, conValue);
  209 + break;
  210 + case 3://排插
  211 + HttpUtil.controlDev(conDevId, conCode, conValue);
  212 + break;
  213 + case 7://空调伴侣
  214 + HttpUtil.addAirCode(conValue, conDevId);
  215 + break;
  216 + case 10://开关
  217 + HttpUtil.controlDev(conDevId, conCode, conValue);
  218 + break;
  219 + case 12://万能遥控器
  220 + HttpUtil.addAirCode(conValue, conDevId);
  221 + break;
  222 + }
  223 + }
  224 +
  225 + }
  226 +
134 227 }
135 228  
  229 + }
  230 +
  231 + /**
  232 + * 获取被控制的设备
  233 + *
  234 + * @param assDevice
  235 + * @return
  236 + */
  237 + private List<CalDevBeContrl> getCalDevBeCon(String assDevice) {
  238 +
  239 + String[] assDeviceIds = assDevice.split(",");
  240 +
  241 + List<CalDevBeContrl> devBeContrlList = new ArrayList<>();
  242 +
  243 + for (int i = 0; i < assDeviceIds.length; i++) {
  244 + String deviceId = assDeviceIds[i];
  245 +
  246 + List<CalDevContrl> calDevContrl = deviceDao.getCalDevContrlWidthDevId(deviceId);
  247 +
  248 + for (int j = 0; j < calDevContrl.size(); j++) {
  249 +
  250 + CalDevContrl calDevContrl1 = calDevContrl.get(j);
  251 +
  252 + if (!calDevContrl1.getDevBeId().equals("0")) {
  253 + String[] calDevBeIdStr = calDevContrl1.getDevBeId().split(",");
  254 + if (calDevBeIdStr != null) {
  255 + for (int k = 0; k < calDevBeIdStr.length; k++) {
  256 + CalDevBeContrl calDevBeContrl = deviceDao.getCalDevBeControl(calDevBeIdStr[k]);
  257 + devBeContrlList.add(calDevBeContrl);
  258 + }
  259 + }
  260 + }
  261 + }
  262 +
  263 + }
  264 +
  265 + return devBeContrlList;
  266 + }
  267 +
  268 +
  269 + /**
  270 + * 判断联动设备是否符合条件
  271 + *
  272 + * @param deviceIds
  273 + * @return
  274 + */
  275 + private boolean isExist(String[] deviceIds) {
  276 +
  277 + for (int i = 0; i < deviceIds.length; i++) {
  278 + String deviceId = deviceIds[i];
  279 + Iterator<CalDevContrl> calDevContrlIterator = deviceSet.iterator();
  280 + boolean is = false;
  281 + while (calDevContrlIterator.hasNext()) {
  282 +
  283 + CalDevContrl calDevContrl = calDevContrlIterator.next();
  284 + if (calDevContrl.getDevid().equals(deviceId)) {//存在设备
  285 + is = true;
  286 + }
  287 +
  288 + }
  289 + if (!is) return false;
  290 + }
  291 + return true;
136 292  
137 293 }
138 294  
... ...
cloud/mypulsar/src/main/java/com/example/mypulsar/utils/HttpUtil.java
... ... @@ -3,7 +3,6 @@ package com.example.mypulsar.utils;
3 3 import com.example.mypulsar.bean.Command;
4 4 import com.example.mypulsar.bean.TuYaAirCondition;
5 5 import com.example.mypulsar.bean.TuYaCommand;
6   -import org.apache.pulsar.shade.com.google.gson.Gson;
7 6 import org.springframework.boot.configurationprocessor.json.JSONException;
8 7 import org.springframework.boot.configurationprocessor.json.JSONObject;
9 8 import org.springframework.core.io.FileSystemResource;
... ... @@ -156,7 +155,6 @@ public class HttpUtil {
156 155  
157 156 System.out.println("url-------------------------------:" + url+" conValue:"+tuYaAirCondition.toString());
158 157 String response = restTemplate.postForObject(url, tuYaAirCondition, String.class);
159   -
160 158 System.out.println("response----------------------------------:" + response);
161 159 return response;
162 160  
... ...
cloud/pom.xml
... ... @@ -14,58 +14,81 @@
14 14 <name>cloud</name>
15 15 <description>Demo project for Spring Boot</description>
16 16  
  17 + <properties>
  18 + <java.version>1.8</java.version>
  19 + <spring-cloud.version>Greenwich.SR1</spring-cloud.version>
  20 + <commons-collections4.version>4.1</commons-collections4.version>
  21 + <spring-boot.version>2.1.7.RELEASE</spring-boot.version>
  22 + <security-oauth2.version>2.3.6.RELEASE</security-oauth2.version>
  23 + <fastjson.version>1.2.60</fastjson.version>
  24 + <spring-platform-bom.version>Cairo-SR7</spring-platform-bom.version>
  25 + </properties>
  26 +
17 27 <modules>
18 28 <module>server1</module>
19 29 <module>server2</module>
20 30 <!-- <module>autho</module>-->
21   - <module>common</module>
22   -<!-- <module>geteway</module>-->
  31 +<!-- <module>common</module>-->
  32 + <module>geteway</module>
23 33 <module>haikang</module>
24 34 <!-- <module>dahua</module>-->
25 35 <!-- <module>consumer</module>-->
26 36 <!-- <module>haikangface</module>-->
27 37 <!-- <module>search_independence</module>-->
28   - <module>search_smartCampus</module>
29   - <module>search_xiaoan</module>
  38 +<!-- <module>search_smartCampus</module>-->
  39 +<!-- <module>search_xiaoan</module>-->
30 40 <!-- <module>mypulsar</module>-->
31 41 <!-- <module>weigeng</module>-->
32 42 <!-- <module>independence</module>-->
33   - <module>quartz</module>
34   - <module>zkAttendance</module>
  43 +<!-- <module>quartz</module>-->
  44 + <!-- <module>zkAttendance</module>-->
35 45 </modules>
36 46  
37   - <properties>
38   - <java.version>1.8</java.version>
39   - <spring-cloud.version>Greenwich.SR1</spring-cloud.version>
40   - </properties>
41   -
42 47 <dependencies>
43 48 <dependency>
44   - <groupId>org.springframework.cloud</groupId>
45   - <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
  49 + <groupId>com.alibaba</groupId>
  50 + <artifactId>fastjson</artifactId>
  51 + <version>1.2.58</version>
  52 + <scope>compile</scope>
46 53 </dependency>
47 54  
48 55 <dependency>
49   - <groupId>org.springframework.boot</groupId>
50   - <artifactId>spring-boot-starter-test</artifactId>
51   - <scope>test</scope>
  56 + <groupId>org.projectlombok</groupId>
  57 + <artifactId>lombok</artifactId>
  58 + <version>1.18.8</version>
52 59 </dependency>
53 60  
54 61 <dependency>
55   - <groupId>org.springframework.boot</groupId>
56   - <artifactId>spring-boot-starter-actuator</artifactId>
  62 + <groupId>org.springframework.cloud</groupId>
  63 + <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
57 64 </dependency>
58 65  
59 66 <dependency>
  67 + <groupId>org.springframework.cloud</groupId>
  68 + <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
  69 + </dependency>
  70 + <dependency>
60 71 <groupId>org.springframework.boot</groupId>
61 72 <artifactId>spring-boot-configuration-processor</artifactId>
62   - <!--<version>2.1.3.RELEASE</version>-->
  73 + <optional>true</optional>
63 74 </dependency>
64 75 <dependency>
65   - <groupId>com.alibaba</groupId>
66   - <artifactId>fastjson</artifactId>
67   - <version>1.2.58</version>
68   - <scope>compile</scope>
  76 + <groupId>org.springframework.boot</groupId>
  77 + <artifactId>spring-boot-starter-actuator</artifactId>
  78 + </dependency>
  79 + <dependency>
  80 + <groupId>org.springframework.cloud</groupId>
  81 + <artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
  82 + </dependency>
  83 + <dependency>
  84 + <groupId>org.projectlombok</groupId>
  85 + <artifactId>lombok</artifactId>
  86 + <version>1.16.20</version>
  87 + </dependency>
  88 + <dependency>
  89 + <groupId>commons-io</groupId>
  90 + <artifactId>commons-io</artifactId>
  91 + <version>2.6</version>
69 92 </dependency>
70 93  
71 94 </dependencies>
... ... @@ -73,12 +96,26 @@
73 96 <dependencyManagement>
74 97 <dependencies>
75 98 <dependency>
  99 + <groupId>org.springframework.boot</groupId>
  100 + <artifactId>spring-boot-dependencies</artifactId>
  101 + <version>${spring-boot.version}</version>
  102 + <type>pom</type>
  103 + <scope>import</scope>
  104 + </dependency>
  105 + <dependency>
76 106 <groupId>org.springframework.cloud</groupId>
77 107 <artifactId>spring-cloud-dependencies</artifactId>
78 108 <version>${spring-cloud.version}</version>
79 109 <type>pom</type>
80 110 <scope>import</scope>
81 111 </dependency>
  112 + <dependency>
  113 + <groupId>io.spring.platform</groupId>
  114 + <artifactId>platform-bom</artifactId>
  115 + <version>${spring-platform-bom.version}</version>
  116 + <type>pom</type>
  117 + <scope>import</scope>
  118 + </dependency>
82 119 </dependencies>
83 120 </dependencyManagement>
84 121 </project>
... ...
cloud/quartz/src/main/java/com/sincere/quartz/enums/KqTypeEnums.java
... ... @@ -6,21 +6,21 @@ package com.sincere.quartz.enums;
6 6 * @date 2019/11/29 0029 11:44
7 7 */
8 8 public enum KqTypeEnums {
9   - morning_to_school(1,"早上到校"),
10   - noon_le_school(2,"中午离校"),
11   - afternoon_to_school(3,"下午到校"),
12   - afternoon_le_school(4,"下午离校"),
13   - night_to_school(5,"晚上到校"),
14   - night_le_school(6,"晚上离校"),
15   - morning_to_chamber(7,"早上离寝"),
16   - noon_to_chamber(8,"中午到寝"),
17   - noon_le_chamber(9,"中午离寝"),
18   - afternoon_to_chamber(10,"下午到寝"),
19   - afternoon_le_chamber(11,"下午离寝"),
20   - night_to_chamber(12,"晚上到寝");
21   -
22   - private int type ;
23   - private String name ;
  9 + morning_to_school(1, "早上到校"),
  10 + noon_le_school(2, "中午离校"),
  11 + afternoon_to_school(3, "下午到校"),
  12 + afternoon_le_school(4, "下午离校"),
  13 + night_to_school(5, "晚上到校"),
  14 + night_le_school(6, "晚上离校"),
  15 + morning_to_chamber(7, "早上离寝"),
  16 + noon_to_chamber(8, "中午到寝"),
  17 + noon_le_chamber(9, "中午离寝"),
  18 + afternoon_to_chamber(10, "下午到寝"),
  19 + afternoon_le_chamber(11, "下午离寝"),
  20 + night_to_chamber(12, "晚上到寝");
  21 +
  22 + private int type;
  23 + private String name;
24 24  
25 25 public int getType() {
26 26 return type;
... ... @@ -43,12 +43,12 @@ public enum KqTypeEnums {
43 43 this.name = name;
44 44 }
45 45  
46   - public static String getName(int type){
47   - for(KqTypeEnums enums : KqTypeEnums.values()){
48   - if(enums.getType() == type){
  46 + public static String getName(int type) {
  47 + for (KqTypeEnums enums : KqTypeEnums.values()) {
  48 + if (enums.getType() == type) {
49 49 return enums.getName();
50 50 }
51 51 }
52   - return "" ;
  52 + return "";
53 53 }
54 54 }
... ...
cloud/quartz/src/main/java/com/sincere/quartz/enums/TypeEnums.java
... ... @@ -7,15 +7,15 @@ package com.sincere.quartz.enums;
7 7 */
8 8 public enum TypeEnums {
9 9  
10   - kaoqing(10,"考勤");
  10 + kaoqing(10, "考勤");
11 11  
12 12 TypeEnums(int type, String name) {
13 13 this.type = type;
14 14 this.name = name;
15 15 }
16 16  
17   - private int type ;
18   - private String name ;
  17 + private int type;
  18 + private String name;
19 19  
20 20 public int getType() {
21 21 return type;
... ...
cloud/quartz/src/main/java/com/sincere/quartz/job/KQJob.java
... ... @@ -308,8 +308,8 @@ public class KQJob {
308 308 "整体数据:" + message);
309 309 String wapUrl = "http://campus.myjxt.com/studentRecord/znxwwebapp/index.html?" +
310 310 "schoolid="+teacher.getSchoolId()+"&userId="+teacher.getUserId()+"&name="+teacher.getName()+ "&TemplateId=" + templateId+
311   - "&data="+thirdOpenId+"&type=5&stype=4&mobile="+teacher.getMobile()+"&pass="+teacher.getPass()+
312   - "&QianDaoId="+times[3]+"&ClassId=0&face=&sourcetype=16&soutype=3&timestamp="+ DateUtils.getDate()+"&time="+DateUtils.date2String(new Date(),DateUtils.format1) ;
  311 + "&data="+thirdOpenId+"&type=1&stype=4&mobile="+teacher.getMobile()+"&pass="+teacher.getPass()+
  312 + "&face=&sourcetype=16&soutype=3&timestamp="+ DateUtils.getDate()+"&time="+DateUtils.date2String(new Date(),DateUtils.format1) ;
313 313 dingSms.setSchoolId(teacher.getSchoolId());
314 314 dingSms.setDingUserId(thirdOpenId);
315 315 dingSms.setAgentId(appDto.getAgentId());
... ...
cloud/quartz/src/main/java/com/sincere/quartz/model/DingSms.java
... ... @@ -6,16 +6,16 @@ package com.sincere.quartz.model;
6 6 * @date 2019/11/28 0028 9:45
7 7 */
8 8 public class DingSms {
9   - private String tableName ;
10   -
11   - private String msg ;
12   - private int schoolId ;
13   - private String dingUserId ;
14   - private String wapUrl ;
15   - private String agentId ;
16   - private int tdType ;
17   - private String receiveUserId ;
18   - private String name ;
  9 + private String tableName;
  10 +
  11 + private String msg;
  12 + private int schoolId;
  13 + private String dingUserId;
  14 + private String wapUrl;
  15 + private String agentId;
  16 + private int tdType;
  17 + private String receiveUserId;
  18 + private String name;
19 19  
20 20 public String getTableName() {
21 21 return tableName;
... ...
cloud/quartz/src/main/java/com/sincere/quartz/model/ShortMsg.java
... ... @@ -7,11 +7,11 @@ package com.sincere.quartz.model;
7 7 */
8 8 public class ShortMsg {
9 9  
10   - private String tableName ;
  10 + private String tableName;
11 11  
12   - private int schoolId ;
13   - private String mobile ;
14   - private String msg ;
  12 + private int schoolId;
  13 + private String mobile;
  14 + private String msg;
15 15  
16 16 public String getTableName() {
17 17 return tableName;
... ...
cloud/quartz/src/main/java/com/sincere/quartz/model/WeChatSms.java
... ... @@ -7,17 +7,17 @@ package com.sincere.quartz.model;
7 7 */
8 8 public class WeChatSms {
9 9  
10   - private String tableName ;
11   -
12   - private String receiveUserId ;
13   - private String qiYeHaoUserId ;
14   - private int schoolId ;
15   - private String msgUrl ;
16   - private String name ;
17   - private String appId ;
18   - private String secret ;
19   - private int tdType ;
20   - private String msg ;
  10 + private String tableName;
  11 +
  12 + private String receiveUserId;
  13 + private String qiYeHaoUserId;
  14 + private int schoolId;
  15 + private String msgUrl;
  16 + private String name;
  17 + private String appId;
  18 + private String secret;
  19 + private int tdType;
  20 + private String msg;
21 21  
22 22  
23 23 public String getAppId() {
... ...
cloud/quartz/src/main/resources/logback.xml
1 1 <?xml version="1.0" encoding="UTF-8"?>
2 2 <configuration debug="true">
3 3     <!-- 项目名称 -->
4   -     <property name="PROJECT_NAME" value="quartz" />
  4 +    
  5 + <property name="PROJECT_NAME" value="quartz"/>
5 6  
6 7     <!--定义日志文件的存储地址 勿在 LogBack 的配置中使用相对路径-->
7   - <property name="LOG_HOME" value="C://log"/>
  8 + <property name="LOG_HOME" value="C://log"/>
8 9  
9 10     <!-- 控制台输出 -->
10   -     <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
11   -         <!--<withJansi>true</withJansi>-->
12   -         <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
13   -             <!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
14   -             <pattern>[%d{yyyy-MM-dd HH:mm:ss.SSS}] [%thread] %highlight([%-5level] %logger{50} - %msg%n)</pattern>
15   -             <charset>UTF-8</charset>
16   -         </encoder>
17   -     </appender>
  11 +    
  12 + <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
  13 +         <!--<withJansi>true</withJansi>-->
  14 +        
  15 + <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
  16 +             <!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
  17 +            
  18 + <pattern>[%d{yyyy-MM-dd HH:mm:ss.SSS}] [%thread] %highlight([%-5level] %logger{50} - %msg%n)</pattern>
  19 +            
  20 + <charset>UTF-8</charset>
  21 +        
  22 + </encoder>
  23 +    
  24 + </appender>
18 25  
19 26     <!-- 按照每天生成日志文件 -->
20   -     <appender name="SYSTEM_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
21   -         <!-- 过滤器,只打印ERROR级别的日志 -->
22   -         <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
23   -             <!--日志文件输出的文件名-->
24   -             <FileNamePattern>${LOG_HOME}/${PROJECT_NAME}/%d{yyyy-MM-dd}.%i.log</FileNamePattern>
25   -             <!--日志文件保留天数-->
26   -             <MaxHistory>30</MaxHistory>
27   -             <!--日志文件最大的大小-->
28   -             <MaxFileSize>100MB</MaxFileSize>
29   -         </rollingPolicy>
30   -
31   -         <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
32   -             <!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
33   -             <pattern>[%d{yyyy-MM-dd HH:mm:ss.SSS}] [%thread] [%-5level] %logger{50} - %msg%n</pattern>
34   -             <charset>UTF-8</charset>
35   -         </encoder>
36   -     </appender>
37   -     <logger name="system_error" additivity="true">
38   -        <appender-ref ref="SYSTEM_FILE"/>
39   -    </logger>
40   -
41   -    <!-- 设置Spring&Hibernate日志输出级别 -->
42   -    <logger name="org.springframework" level="WARN" />
43   -    <logger name="org.mybatis" level="WARN" />
44   -    <logger name="com.ibatis" level="DEBUG" />
45   -    <logger name="com.ibatis.common.jdbc.SimpleDataSource" level="DEBUG" />
46   -    <logger name="com.ibatis.common.jdbc.ScriptRunner" level="DEBUG" />
47   -    <logger name="com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate" level="DEBUG" />
48   -
49   -
50   -    <logger name="java.sql.Connection" level="DEBUG" />
51   -    <logger name="java.sql.Statement" level="DEBUG" />
52   -    <logger name="java.sql.PreparedStatement" level="DEBUG" />
53   -    <logger name="com.sincere.smartSearch.mapper" level="DEBUG" />
54   -    <!-- 开发环境下的日志配置 -->
55   -    <root level="INFO">
56   -        <appender-ref ref="CONSOLE" />
57   -        <appender-ref ref="SYSTEM_FILE" />
58   -    </root>
  27 +    
  28 + <appender name="SYSTEM_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
  29 +         <!-- 过滤器,只打印ERROR级别的日志 -->
  30 +        
  31 + <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
  32 +             <!--日志文件输出的文件名-->
  33 +            
  34 + <FileNamePattern>${LOG_HOME}/${PROJECT_NAME}/%d{yyyy-MM-dd}.%i.log</FileNamePattern>
  35 +             <!--日志文件保留天数-->
  36 +            
  37 + <MaxHistory>30</MaxHistory>
  38 +             <!--日志文件最大的大小-->
  39 +            
  40 + <MaxFileSize>100MB</MaxFileSize>
  41 +        
  42 + </rollingPolicy>
  43 +
  44 +        
  45 + <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
  46 +             <!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
  47 +            
  48 + <pattern>[%d{yyyy-MM-dd HH:mm:ss.SSS}] [%thread] [%-5level] %logger{50} - %msg%n</pattern>
  49 +            
  50 + <charset>UTF-8</charset>
  51 +        
  52 + </encoder>
  53 +    
  54 + </appender>
  55 +    
  56 + <logger name="system_error" additivity="true">
  57 +        
  58 + <appender-ref ref="SYSTEM_FILE"/>
  59 +    
  60 + </logger>
  61 +
  62 +     <!-- 设置Spring&Hibernate日志输出级别 -->
  63 +    
  64 + <logger name="org.springframework" level="WARN"/>
  65 +    
  66 + <logger name="org.mybatis" level="WARN"/>
  67 +    
  68 + <logger name="com.ibatis" level="DEBUG"/>
  69 +    
  70 + <logger name="com.ibatis.common.jdbc.SimpleDataSource" level="DEBUG"/>
  71 +    
  72 + <logger name="com.ibatis.common.jdbc.ScriptRunner" level="DEBUG"/>
  73 +    
  74 + <logger name="com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate" level="DEBUG"/>
  75 +
  76 +
  77 +    
  78 + <logger name="java.sql.Connection" level="DEBUG"/>
  79 +    
  80 + <logger name="java.sql.Statement" level="DEBUG"/>
  81 +    
  82 + <logger name="java.sql.PreparedStatement" level="DEBUG"/>
  83 +    
  84 + <logger name="com.sincere.smartSearch.mapper" level="DEBUG"/>
  85 +     <!-- 开发环境下的日志配置 -->
  86 +    
  87 + <root level="INFO">
  88 +        
  89 + <appender-ref ref="CONSOLE"/>
  90 +        
  91 + <appender-ref ref="SYSTEM_FILE"/>
  92 +    
  93 + </root>
59 94  
60 95 </configuration>
... ...
cloud/quartz/src/main/resources/mapper/SmsMapper.xml
... ... @@ -3,17 +3,21 @@
3 3 <mapper namespace="com.sincere.quartz.mapper.SmsMapper">
4 4  
5 5 <insert id="insertDing" parameterType="com.sincere.quartz.model.DingSms">
6   - insert into ${tableName} (Msg,MsgID,SchoolID,Type,Status,intime,sendtime,DingUserId,WapUrl,agentid,tdtype,ReceiveUserID,Remark)
7   - values (#{msg},-1,#{schoolId},3,0,GETDATE(),GETDATE(),#{dingUserId},#{wapUrl},#{agentId},#{tdType},#{receiveUserId},#{name})
  6 + insert into ${tableName} (Msg, MsgID, SchoolID, Type, Status, intime, sendtime, DingUserId, WapUrl, agentid,
  7 + tdtype, ReceiveUserID, Remark)
  8 + values (#{msg}, -1, #{schoolId}, 1, 0, GETDATE(), GETDATE(), #{dingUserId}, #{wapUrl}, #{agentId}, #{tdType},
  9 + #{receiveUserId}, #{name})
8 10 </insert>
9 11  
10 12 <insert id="insertWeChat" parameterType="com.sincere.quartz.model.WeChatSms">
11   - insert into ${tableName} (SchoolID,MsgID,Guid,WapUrl,Status,intime,sendTime,SendUserName,ReceiveUserID,QiYeHaoUserId,AppID,Secret,tdtype,Remark)
12   - values (#{schoolId},-1,#{msg},#{msgUrl},0,GETDATE(),GETDATE(),'智能校卫',#{receiveUserId},#{qiYeHaoUserId},#{appId},#{secret},#{tdType},#{name})
  13 + insert into ${tableName} (SchoolID, MsgID, Guid, WapUrl, Status, intime, sendTime, SendUserName, ReceiveUserID,
  14 + QiYeHaoUserId, AppID, Secret, tdtype, Remark)
  15 + values (#{schoolId}, -1, #{msg}, #{msgUrl}, 0, GETDATE(), GETDATE(), '智能校卫', #{receiveUserId}, #{qiYeHaoUserId},
  16 + #{appId}, #{secret}, #{tdType}, #{name})
13 17 </insert>
14 18  
15 19 <insert id="insertSMS" parameterType="com.sincere.quartz.model.ShortMsg">
16   - insert into ${tableName} (SchoolID,Mobile,Msg,tdtype,Status,IsNeedSend,SendTime,intime)
17   - values (#{schoolId},#{mobile},#{msg},1,0,1,GETDATE(),GETDATE())
  20 + insert into ${tableName} (SchoolID, Mobile, Msg, tdtype, Status, IsNeedSend, SendTime, intime)
  21 + values (#{schoolId}, #{mobile}, #{msg}, 1, 0, 1, GETDATE(), GETDATE())
18 22 </insert>
19 23 </mapper>
... ...
cloud/search_smartCampus/src/main/java/com/sincere/smartSearch/FileConfiguration.java
... ... @@ -1,18 +0,0 @@
1   -package com.sincere.smartSearch;
2   -
3   -import org.springframework.context.annotation.Configuration;
4   -import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
5   -import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
6   -
7   -@Configuration
8   -public class FileConfiguration extends WebMvcConfigurationSupport {
9   -
10   - @Override
11   - protected void addResourceHandlers(ResourceHandlerRegistry registry) {
12   - super.addResourceHandlers(registry);
13   -
14   - registry.addResourceHandler("/upload/**")
15   - .addResourceLocations("file:C:/upload/");
16   -
17   - }
18   -}
cloud/search_xiaoan/pom.xml
... ... @@ -51,6 +51,7 @@
51 51 <artifactId>rapid-core</artifactId>
52 52 <version>4.0.5</version>
53 53 </dependency>
  54 +
54 55 <dependency>
55 56 <groupId>org.apache.commons</groupId>
56 57 <artifactId>commons-lang3</artifactId>
... ...
cloud/server1/pom.xml
... ... @@ -13,6 +13,31 @@
13 13 <name>server1</name>
14 14 <description>Demo project for Spring Boot</description>
15 15  
  16 + <dependencies>
  17 +
  18 + <dependency>
  19 + <groupId>com.aliyun.oss</groupId>
  20 + <artifactId>oss</artifactId>
  21 + <scope>system</scope>
  22 + <version>1</version>
  23 + <systemPath>${project.basedir}/libs/aliyun-sdk-oss-3.8.0.jar</systemPath>
  24 + </dependency>
  25 +
  26 + <dependency>
  27 + <groupId>com.jdom</groupId>
  28 + <artifactId>jdom</artifactId>
  29 + <scope>system</scope>
  30 + <version>1</version>
  31 + <systemPath>${project.basedir}/libs/jdom-1.1.jar</systemPath>
  32 + </dependency>
  33 +
  34 + <dependency>
  35 + <groupId>org.springframework.cloud</groupId>
  36 + <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
  37 + </dependency>
  38 +
  39 + </dependencies>
  40 +
16 41 <build>
17 42 <plugins>
18 43 <plugin>
... ...
cloud/server1/src/main/java/com/sincere/server1/Server1Application.java
... ... @@ -4,6 +4,14 @@ import org.springframework.boot.SpringApplication;
4 4 import org.springframework.boot.autoconfigure.SpringBootApplication;
5 5 import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
6 6  
  7 +import java.io.FileNotFoundException;
  8 +import java.io.FileOutputStream;
  9 +import java.io.IOException;
  10 +import java.io.InputStream;
  11 +import java.net.MalformedURLException;
  12 +import java.net.URL;
  13 +import java.net.URLConnection;
  14 +
7 15 @EnableEurekaServer
8 16 @SpringBootApplication
9 17 public class Server1Application {
... ...
cloud/server1/src/main/java/com/sincere/server1/Test2.java 0 → 100644
... ... @@ -0,0 +1,91 @@
  1 +package com.sincere.server1;
  2 +
  3 +import com.aliyun.oss.OSS;
  4 +import com.aliyun.oss.OSSClientBuilder;
  5 +
  6 +import java.io.*;
  7 +import java.net.URL;
  8 +
  9 +public class Test2 {
  10 +
  11 + // Endpoint以杭州为例,其它Region请按实际情况填写。
  12 + public static String endpoint = "http://oss-cn-hangzhou.aliyuncs.com";
  13 + // 云账号AccessKey有所有API访问权限,建议遵循阿里云安全最佳实践,创建并使用RAM子账号进行API访问或日常运维,请登录 https://ram.console.aliyun.com 创建。
  14 + public static String accessKeyId = "QiuM3PwHTnVotcGy";
  15 + public static String accessKeySecret = "Yqs7RlaC1MioZu2YYJ6u0TdeO13VFC";
  16 +
  17 + public static void main(String[] args) {
  18 + File filePath = new File("D:\\OSS\\video.txt");
  19 + try {
  20 + BufferedReader bufferedReader = new BufferedReader(new FileReader(filePath));
  21 +
  22 + String cotnent = null;
  23 +
  24 + int index = 0;
  25 + while ((cotnent=bufferedReader.readLine())!=null){
  26 +
  27 + upLoadNetStraeam(cotnent,"",cotnent.substring(cotnent.lastIndexOf("/")+1,cotnent.length()));
  28 + index++;
  29 + System.out.println("index:"+index);
  30 +
  31 + }
  32 +
  33 + } catch (FileNotFoundException e) {
  34 + e.printStackTrace();
  35 + } catch (IOException e) {
  36 + e.printStackTrace();
  37 + }
  38 +// File[] files = filePath.listFiles();
  39 +// upLoadNetStraeam("http://0575jyzx.oss-cn-hangzhou.aliyuncs.com/Air/Data/898b208f82574ddcba2d439a1e28bd39.mp4", "test", "898b208f82574ddcba2d439a1e28bd39.mp4");
  40 + /* for (File file:
  41 + files) {
  42 +
  43 + upload(file,"Data");
  44 +
  45 + }*/
  46 + }
  47 +
  48 + /**
  49 + * 上传网络流
  50 + * @param url
  51 + * @param path
  52 + * @param name
  53 + */
  54 + public static void upLoadNetStraeam(String url, String path, String name) {
  55 + System.out.println("name:"+name+" url --"+url);
  56 +// 创建OSSClient实例。
  57 + OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
  58 +
  59 +// 上传网络流。
  60 + InputStream inputStream = null;
  61 + try {
  62 + inputStream = new URL(url).openStream();
  63 + } catch (IOException e) {
  64 + e.printStackTrace();
  65 + }
  66 + ossClient.putObject("szyundisk", "YikeData/" + name, inputStream);
  67 +
  68 +// 关闭OSSClient。
  69 + ossClient.shutdown();
  70 +
  71 + }
  72 +
  73 + public static void upload(File file, String path) {
  74 +
  75 +// 创建OSSClient实例。
  76 + OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
  77 +
  78 +// 上传文件流。
  79 + InputStream inputStream = null;
  80 + try {
  81 + inputStream = new FileInputStream(file);
  82 + ossClient.putObject("szyundisk", "Air/" + path + "/" + file.getName(), inputStream);
  83 +
  84 +// 关闭OSSClient。
  85 + ossClient.shutdown();
  86 + } catch (FileNotFoundException e) {
  87 + e.printStackTrace();
  88 + }
  89 + }
  90 +
  91 +}
... ...
cloud/server1/src/main/resources/application.yaml
... ... @@ -3,7 +3,7 @@ server:
3 3  
4 4 spring:
5 5 application:
6   - name: eureka-server
  6 + name: eureka-server1
7 7 profiles:
8 8 active: dev
9 9  
... ...
cloud/server2/pom.xml
... ... @@ -13,6 +13,13 @@
13 13 <name>server2</name>
14 14 <description>Demo project for Spring Boot</description>
15 15  
  16 + <dependencies>
  17 + <dependency>
  18 + <groupId>org.springframework.cloud</groupId>
  19 + <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
  20 + </dependency>
  21 + </dependencies>
  22 +
16 23 <build>
17 24 <plugins>
18 25 <plugin>
... ...
cloud/server2/src/main/resources/application.yaml
... ... @@ -3,7 +3,7 @@ server:
3 3  
4 4 spring:
5 5 application:
6   - name: eureka-server
  6 + name: eureka-server2
7 7 profiles:
8 8 active: dev
9 9  
... ...
cloud/uploadFile/test.jpg

150 KB