Commit b971c4366b403aa4e3a970f6f7d60ec5b0c177ef
1 parent
1a68a9be
Exists in
master
smartcampussearcg增加获取教师和学生个人信息的接口
Showing
28 changed files
with
887 additions
and
110 deletions
Show diff stats
cloud/RibbonConsume/src/main/resources/bootstrap.yml
| ... | ... | @@ -12,8 +12,9 @@ spring: |
| 12 | 12 | eureka: |
| 13 | 13 | client: |
| 14 | 14 | serviceUrl: |
| 15 | + defaultZone: http:// | |
| 15 | 16 | # defaultZone: http://localhost:8761/eureka/,http://localhost:8762/eureka/ |
| 16 | - defaultZone: http://121.40.109.21:8761/eureka/,http://121.40.109.21:8762/eureka/ | |
| 17 | +# defaultZone: http://121.40.109.21:8761/eureka/,http://121.40.109.21:8762/eureka/ | |
| 17 | 18 | #http://134.224.249.33:1111/eureka/ 正式库 |
| 18 | 19 | #http://134.224.249.33:1111/eureka/ 测试库 |
| 19 | 20 | #http://127.0.0.1:8761/eureka,http://127.0.0.1:8762/eureka | ... | ... |
cloud/dahua/pom.xml
| ... | ... | @@ -118,11 +118,11 @@ |
| 118 | 118 | <artifactId>mybatis-spring-boot-starter</artifactId> |
| 119 | 119 | <version>2.0.1</version> |
| 120 | 120 | </dependency> |
| 121 | - <dependency> | |
| 122 | - <groupId>com.sincere</groupId> | |
| 123 | - <artifactId>common</artifactId> | |
| 124 | - <version>1.0.0</version> | |
| 125 | - </dependency> | |
| 121 | +<!-- <dependency>--> | |
| 122 | +<!-- <groupId>com.sincere</groupId>--> | |
| 123 | +<!-- <artifactId>common</artifactId>--> | |
| 124 | +<!-- <version>1.0.0</version>--> | |
| 125 | +<!-- </dependency>--> | |
| 126 | 126 | |
| 127 | 127 | <!--<dependency>--> |
| 128 | 128 | <!--<groupId>com.drewnoakes</groupId>--> | ... | ... |
cloud/dahua/src/main/java/com/example/dahua/control/FileControl.java
| ... | ... | @@ -83,6 +83,14 @@ public class FileControl { |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | |
| 86 | + @RequestMapping(value = "imgsSend", method = RequestMethod.GET) | |
| 87 | + @ApiOperation(value = "照片下放") | |
| 88 | + public boolean imgsSend(@RequestParam("schoolId") String schoolId, @RequestParam("type") int type) { | |
| 89 | + userService.sendUserInfos(schoolId, "22", type); | |
| 90 | + return true; | |
| 91 | + } | |
| 92 | + | |
| 93 | + | |
| 86 | 94 | |
| 87 | 95 | |
| 88 | 96 | } | ... | ... |
cloud/dahua/src/main/java/com/example/dahua/control/UserControl.java
| ... | ... | @@ -6,7 +6,6 @@ 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; | |
| 10 | 9 | import io.swagger.annotations.Api; |
| 11 | 10 | import io.swagger.annotations.ApiImplicitParam; |
| 12 | 11 | import io.swagger.annotations.ApiImplicitParams; |
| ... | ... | @@ -370,6 +369,33 @@ public class UserControl { |
| 370 | 369 | // } |
| 371 | 370 | |
| 372 | 371 | |
| 372 | + @RequestMapping(value = "FaceSearch", method = RequestMethod.POST) | |
| 373 | + @ApiOperation("人脸搜索") | |
| 374 | + public String FaceSearch(@RequestPart("file")MultipartFile file) { | |
| 375 | + | |
| 376 | + // 请求url | |
| 377 | + String url = "https://aip.baidubce.com/rest/2.0/face/v3/search"; | |
| 378 | + try { | |
| 379 | + Map<String, Object> map = new HashMap<>(); | |
| 380 | + map.put("image", Base64Util.encode(file.getBytes())); | |
| 381 | + map.put("liveness_control", "NORMAL"); | |
| 382 | + map.put("group_id_list", "One"); | |
| 383 | + map.put("image_type", "BASE64"); | |
| 384 | + map.put("quality_control", "NORMAL"); | |
| 385 | + String param = GsonUtils.toJson(map); | |
| 386 | + // 注意这里仅为了简化编码每一次请求都去获取access_token,线上环境access_token有过期时间, 客户端可自行缓存,过期后重新获取。 | |
| 387 | + String accessToken = getAuth(); | |
| 388 | + String result = HttpUtil.post(url, accessToken, "application/json", param); | |
| 389 | + System.out.println(result); | |
| 390 | + return result; | |
| 391 | + } catch (Exception e) { | |
| 392 | + e.printStackTrace(); | |
| 393 | + } | |
| 394 | + return null; | |
| 395 | + | |
| 396 | + } | |
| 397 | + | |
| 398 | + | |
| 373 | 399 | @RequestMapping(value = "movePic", method = RequestMethod.GET) |
| 374 | 400 | @ApiOperation("转移下发失败的图片到批量图片库") |
| 375 | 401 | public void movePic(@RequestParam("schoolId") int schoolId, @RequestParam("userType") int usertype, @RequestParam("deviceId") String deviceId) { |
| ... | ... | @@ -449,7 +475,8 @@ public class UserControl { |
| 449 | 475 | |
| 450 | 476 | |
| 451 | 477 | |
| 452 | - private String url = "https://aip.baidubce.com/rest/2.0/ocr/v1/general_basic?access_token="+ AuthService.getAuth(); | |
| 478 | + private String url = "https://aip.baidubce.com/rest/2.0/ocr/v1/general_basic?access_token="+AuthService.getAuth(); | |
| 479 | +// + AuthService.getAuth(); | |
| 453 | 480 | |
| 454 | 481 | private String getAnswer(String imgUrl, int type) { |
| 455 | 482 | RestTemplate restTemplate = new RestTemplate(); | ... | ... |
cloud/dahua/src/main/java/com/example/dahua/utils/AuthService.java
0 → 100644
| ... | ... | @@ -0,0 +1,93 @@ |
| 1 | +package com.example.dahua.utils; | |
| 2 | + | |
| 3 | +import org.json.JSONObject; | |
| 4 | + | |
| 5 | +import java.io.BufferedReader; | |
| 6 | +import java.io.InputStreamReader; | |
| 7 | +import java.net.HttpURLConnection; | |
| 8 | +import java.net.URL; | |
| 9 | + | |
| 10 | +/** | |
| 11 | + * 获取token类 | |
| 12 | + */ | |
| 13 | +public class AuthService { | |
| 14 | + //设置APPID/AK/SK | |
| 15 | + public static final String APP_ID = "15990462"; | |
| 16 | + public static final String API_KEY = "t70Rzr6SGmfU9S6MrqAkspsY"; | |
| 17 | + public static final String SECRET_KEY = "nSqpqtrf7cCjo8vOB9knL85nwWNoxwvS "; | |
| 18 | + /** | |
| 19 | + * 获取权限token | |
| 20 | + * @return 返回示例: | |
| 21 | + * { | |
| 22 | + * "access_token": "24.460da4889caad24cccdb1fea17221975.2592000.1491995545.282335-1234567", | |
| 23 | + * "expires_in": 2592000 | |
| 24 | + * } | |
| 25 | + */ | |
| 26 | + //获取文字识别id | |
| 27 | + public static String getAuth() { | |
| 28 | + // 官网获取的 API Key 更新为你注册的 | |
| 29 | + String clientId = "t70Rzr6SGmfU9S6MrqAkspsY"; | |
| 30 | + // 官网获取的 Secret Key 更新为你注册的 | |
| 31 | + String clientSecret = "nSqpqtrf7cCjo8vOB9knL85nwWNoxwvS"; | |
| 32 | + return getAuth(clientId, clientSecret); | |
| 33 | + } | |
| 34 | + | |
| 35 | + public static String getFaceAuthToken() { | |
| 36 | + // 官网获取的 API Key 更新为你注册的 | |
| 37 | + String clientId = "u6rV4YxRZmwzKj56N0DCW8eO"; | |
| 38 | + // 官网获取的 Secret Key 更新为你注册的 | |
| 39 | + String clientSecret = "Krp3KhmIBdnNEsRa1LavMHuZl0KhQGVm"; | |
| 40 | + return getAuth(clientId, clientSecret); | |
| 41 | + } | |
| 42 | + | |
| 43 | + /** | |
| 44 | + * 获取API访问token | |
| 45 | + * 该token有一定的有效期,需要自行管理,当失效时需重新获取. | |
| 46 | + * @param ak - 百度云官网获取的 API Key | |
| 47 | + * @param sk - 百度云官网获取的 Securet Key | |
| 48 | + * @return assess_token 示例: | |
| 49 | + * "24.460da4889caad24cccdb1fea17221975.2592000.1491995545.282335-1234567" | |
| 50 | + */ | |
| 51 | + public static String getAuth(String ak, String sk) { | |
| 52 | + // 获取token地址 | |
| 53 | + String authHost = "https://aip.baidubce.com/oauth/2.0/token?"; | |
| 54 | + String getAccessTokenUrl = authHost | |
| 55 | + // 1. grant_type为固定参数 | |
| 56 | + + "grant_type=client_credentials" | |
| 57 | + // 2. 官网获取的 API Key | |
| 58 | + + "&client_id=" + ak | |
| 59 | + // 3. 官网获取的 Secret Key | |
| 60 | + + "&client_secret=" + sk; | |
| 61 | + try { | |
| 62 | + URL realUrl = new URL(getAccessTokenUrl); | |
| 63 | + // 打开和URL之间的连接 | |
| 64 | + HttpURLConnection connection = (HttpURLConnection) realUrl.openConnection(); | |
| 65 | + connection.setRequestMethod("GET"); | |
| 66 | + connection.connect(); | |
| 67 | + // 获取所有响应头字段 | |
| 68 | +// Map<String, List<String>> map = connection.getHeaderFields(); | |
| 69 | +// // 遍历所有的响应头字段 | |
| 70 | +// for (String key : map.keySet()) { | |
| 71 | +// System.err.println(key + "--->" + map.get(key)); | |
| 72 | +// } | |
| 73 | + // 定义 BufferedReader输入流来读取URL的响应 | |
| 74 | + BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream())); | |
| 75 | + String result = ""; | |
| 76 | + String line; | |
| 77 | + while ((line = in.readLine()) != null) { | |
| 78 | + result += line; | |
| 79 | + } | |
| 80 | + /** | |
| 81 | + * 返回结果示例 | |
| 82 | + */ | |
| 83 | +// System.err.println("result:" + result); | |
| 84 | + JSONObject jsonObject = new JSONObject(result); | |
| 85 | + String access_token = jsonObject.getString("access_token"); | |
| 86 | + return access_token; | |
| 87 | + } catch (Exception e) { | |
| 88 | + System.err.printf("获取token失败!"); | |
| 89 | + e.printStackTrace(System.err); | |
| 90 | + } | |
| 91 | + return null; | |
| 92 | + } | |
| 93 | +} | ... | ... |
cloud/dahua/src/main/java/com/example/dahua/utils/HttpUtils.java
| ... | ... | @@ -7,9 +7,12 @@ import org.springframework.http.MediaType; |
| 7 | 7 | import org.springframework.http.ResponseEntity; |
| 8 | 8 | import org.springframework.util.LinkedMultiValueMap; |
| 9 | 9 | import org.springframework.util.MultiValueMap; |
| 10 | +import org.springframework.web.bind.annotation.RequestParam; | |
| 10 | 11 | import org.springframework.web.client.RestTemplate; |
| 11 | 12 | |
| 12 | 13 | import java.io.File; |
| 14 | +import java.util.HashMap; | |
| 15 | +import java.util.Map; | |
| 13 | 16 | |
| 14 | 17 | public class HttpUtils { |
| 15 | 18 | |
| ... | ... | @@ -49,4 +52,13 @@ public class HttpUtils { |
| 49 | 52 | } |
| 50 | 53 | |
| 51 | 54 | |
| 55 | + public static boolean imgsSend(String schoolId, int type){ | |
| 56 | + String url = "http://121.40.109.21:8991/file/imgsSend?schoolId="+schoolId+"&type="+type; | |
| 57 | + RestTemplate restTemplate = new RestTemplate(); | |
| 58 | + ResponseEntity<Boolean> result = restTemplate.getForEntity(url,Boolean.class); | |
| 59 | + System.out.println("result:"+result.getBody()); | |
| 60 | + return result.getBody(); | |
| 61 | + } | |
| 62 | + | |
| 63 | + | |
| 52 | 64 | } | ... | ... |
cloud/dahua/src/main/resources/application.yaml
| ... | ... | @@ -1,62 +0,0 @@ |
| 1 | -server: | |
| 2 | - port: 8991 | |
| 3 | -#spring: | |
| 4 | -# datasource: | |
| 5 | -# username: szjxtuser | |
| 6 | -# password: RQminVCJota3H1u8bBYH | |
| 7 | -# url: jdbc:sqlserver://116.62.155.137:33419;database=SmartCampus | |
| 8 | -# driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver | |
| 9 | -# application: | |
| 10 | -# name: dahuaserver | |
| 11 | - | |
| 12 | -spring: | |
| 13 | - datasource: | |
| 14 | - campus: | |
| 15 | - username: szjxtuser | |
| 16 | - password: RQminVCJota3H1u8bBYH | |
| 17 | - jdbc-url: jdbc:sqlserver://116.62.155.137:33419;database=SmartCampus | |
| 18 | - driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver | |
| 19 | -# username: SZJXTUSER | |
| 20 | -# password: xst200919 | |
| 21 | -# jdbc-url: jdbc:sqlserver://60.190.202.57:14333;database=SmartCampusSZ | |
| 22 | -# driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver | |
| 23 | - xiaoan: | |
| 24 | - jdbc-url: jdbc:sqlserver://116.62.241.27:33419;database=xiaoanhxy | |
| 25 | - username: szjxtuser | |
| 26 | - password: RQminVCJota3H1u8bBYH | |
| 27 | - driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver | |
| 28 | -# jdbc-url: jdbc:sqlserver://60.190.202.57:14333;database=xiaoanhxy | |
| 29 | -# username: SZJXTUSER | |
| 30 | -# password: xst200919 | |
| 31 | -# driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver | |
| 32 | - application: | |
| 33 | - name: dahuaserver | |
| 34 | - | |
| 35 | - | |
| 36 | -eureka: | |
| 37 | - instance: | |
| 38 | - hostname: localhost | |
| 39 | - lease-expiration-duration-in-seconds: 60 | |
| 40 | - lease-renewal-interval-in-seconds: 10 | |
| 41 | - prefer-ip-address: true | |
| 42 | - client: | |
| 43 | - service-url: | |
| 44 | -# defaultZone: http://localhost:8761/eureka/ | |
| 45 | - defaultZone: http://121.40.109.21:8761/eureka/,http://121.40.109.21:8762/eureka/ | |
| 46 | - | |
| 47 | -mybatis: | |
| 48 | - campus: | |
| 49 | - type-aliases-package: com.example.dahua.dao | |
| 50 | - mapper-locations: classpath:mapper/*.xml | |
| 51 | - xiaoan: | |
| 52 | - type-aliases-package: com.example.dahua.xiananDao | |
| 53 | - mapper-locations: classpath:xiaoanmapper/*.xml | |
| 54 | - config-location: classpath:mybatis-config.xml | |
| 55 | - | |
| 56 | - | |
| 57 | -#haikangpic: E:\wwwhtdocs\HFface\FaceLogs\ | |
| 58 | - | |
| 59 | -#haikangfaceurl: http://60.190.202.57:8899 | |
| 60 | - | |
| 61 | - | |
| 62 | - |
| ... | ... | @@ -0,0 +1,48 @@ |
| 1 | +#spring: | |
| 2 | +# datasource: | |
| 3 | +# username: szjxtuser | |
| 4 | +# password: RQminVCJota3H1u8bBYH | |
| 5 | +# url: jdbc:sqlserver://116.62.155.137:33419;database=SmartCampus | |
| 6 | +# driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver | |
| 7 | +# application: | |
| 8 | +# name: dahuaserver | |
| 9 | + | |
| 10 | +spring: | |
| 11 | + datasource: | |
| 12 | + campus: | |
| 13 | + username: szjxtuser | |
| 14 | + password: RQminVCJota3H1u8bBYH | |
| 15 | + jdbc-url: jdbc:sqlserver://116.62.155.137:33419;database=SmartCampus | |
| 16 | + driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver | |
| 17 | +# username: SZJXTUSER | |
| 18 | +# password: xst200919 | |
| 19 | +# jdbc-url: jdbc:sqlserver://60.190.202.57:14333;database=SmartCampusSZ | |
| 20 | +# driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver | |
| 21 | + xiaoan: | |
| 22 | + jdbc-url: jdbc:sqlserver://116.62.241.27:33419;database=xiaoanhxy | |
| 23 | + username: szjxtuser | |
| 24 | + password: RQminVCJota3H1u8bBYH | |
| 25 | + driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver | |
| 26 | +# jdbc-url: jdbc:sqlserver://60.190.202.57:14333;database=xiaoanhxy | |
| 27 | +# username: SZJXTUSER | |
| 28 | +# password: xst200919 | |
| 29 | +# driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | +mybatis: | |
| 34 | + campus: | |
| 35 | + type-aliases-package: com.example.dahua.dao | |
| 36 | + mapper-locations: classpath:mapper/*.xml | |
| 37 | + xiaoan: | |
| 38 | + type-aliases-package: com.example.dahua.xiananDao | |
| 39 | + mapper-locations: classpath:xiaoanmapper/*.xml | |
| 40 | + config-location: classpath:mybatis-config.xml | |
| 41 | + | |
| 42 | + | |
| 43 | +#haikangpic: E:\wwwhtdocs\HFface\FaceLogs\ | |
| 44 | + | |
| 45 | +#haikangfaceurl: http://60.190.202.57:8899 | |
| 46 | + | |
| 47 | + | |
| 48 | + | ... | ... |
| ... | ... | @@ -0,0 +1,40 @@ |
| 1 | +#端口 | |
| 2 | +server: | |
| 3 | + port: 8991 #固定端口 | |
| 4 | +# port: ${randomServerPort.value[5000,5005]} #随机端口 | |
| 5 | + | |
| 6 | +#服务名称 | |
| 7 | +spring: | |
| 8 | + application: | |
| 9 | + name: dahua | |
| 10 | + | |
| 11 | +#management: | |
| 12 | +# endpoints: | |
| 13 | +# web: | |
| 14 | +# exposure: | |
| 15 | +# include: "*" | |
| 16 | +# endpoint: | |
| 17 | +# health: | |
| 18 | +# show-details: always | |
| 19 | + | |
| 20 | +#eureka client配置 | |
| 21 | +eureka: | |
| 22 | + client: | |
| 23 | + serviceUrl: | |
| 24 | +# defaultZone: http://localhost:8761/eureka/,http://localhost:8762/eureka/ | |
| 25 | + defaultZone: http://121.40.109.21:8761/eureka/,http://121.40.109.21:8762/eureka/ | |
| 26 | + #http://134.224.249.33:1111/eureka/ 正式库 | |
| 27 | + #http://134.224.249.33:1111/eureka/ 测试库 | |
| 28 | + #http://127.0.0.1:8761/eureka,http://127.0.0.1:8762/eureka | |
| 29 | + registry-fetch-interval-seconds: 5 | |
| 30 | + instance-info-replication-interval-seconds: 10 | |
| 31 | + instance: | |
| 32 | +# prefer-ip-address: false | |
| 33 | + instance-id: ${spring.application.name} | |
| 34 | +# instance-id: ${spring.application.name}:${spring.cloud.client.ip-address}:${spring.application.instance_id:${server.port}} #固定端口 | |
| 35 | +# instance-id: ${spring.application.name}:${spring.cloud.client.ip-address}:${spring.application.instance_id:${randomServerPort.value[5000,5005]}} #随机端口 | |
| 36 | + lease-renewal-interval-in-seconds: 10 #每隔几秒告诉eureka服务器我还存活,用于心跳检测 | |
| 37 | + lease-expiration-duration-in-seconds: 10 #如果心跳检测一直没有发送,10秒后会从eureka服务器中将此服务剔除 | |
| 38 | +# status-page-url: http://${spring.cloud.client.ip-address}:${server.port}/doc.html # ${server.port}为该服务的端口号 | |
| 39 | + hostname: 114.55.30.100 | |
| 40 | +# status-page-url: http://${spring.cloud.client.ip-address}:${randomServerPort.value[5000,5005]}/document.html # ${server.port}为该服务的端口号 | |
| 0 | 41 | \ No newline at end of file | ... | ... |
cloud/fIle-center/src/main/java/com/sincere/file/control/FileControl.java
| ... | ... | @@ -43,17 +43,32 @@ public class FileControl { |
| 43 | 43 | FileService fileService; |
| 44 | 44 | |
| 45 | 45 | @PostMapping("fileUpload") |
| 46 | - @ApiOperation("上传文件") | |
| 46 | + @ApiOperation("上传文件(重复文件会新增1)") | |
| 47 | 47 | public String fileUpload(@RequestParam("file") MultipartFile file, HttpServletRequest request) throws Exception { |
| 48 | 48 | |
| 49 | 49 | String ossPath = request.getHeader("ossPath");//oss的二级目录 |
| 50 | 50 | |
| 51 | + | |
| 52 | + FileInfo fileInfo = fileService.upload(file, ossPath); | |
| 53 | + | |
| 54 | + return fileInfo.getUrl(); | |
| 55 | + | |
| 56 | + } | |
| 57 | + | |
| 58 | + | |
| 59 | + @PostMapping("fileUpload1") | |
| 60 | + @ApiOperation("上传文件") | |
| 61 | + public String fileUpload1(@RequestParam("file") MultipartFile file, HttpServletRequest request) throws Exception { | |
| 62 | + | |
| 63 | + String ossPath = request.getHeader("ossPath");//oss的二级目录 | |
| 64 | + | |
| 51 | 65 | FileInfo fileInfo = fileService.upload(file, ossPath); |
| 52 | 66 | |
| 53 | 67 | return fileInfo.getUrl(); |
| 54 | 68 | |
| 55 | 69 | } |
| 56 | 70 | |
| 71 | + | |
| 57 | 72 | @DeleteMapping("deleteFile/{fileName}") |
| 58 | 73 | @ApiOperation("删除文件") |
| 59 | 74 | public boolean deleteFile(@PathVariable String fileName, HttpServletRequest request) { | ... | ... |
cloud/fIle-center/src/main/java/com/sincere/file/service/impl/AliyunOssServiceImpl.java
| ... | ... | @@ -9,6 +9,7 @@ import org.springframework.stereotype.Service; |
| 9 | 9 | import org.springframework.web.multipart.MultipartFile; |
| 10 | 10 | |
| 11 | 11 | import java.io.File; |
| 12 | +import java.util.UUID; | |
| 12 | 13 | |
| 13 | 14 | /** |
| 14 | 15 | * @author 作者 owen E-mail: 624191343@qq.com |
| ... | ... | @@ -41,8 +42,9 @@ public class AliyunOssServiceImpl extends AbstractFileService { |
| 41 | 42 | |
| 42 | 43 | @Override |
| 43 | 44 | protected void uploadFile(MultipartFile file, FileInfo fileInfo,String filePath) throws Exception { |
| 44 | - ossClient.putObject(bucketName, filePath+"/"+fileInfo.getName(), file.getInputStream()); | |
| 45 | - fileInfo.setUrl(domain+"/" +filePath+ "/" + fileInfo.getName()); | |
| 45 | + String fileName = UUID.randomUUID().toString()+"."+fileInfo.getName().split("\\.")[1]; | |
| 46 | + ossClient.putObject(bucketName, filePath+"/"+fileName, file.getInputStream()); | |
| 47 | + fileInfo.setUrl(domain+"/" +filePath+ "/" + fileName); | |
| 46 | 48 | } |
| 47 | 49 | |
| 48 | 50 | @Override | ... | ... |
cloud/getaway/src/main/java/com/sincere/getaway/client/filter/AccessFilter.java
| ... | ... | @@ -46,6 +46,7 @@ public class AccessFilter implements GlobalFilter, Ordered { |
| 46 | 46 | @Override |
| 47 | 47 | public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) { |
| 48 | 48 | String accessToken = this.extractToken(exchange.getRequest()); |
| 49 | + System.out.println("path:"+exchange.getRequest().getPath().value()); | |
| 49 | 50 | // 默认 |
| 50 | 51 | boolean flag = false; |
| 51 | 52 | for (String ignored :permitUrlProperties.getIgnored()) { | ... | ... |
cloud/getaway/src/main/java/com/sincere/getaway/client/filter/SwaggerHeaderFilter.java
| ... | ... | @@ -21,6 +21,9 @@ public class SwaggerHeaderFilter extends AbstractGatewayFilterFactory { |
| 21 | 21 | return (exchange, chain) -> { |
| 22 | 22 | ServerHttpRequest request = exchange.getRequest(); |
| 23 | 23 | String path = request.getURI().getPath(); |
| 24 | + | |
| 25 | + System.out.println("path:"+path); | |
| 26 | + | |
| 24 | 27 | if (!StringUtils.endsWithIgnoreCase(path, SwaggerProvider.API_URI)) { |
| 25 | 28 | return chain.filter(exchange); |
| 26 | 29 | } | ... | ... |
cloud/getaway/src/main/resources/application.yml
| ... | ... | @@ -55,6 +55,13 @@ spring: |
| 55 | 55 | - Path=/NewSmartCampus/** |
| 56 | 56 | filters: |
| 57 | 57 | - StripPrefix=1 |
| 58 | + - id: dahua | |
| 59 | +# uri: lb://dahua | |
| 60 | + uri: http://114.55.30.100:8991 | |
| 61 | + predicates: | |
| 62 | + - Path=/dahua/** | |
| 63 | + filters: | |
| 64 | + - StripPrefix=1 | |
| 58 | 65 | # default-filters: |
| 59 | 66 | # - DedupeResponseHeader=Access-Control-Allow-Origin, RETAIN_UNIQUE |
| 60 | 67 | # discovery: |
| ... | ... | @@ -78,4 +85,4 @@ ribbon: |
| 78 | 85 | |
| 79 | 86 | |
| 80 | 87 | url: |
| 81 | - ignored: /SmartCampusWebApi/**,/authserver/**,/NewSmartCampus/**,/file-center/** | |
| 82 | 88 | \ No newline at end of file |
| 89 | + ignored: /SmartCampusWebApi/**,/authserver/**,/NewSmartCampus/**,/file-center/**,/dahua/** | |
| 83 | 90 | \ No newline at end of file | ... | ... |
cloud/haikangface/src/main/java/com/sincere/haikangface/CMSServer.java
| ... | ... | @@ -398,7 +398,7 @@ public class CMSServer implements ApplicationRunner { |
| 398 | 398 | strXMLData.read(); |
| 399 | 399 | |
| 400 | 400 | String strXML = new String(strXMLData.byValue); |
| 401 | -// System.out.println(strXML); | |
| 401 | + System.out.println(strXML); | |
| 402 | 402 | |
| 403 | 403 | if (null == alarmUtils) { |
| 404 | 404 | alarmUtils = new AlarmUtils(deviceDao); | ... | ... |
cloud/mypulsar/src/main/java/com/example/mypulsar/MyRunnerableInt.java
| ... | ... | @@ -199,7 +199,7 @@ public class MyRunnerableInt implements ApplicationRunner { |
| 199 | 199 | String value = statue.getValue(); |
| 200 | 200 | deviceBean.setValue(value); |
| 201 | 201 | |
| 202 | - System.out.println("插入数据:" +value); | |
| 202 | + System.out.println(devId+"-插入数据:" +value); | |
| 203 | 203 | switch (code) { |
| 204 | 204 | case "va_temperature"://温度 |
| 205 | 205 | deviceBean.setValue(Integer.parseInt(value)/100+""); |
| ... | ... | @@ -263,8 +263,14 @@ public class MyRunnerableInt implements ApplicationRunner { |
| 263 | 263 | case "pir"://人体感应 |
| 264 | 264 | log("人体感应:" + value); |
| 265 | 265 | value = (value.equals("pir") ? "有人" : "无人"); |
| 266 | + | |
| 266 | 267 | deviceBean.setValue(value); |
| 267 | - calOpenOrCloseDevWithPir(deviceBean); | |
| 268 | + try { | |
| 269 | + Thread.sleep(1000); | |
| 270 | + calOpenOrCloseDevWithPir(deviceBean); | |
| 271 | + } catch (InterruptedException e) { | |
| 272 | + e.printStackTrace(); | |
| 273 | + } | |
| 268 | 274 | break; |
| 269 | 275 | case "cur_voltage"://当前电压 |
| 270 | 276 | // value = Integer.parseInt(value) / 10 + "V"; |
| ... | ... | @@ -293,6 +299,7 @@ public class MyRunnerableInt implements ApplicationRunner { |
| 293 | 299 | private void calOpenOrCloseDevWithPir(DeviceBean deviceBean) { |
| 294 | 300 | |
| 295 | 301 | List<CalDevContrl> calDevContrls = deviceDao.getCalDevContrlWidthDevId(deviceBean.getDevId()); |
| 302 | + System.out.println("calOpenOrCloseDevWithPir:"+calDevContrls.toString()); | |
| 296 | 303 | if (null != calDevContrls && calDevContrls.size() > 0) { |
| 297 | 304 | if (deviceBean.getValue().equals("有人")) deviceBean.setValue("1"); |
| 298 | 305 | else deviceBean.setValue("0"); | ... | ... |
cloud/mypulsar/src/main/java/com/example/mypulsar/dao/DeviceDao.java
| ... | ... | @@ -43,6 +43,6 @@ public interface DeviceDao { |
| 43 | 43 | @Select("select * from CalDevContrl where Devid = #{Devid} and Status = 1") |
| 44 | 44 | List<CalDevContrl> getCalDevContrlWidthDevId(@Param("Devid") String devId); |
| 45 | 45 | |
| 46 | - @Select("select * from CalDevContrl where State = 1 and Id = #{Id}") | |
| 46 | + @Select("select * from CalDevBeContrl where State = 1 and Id = #{Id}") | |
| 47 | 47 | CalDevBeContrl getCalDevBeControl(@Param("Id") String Id); |
| 48 | 48 | } | ... | ... |
cloud/mypulsar/src/main/java/com/example/mypulsar/utils/ControlUtils.java
| ... | ... | @@ -47,7 +47,9 @@ public class ControlUtils { |
| 47 | 47 | calDevContrls) { |
| 48 | 48 | |
| 49 | 49 | String inUseTime = cal.getInUserTime();//联动的时间范围,[{"Week":"5","StartTime":"14:02","EndTime":"14:06"}] |
| 50 | + | |
| 50 | 51 | if (inUseTime == null) break; |
| 52 | +// System.out.println("inUseTime:"+inUseTime); | |
| 51 | 53 | try { |
| 52 | 54 | JSONArray jsonArray = new JSONArray(inUseTime); |
| 53 | 55 | |
| ... | ... | @@ -72,9 +74,9 @@ public class ControlUtils { |
| 72 | 74 | Date date = simpleDateFormat1.parse(new Date().getHours() + ":" + new Date().getMinutes() + ":" + new Date().getSeconds()); |
| 73 | 75 | |
| 74 | 76 | long starTime = startDate.getTime(); |
| 75 | - System.out.println("startDate:" + starTime); | |
| 76 | - System.out.println("endDate:" + endDate.getTime()); | |
| 77 | - System.out.println("date:" + date.getTime()); | |
| 77 | +// System.out.println("startDate:" + starTime); | |
| 78 | +// System.out.println("endDate:" + endDate.getTime()); | |
| 79 | +// System.out.println("date:" + date.getTime()); | |
| 78 | 80 | |
| 79 | 81 | if (date.getTime() < endDate.getTime() && date.getTime() > starTime) { |
| 80 | 82 | //比较器类型 |
| ... | ... | @@ -82,7 +84,7 @@ public class ControlUtils { |
| 82 | 84 | |
| 83 | 85 | switch (compreType) { |
| 84 | 86 | case 1://固定值 |
| 85 | - calCompre(cal, deviceBean); | |
| 87 | + calCompre(cal,deviceBean); | |
| 86 | 88 | break; |
| 87 | 89 | case 2://当天日期 |
| 88 | 90 | |
| ... | ... | @@ -92,7 +94,7 @@ public class ControlUtils { |
| 92 | 94 | |
| 93 | 95 | } |
| 94 | 96 | |
| 95 | - System.out.println("jsonObject:" + jsonObject.toString()); | |
| 97 | +// System.out.println("jsonObject:" + jsonObject.toString()); | |
| 96 | 98 | } |
| 97 | 99 | |
| 98 | 100 | } catch (JSONException e) { |
| ... | ... | @@ -181,7 +183,8 @@ public class ControlUtils { |
| 181 | 183 | |
| 182 | 184 | String assDevice = cal.getAssDevice();//联动的设备id |
| 183 | 185 | |
| 184 | - boolean isExit = isExist(assDevice.split(",")); | |
| 186 | +// boolean isExit = isExist(assDevice.split(",")); | |
| 187 | + boolean isExit = true; | |
| 185 | 188 | |
| 186 | 189 | System.out.println("是否符合联动条件:" + isExit); |
| 187 | 190 | |
| ... | ... | @@ -214,7 +217,8 @@ public class ControlUtils { |
| 214 | 217 | HttpUtil.addAirCode(conValue, conDevId); |
| 215 | 218 | break; |
| 216 | 219 | case 10://开关 |
| 217 | - HttpUtil.controlDev(conDevId, conCode, conValue); | |
| 220 | +// HttpUtil.controlDev(conDevId, conCode, conValue); | |
| 221 | + HttpUtil.addAirCode(conValue, conDevId); | |
| 218 | 222 | break; |
| 219 | 223 | case 12://万能遥控器 |
| 220 | 224 | HttpUtil.addAirCode(conValue, conDevId); | ... | ... |
cloud/mypulsar/src/main/java/com/example/mypulsar/utils/HttpUtil.java
| ... | ... | @@ -88,7 +88,7 @@ public class HttpUtil { |
| 88 | 88 | result += getLine; |
| 89 | 89 | } |
| 90 | 90 | in.close(); |
| 91 | - System.err.println("result:" + result); | |
| 91 | +// System.err.println("result:" + result); | |
| 92 | 92 | return result; |
| 93 | 93 | } |
| 94 | 94 | |
| ... | ... | @@ -112,7 +112,7 @@ public class HttpUtil { |
| 112 | 112 | |
| 113 | 113 | String responseEntity = restTemplate.postForObject(url, tuYaCommand, String.class); |
| 114 | 114 | |
| 115 | - System.out.println("tuYaCommand:" + tuYaCommand.toString()); | |
| 115 | + System.out.println("tuYaCommand:" + tuYaCommand.toString()+"----deviceId:"+deviceId); | |
| 116 | 116 | System.out.println("responseEntity:" + responseEntity); |
| 117 | 117 | return responseEntity.equals("1"); |
| 118 | 118 | } |
| ... | ... | @@ -144,11 +144,12 @@ public class HttpUtil { |
| 144 | 144 | JSONObject jsonObject = new JSONObject(conValue); |
| 145 | 145 | tuYaAirCondition.setMode(jsonObject.getString("mode")); |
| 146 | 146 | tuYaAirCondition.setPower(jsonObject.getString("power")); |
| 147 | - tuYaAirCondition.setRemote_id(jsonObject.getString("remote_index")); | |
| 147 | + tuYaAirCondition.setRemote_id(jsonObject.getString("remote_id")); | |
| 148 | 148 | tuYaAirCondition.setWind(jsonObject.getString("wind")); |
| 149 | 149 | tuYaAirCondition.setTemp(jsonObject.getString("temp")); |
| 150 | 150 | tuYaAirCondition.setRemote_index(jsonObject.getString("remote_index")); |
| 151 | 151 | |
| 152 | + | |
| 152 | 153 | } catch (JSONException e) { |
| 153 | 154 | e.printStackTrace(); |
| 154 | 155 | } | ... | ... |
cloud/search_smartCampus/src/main/java/com/sincere/smartSearch/controller/UserController.java
| ... | ... | @@ -23,4 +23,19 @@ public class UserController { |
| 23 | 23 | String selectStudentNumByStudentId(@RequestParam("studentId") int studentId){ |
| 24 | 24 | return userService.selectStudentNumByStudentId(studentId); |
| 25 | 25 | } |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + @RequestMapping(value = "getStudent_NumWitdCode",method = RequestMethod.GET) | |
| 30 | + String getStudent_NumWitdCode(@RequestParam("studentcode") String studentcode){ | |
| 31 | + return userService.getStudent_NumWitdCode(studentcode); | |
| 32 | + } | |
| 33 | + | |
| 34 | + | |
| 35 | + @RequestMapping(value = "getTeacherWithstudentcode",method = RequestMethod.GET) | |
| 36 | + String getTeacherWithstudentcode(@RequestParam("num") String num,@RequestParam("schoolId") String schoolId){ | |
| 37 | + return userService.getTeacherWithstudentcode(num,schoolId); | |
| 38 | + } | |
| 39 | + | |
| 40 | + | |
| 26 | 41 | } | ... | ... |
cloud/search_smartCampus/src/main/java/com/sincere/smartSearch/mapper/UserMapper.java
| ... | ... | @@ -8,4 +8,13 @@ package com.sincere.smartSearch.mapper; |
| 8 | 8 | public interface UserMapper { |
| 9 | 9 | |
| 10 | 10 | String selectStudentNumByStudentId(int studentId); |
| 11 | + | |
| 12 | + @Select("select Top(1)*\n" + | |
| 13 | + "from SZ_V_School_Teacher\n" + | |
| 14 | + "where num = #{num} and school_id = #{schoolId}") | |
| 15 | + StudentBean getTeacherWithstudentcode(@Param("num") String num,@Param("schoolId")String schoolId); | |
| 16 | + | |
| 17 | + @Select("select Top(1) * from SZ_V_School_Student where studentcode = #{studentcode}") | |
| 18 | + StudentBean getStudent_NumWitdCode(@Param("studentcode") String studentcode); | |
| 19 | + | |
| 11 | 20 | } | ... | ... |
cloud/search_smartCampus/src/main/java/com/sincere/smartSearch/model/StudentBean.java
0 → 100644
| ... | ... | @@ -0,0 +1,307 @@ |
| 1 | +package com.sincere.haikangface.bean; | |
| 2 | + | |
| 3 | +import java.io.Serializable; | |
| 4 | +import java.util.Date; | |
| 5 | + | |
| 6 | +public class StudentBean implements Serializable { | |
| 7 | + | |
| 8 | + private String teacher_id; | |
| 9 | + | |
| 10 | + private String parent_id; | |
| 11 | + | |
| 12 | + private long ID; | |
| 13 | + | |
| 14 | + private String UserId; | |
| 15 | + | |
| 16 | + private String CustomerId; | |
| 17 | + | |
| 18 | + private int StudentType; | |
| 19 | + | |
| 20 | + private int UserType; | |
| 21 | + | |
| 22 | + private String name; | |
| 23 | + | |
| 24 | + private int ClassId; | |
| 25 | + | |
| 26 | + private String ClassName; | |
| 27 | + | |
| 28 | + private String OldCard; | |
| 29 | + | |
| 30 | + private String Card; | |
| 31 | + | |
| 32 | + private int SchoolId; | |
| 33 | + | |
| 34 | + private int school_id; | |
| 35 | + | |
| 36 | + private int IsNew; | |
| 37 | + | |
| 38 | + private int UpdateType; | |
| 39 | + | |
| 40 | + private Date AddTime; | |
| 41 | + | |
| 42 | + private int Sex; | |
| 43 | + | |
| 44 | + private String Face; | |
| 45 | + | |
| 46 | + private String studentcode; | |
| 47 | + | |
| 48 | + private String student_num; | |
| 49 | + | |
| 50 | + private String student_id; | |
| 51 | + | |
| 52 | + private String user_id; | |
| 53 | + | |
| 54 | + private String photo; | |
| 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 | + | |
| 76 | + public String getPhoto() { | |
| 77 | + return photo; | |
| 78 | + } | |
| 79 | + | |
| 80 | + public void setPhoto(String photo) { | |
| 81 | + this.photo = photo; | |
| 82 | + } | |
| 83 | + | |
| 84 | + public String getUser_id() { | |
| 85 | + return user_id; | |
| 86 | + } | |
| 87 | + | |
| 88 | + public void setUser_id(String user_id) { | |
| 89 | + this.user_id = user_id; | |
| 90 | + } | |
| 91 | + | |
| 92 | + public String getStudentcode() { | |
| 93 | + return studentcode; | |
| 94 | + } | |
| 95 | + | |
| 96 | + public void setStudentcode(String studentcode) { | |
| 97 | + this.studentcode = studentcode; | |
| 98 | + } | |
| 99 | + | |
| 100 | + public String getUserId() { | |
| 101 | + return UserId; | |
| 102 | + } | |
| 103 | + | |
| 104 | + public void setUserId(String userId) { | |
| 105 | + UserId = userId; | |
| 106 | + } | |
| 107 | + | |
| 108 | + public String getCustomerId() { | |
| 109 | + return CustomerId; | |
| 110 | + } | |
| 111 | + | |
| 112 | + public void setCustomerId(String customerId) { | |
| 113 | + CustomerId = customerId; | |
| 114 | + } | |
| 115 | + | |
| 116 | + public int getStudentType() { | |
| 117 | + return StudentType; | |
| 118 | + } | |
| 119 | + | |
| 120 | + public void setStudentType(int studentType) { | |
| 121 | + StudentType = studentType; | |
| 122 | + } | |
| 123 | + | |
| 124 | + public int getUserType() { | |
| 125 | + return UserType; | |
| 126 | + } | |
| 127 | + | |
| 128 | + public String getTeacher_id() { | |
| 129 | + return teacher_id; | |
| 130 | + } | |
| 131 | + | |
| 132 | + public String getParent_id() { | |
| 133 | + return parent_id; | |
| 134 | + } | |
| 135 | + | |
| 136 | + public void setParent_id(String parent_id) { | |
| 137 | + this.parent_id = parent_id; | |
| 138 | + } | |
| 139 | + | |
| 140 | + public void setTeacher_id(String teacher_id) { | |
| 141 | + this.teacher_id = teacher_id; | |
| 142 | + } | |
| 143 | + | |
| 144 | + public void setUserType(int userType) { | |
| 145 | + UserType = userType; | |
| 146 | + } | |
| 147 | + | |
| 148 | + public String getName() { | |
| 149 | + return name; | |
| 150 | + } | |
| 151 | + | |
| 152 | + public void setName(String name) { | |
| 153 | + this.name = name; | |
| 154 | + } | |
| 155 | + | |
| 156 | + public int getClassId() { | |
| 157 | + return ClassId; | |
| 158 | + } | |
| 159 | + | |
| 160 | + public void setClassId(int classId) { | |
| 161 | + ClassId = classId; | |
| 162 | + } | |
| 163 | + | |
| 164 | + public String getClassName() { | |
| 165 | + return ClassName; | |
| 166 | + } | |
| 167 | + | |
| 168 | + public void setClassName(String className) { | |
| 169 | + ClassName = className; | |
| 170 | + } | |
| 171 | + | |
| 172 | + public String getOldCard() { | |
| 173 | + return OldCard; | |
| 174 | + } | |
| 175 | + | |
| 176 | + public void setOldCard(String oldCard) { | |
| 177 | + OldCard = oldCard; | |
| 178 | + } | |
| 179 | + | |
| 180 | + public String getCard() { | |
| 181 | + return Card; | |
| 182 | + } | |
| 183 | + | |
| 184 | + public int getSchool_id() { | |
| 185 | + return school_id; | |
| 186 | + } | |
| 187 | + | |
| 188 | + public void setSchool_id(int school_id) { | |
| 189 | + this.school_id = school_id; | |
| 190 | + } | |
| 191 | + | |
| 192 | + public String getStudent_num() { | |
| 193 | + return student_num; | |
| 194 | + } | |
| 195 | + | |
| 196 | + public void setStudent_num(String student_num) { | |
| 197 | + this.student_num = student_num; | |
| 198 | + } | |
| 199 | + | |
| 200 | + public void setCard(String card) { | |
| 201 | + Card = card; | |
| 202 | + } | |
| 203 | + | |
| 204 | + public int getSchoolId() { | |
| 205 | + return SchoolId; | |
| 206 | + } | |
| 207 | + | |
| 208 | + public void setSchoolId(int schoolId) { | |
| 209 | + SchoolId = schoolId; | |
| 210 | + } | |
| 211 | + | |
| 212 | + public int getIsNew() { | |
| 213 | + return IsNew; | |
| 214 | + } | |
| 215 | + | |
| 216 | + public void setIsNew(int isNew) { | |
| 217 | + IsNew = isNew; | |
| 218 | + } | |
| 219 | + | |
| 220 | + public int getUpdateType() { | |
| 221 | + return UpdateType; | |
| 222 | + } | |
| 223 | + | |
| 224 | + public void setUpdateType(int updateType) { | |
| 225 | + UpdateType = updateType; | |
| 226 | + } | |
| 227 | + | |
| 228 | + public Date getAddTime() { | |
| 229 | + return AddTime; | |
| 230 | + } | |
| 231 | + | |
| 232 | + public void setAddTime(Date addTime) { | |
| 233 | + AddTime = addTime; | |
| 234 | + } | |
| 235 | + | |
| 236 | + public int getSex() { | |
| 237 | + return Sex; | |
| 238 | + } | |
| 239 | + | |
| 240 | + public void setSex(int sex) { | |
| 241 | + Sex = sex; | |
| 242 | + } | |
| 243 | + | |
| 244 | + public String getFace() { | |
| 245 | + return Face; | |
| 246 | + } | |
| 247 | + | |
| 248 | + public void setFace(String face) { | |
| 249 | + Face = face; | |
| 250 | + } | |
| 251 | + | |
| 252 | + public String getStudentCode() { | |
| 253 | + return studentcode; | |
| 254 | + } | |
| 255 | + | |
| 256 | + public void setStudentCode(String studentCode) { | |
| 257 | + this.studentcode = studentCode; | |
| 258 | + } | |
| 259 | + | |
| 260 | + public long getID() { | |
| 261 | + return ID; | |
| 262 | + } | |
| 263 | + | |
| 264 | + public void setID(long ID) { | |
| 265 | + this.ID = ID; | |
| 266 | + } | |
| 267 | + | |
| 268 | + public String getStudent_id() { | |
| 269 | + return student_id; | |
| 270 | + } | |
| 271 | + | |
| 272 | + public void setStudent_id(String student_id) { | |
| 273 | + this.student_id = student_id; | |
| 274 | + } | |
| 275 | + | |
| 276 | + @Override | |
| 277 | + public String toString() { | |
| 278 | + return "StudentBean{" + | |
| 279 | + "teacher_id='" + teacher_id + '\'' + | |
| 280 | + ", parent_id='" + parent_id + '\'' + | |
| 281 | + ", ID=" + ID + | |
| 282 | + ", UserId='" + UserId + '\'' + | |
| 283 | + ", CustomerId='" + CustomerId + '\'' + | |
| 284 | + ", StudentType=" + StudentType + | |
| 285 | + ", UserType=" + UserType + | |
| 286 | + ", name='" + name + '\'' + | |
| 287 | + ", ClassId=" + ClassId + | |
| 288 | + ", ClassName='" + ClassName + '\'' + | |
| 289 | + ", OldCard='" + OldCard + '\'' + | |
| 290 | + ", Card='" + Card + '\'' + | |
| 291 | + ", SchoolId=" + SchoolId + | |
| 292 | + ", school_id=" + school_id + | |
| 293 | + ", IsNew=" + IsNew + | |
| 294 | + ", UpdateType=" + UpdateType + | |
| 295 | + ", AddTime=" + AddTime + | |
| 296 | + ", Sex=" + Sex + | |
| 297 | + ", Face='" + Face + '\'' + | |
| 298 | + ", studentcode='" + studentcode + '\'' + | |
| 299 | + ", student_num='" + student_num + '\'' + | |
| 300 | + ", student_id='" + student_id + '\'' + | |
| 301 | + ", user_id='" + user_id + '\'' + | |
| 302 | + ", photo='" + photo + '\'' + | |
| 303 | + ", teacher_num='" + teacher_num + '\'' + | |
| 304 | + ", num='" + num + '\'' + | |
| 305 | + '}'; | |
| 306 | + } | |
| 307 | +} | ... | ... |
cloud/search_smartCampus/src/main/java/com/sincere/smartSearch/service/UserService.java
cloud/search_smartCampus/src/main/java/com/sincere/smartSearch/service/impl/UserServiceImpl.java
| ... | ... | @@ -20,4 +20,17 @@ public class UserServiceImpl implements UserService { |
| 20 | 20 | public String selectStudentNumByStudentId(int studentId) { |
| 21 | 21 | return userMapper.selectStudentNumByStudentId(studentId); |
| 22 | 22 | } |
| 23 | + | |
| 24 | + | |
| 25 | + @Override | |
| 26 | + public StudentBean getStudent_NumWitdCode(String studentcode) { | |
| 27 | + return userMapper.getStudent_NumWitdCode(studentcode); | |
| 28 | + } | |
| 29 | + | |
| 30 | + | |
| 31 | + @Override | |
| 32 | + public StudentBean getTeacherWithstudentcode(String num,String schoolId) { | |
| 33 | + return userMapper.getTeacherWithstudentcode(num,schoolId); | |
| 34 | + } | |
| 35 | + | |
| 23 | 36 | } | ... | ... |
cloud/server1/src/main/java/com/sincere/server1/FileUtils.java
0 → 100644
| ... | ... | @@ -0,0 +1,94 @@ |
| 1 | +package com.sincere.server1; | |
| 2 | + | |
| 3 | +import java.io.*; | |
| 4 | +import java.text.SimpleDateFormat; | |
| 5 | +import java.util.Date; | |
| 6 | + | |
| 7 | +/** | |
| 8 | + * 日志记录、文件操作工具类 | |
| 9 | + */ | |
| 10 | +public class FileUtils { | |
| 11 | + | |
| 12 | + | |
| 13 | + public static String checkFail = "检测失败.txt"; | |
| 14 | + public static String checkSuc = "检测成功.txt"; | |
| 15 | + public static String device_login="设备登录id.txt"; | |
| 16 | + private static FileUtils fileUtils; | |
| 17 | + | |
| 18 | + private String filePath = "./log/";//日志记录目录 | |
| 19 | + | |
| 20 | + public static String devices = "devices.txt";//设备记录 | |
| 21 | + | |
| 22 | + public static String sendUserErrTxt = "senduserErr.txt";//用户下发失败记录 | |
| 23 | + | |
| 24 | + public static String sendUserSucTxt = "senduserSuc.txt";//用户下发成功记录 | |
| 25 | + | |
| 26 | + public static String qiandaoSuccess = "qiandaoSuccess.txt";//用户签到成功记录 | |
| 27 | + | |
| 28 | + public static String qiandaoErr = "qiandaoErr.txt";//用户签到失败记录 | |
| 29 | + | |
| 30 | + public static String sendNodevice = "没有设备.txt";//设备没有 | |
| 31 | + | |
| 32 | + public static String sendOrder = "下发指令.txt";//学校id记录表 | |
| 33 | + | |
| 34 | + public static FileUtils getInstance() { | |
| 35 | + if (null == fileUtils) { | |
| 36 | + synchronized (FileUtils.class) { | |
| 37 | + fileUtils = new FileUtils(); | |
| 38 | + } | |
| 39 | + } | |
| 40 | + return fileUtils; | |
| 41 | + } | |
| 42 | + | |
| 43 | + | |
| 44 | + public FileUtils() { | |
| 45 | + | |
| 46 | + File filePa = new File(filePath); | |
| 47 | + if (!filePa.exists()) filePa.mkdirs(); | |
| 48 | + | |
| 49 | + } | |
| 50 | + | |
| 51 | + | |
| 52 | + /** | |
| 53 | + * @param content 日志内容 | |
| 54 | + * @param fileName 文件名字 | |
| 55 | + */ | |
| 56 | + public void writeLogs(String content, String fileName) { | |
| 57 | + | |
| 58 | + String date = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); | |
| 59 | + | |
| 60 | + File path = new File(filePath+date); | |
| 61 | + if (!path.exists())path.mkdirs(); | |
| 62 | + | |
| 63 | + File logPath = new File(filePath+date, fileName); | |
| 64 | + | |
| 65 | + try { | |
| 66 | +// System.out.println("logPath:" + logPath.getAbsolutePath()); | |
| 67 | + if (!logPath.exists()) logPath.createNewFile(); | |
| 68 | + | |
| 69 | + FileOutputStream fileOutputStream = new FileOutputStream(logPath, true);//true表示文件后面续写 | |
| 70 | + | |
| 71 | + String writeContent = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()) | |
| 72 | + + " " + content + "\r\n"; | |
| 73 | + | |
| 74 | + OutputStreamWriter outputStreamWriter = new OutputStreamWriter(fileOutputStream, "UTF-8"); | |
| 75 | + | |
| 76 | + outputStreamWriter.write(writeContent); | |
| 77 | + | |
| 78 | + outputStreamWriter.write("\r\n"); | |
| 79 | + | |
| 80 | + outputStreamWriter.close(); | |
| 81 | + | |
| 82 | + } catch (FileNotFoundException e) { | |
| 83 | + e.printStackTrace(); | |
| 84 | + } catch (UnsupportedEncodingException e) { | |
| 85 | + e.printStackTrace(); | |
| 86 | + } catch (IOException e) { | |
| 87 | + e.printStackTrace(); | |
| 88 | + } | |
| 89 | + | |
| 90 | + | |
| 91 | + } | |
| 92 | + | |
| 93 | + | |
| 94 | +} | ... | ... |
cloud/server1/src/main/java/com/sincere/server1/listener/EurekaInstanceCanceledListener.java
| ... | ... | @@ -4,6 +4,7 @@ package com.sincere.server1.listener; |
| 4 | 4 | import com.netflix.discovery.shared.Applications; |
| 5 | 5 | import com.netflix.eureka.EurekaServerContextHolder; |
| 6 | 6 | import com.netflix.eureka.registry.PeerAwareInstanceRegistry; |
| 7 | +import com.sincere.server1.FileUtils; | |
| 7 | 8 | import lombok.extern.slf4j.Slf4j; |
| 8 | 9 | import org.springframework.cloud.netflix.eureka.server.event.EurekaInstanceCanceledEvent; |
| 9 | 10 | import org.springframework.cloud.netflix.eureka.server.event.EurekaInstanceRegisteredEvent; |
| ... | ... | @@ -29,27 +30,43 @@ public class EurekaInstanceCanceledListener implements ApplicationListener { |
| 29 | 30 | PeerAwareInstanceRegistry registry = EurekaServerContextHolder.getInstance().getServerContext().getRegistry(); |
| 30 | 31 | Applications applications = registry.getApplications(); |
| 31 | 32 | // 遍历获取已注册节点中与当前失效节点ID一致的节点信息 |
| 32 | - applications.getRegisteredApplications().forEach((registeredApplication) -> { | |
| 33 | - registeredApplication.getInstances().forEach((instance) -> { | |
| 34 | - if (instance.getInstanceId().equals(event.getServerId())) { | |
| 35 | - log.debug("服务:" + instance.getAppName() + " 挂啦。。。"); | |
| 36 | - // // TODO: 2017/9/3 扩展消息提醒 邮件、手机短信、微信等 | |
| 37 | - } | |
| 38 | - }); | |
| 39 | - }); | |
| 33 | + if (null != applications && null != event) { | |
| 34 | + applications.getRegisteredApplications().forEach((registeredApplication) -> { | |
| 35 | + | |
| 36 | + registeredApplication.getInstances().forEach((instance) -> { | |
| 37 | + | |
| 38 | + if (null != instance && instance.getInstanceId().equals(event.getServerId())) { | |
| 39 | + System.out.println("服务:" + instance.getAppName() + " 挂啦。。。"); | |
| 40 | + // // TODO: 2017/9/3 扩展消息提醒 邮件、手机短信、微信等 | |
| 41 | + FileUtils.getInstance().writeLogs("服务:" + instance.getAppName() + " 挂啦。。。","服务监控"); | |
| 42 | + } | |
| 40 | 43 | |
| 44 | + }); | |
| 45 | + | |
| 46 | + }); | |
| 47 | + } | |
| 41 | 48 | |
| 42 | 49 | } |
| 50 | + | |
| 43 | 51 | if (applicationEvent instanceof EurekaInstanceRegisteredEvent) { |
| 44 | 52 | EurekaInstanceRegisteredEvent event = (EurekaInstanceRegisteredEvent) applicationEvent; |
| 45 | - log.debug("服务:" + event.getInstanceInfo().getAppName() + " 注册成功啦。。。"); | |
| 53 | + if (null!=event){ | |
| 54 | + System.out.println("服务:" + event.getInstanceInfo().getAppName() + " 注册成功啦。。。"); | |
| 55 | + FileUtils.getInstance().writeLogs("服务:" +event.getInstanceInfo().getAppName() + " 注册成功啦。。。","服务注册监控"); | |
| 56 | + }else System.out.println("服务EurekaInstanceRegisteredEvent"); | |
| 46 | 57 | } |
| 47 | 58 | if (applicationEvent instanceof EurekaInstanceRenewedEvent) { |
| 48 | 59 | EurekaInstanceRenewedEvent event = (EurekaInstanceRenewedEvent) applicationEvent; |
| 49 | - log.debug("心跳检测服务:" + event.getInstanceInfo().getAppName() + "。。"); | |
| 60 | + if (null!=event){ | |
| 61 | + System.out.println("心跳检测服务:" + event.getInstanceInfo().getAppName() + "。。"); | |
| 62 | + FileUtils.getInstance().writeLogs("心跳检测服务:" +event.getInstanceInfo().getAppName() + "。。","服务心跳监控"); | |
| 63 | + }else { | |
| 64 | + System.out.println("心跳检测服务EurekaInstanceRenewedEvent"); | |
| 65 | + } | |
| 50 | 66 | } |
| 51 | 67 | if (applicationEvent instanceof EurekaRegistryAvailableEvent) { |
| 52 | - log.debug("服务 Aualiable。。"); | |
| 68 | + System.out.println("服务 Aualiable。。"); | |
| 69 | + FileUtils.getInstance().writeLogs("服务 Aualiable。。","服务Aualiable"); | |
| 53 | 70 | } |
| 54 | 71 | |
| 55 | 72 | } | ... | ... |
cloud/server2/src/main/java/com/sincere/server2/FileUtils.java
0 → 100644
| ... | ... | @@ -0,0 +1,94 @@ |
| 1 | +package com.sincere.server2; | |
| 2 | + | |
| 3 | +import java.io.*; | |
| 4 | +import java.text.SimpleDateFormat; | |
| 5 | +import java.util.Date; | |
| 6 | + | |
| 7 | +/** | |
| 8 | + * 日志记录、文件操作工具类 | |
| 9 | + */ | |
| 10 | +public class FileUtils { | |
| 11 | + | |
| 12 | + | |
| 13 | + public static String checkFail = "检测失败.txt"; | |
| 14 | + public static String checkSuc = "检测成功.txt"; | |
| 15 | + public static String device_login="设备登录id.txt"; | |
| 16 | + private static FileUtils fileUtils; | |
| 17 | + | |
| 18 | + private String filePath = "./log/";//日志记录目录 | |
| 19 | + | |
| 20 | + public static String devices = "devices.txt";//设备记录 | |
| 21 | + | |
| 22 | + public static String sendUserErrTxt = "senduserErr.txt";//用户下发失败记录 | |
| 23 | + | |
| 24 | + public static String sendUserSucTxt = "senduserSuc.txt";//用户下发成功记录 | |
| 25 | + | |
| 26 | + public static String qiandaoSuccess = "qiandaoSuccess.txt";//用户签到成功记录 | |
| 27 | + | |
| 28 | + public static String qiandaoErr = "qiandaoErr.txt";//用户签到失败记录 | |
| 29 | + | |
| 30 | + public static String sendNodevice = "没有设备.txt";//设备没有 | |
| 31 | + | |
| 32 | + public static String sendOrder = "下发指令.txt";//学校id记录表 | |
| 33 | + | |
| 34 | + public static FileUtils getInstance() { | |
| 35 | + if (null == fileUtils) { | |
| 36 | + synchronized (FileUtils.class) { | |
| 37 | + fileUtils = new FileUtils(); | |
| 38 | + } | |
| 39 | + } | |
| 40 | + return fileUtils; | |
| 41 | + } | |
| 42 | + | |
| 43 | + | |
| 44 | + public FileUtils() { | |
| 45 | + | |
| 46 | + File filePa = new File(filePath); | |
| 47 | + if (!filePa.exists()) filePa.mkdirs(); | |
| 48 | + | |
| 49 | + } | |
| 50 | + | |
| 51 | + | |
| 52 | + /** | |
| 53 | + * @param content 日志内容 | |
| 54 | + * @param fileName 文件名字 | |
| 55 | + */ | |
| 56 | + public void writeLogs(String content, String fileName) { | |
| 57 | + | |
| 58 | + String date = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); | |
| 59 | + | |
| 60 | + File path = new File(filePath+date); | |
| 61 | + if (!path.exists())path.mkdirs(); | |
| 62 | + | |
| 63 | + File logPath = new File(filePath+date, fileName); | |
| 64 | + | |
| 65 | + try { | |
| 66 | +// System.out.println("logPath:" + logPath.getAbsolutePath()); | |
| 67 | + if (!logPath.exists()) logPath.createNewFile(); | |
| 68 | + | |
| 69 | + FileOutputStream fileOutputStream = new FileOutputStream(logPath, true);//true表示文件后面续写 | |
| 70 | + | |
| 71 | + String writeContent = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()) | |
| 72 | + + " " + content + "\r\n"; | |
| 73 | + | |
| 74 | + OutputStreamWriter outputStreamWriter = new OutputStreamWriter(fileOutputStream, "UTF-8"); | |
| 75 | + | |
| 76 | + outputStreamWriter.write(writeContent); | |
| 77 | + | |
| 78 | + outputStreamWriter.write("\r\n"); | |
| 79 | + | |
| 80 | + outputStreamWriter.close(); | |
| 81 | + | |
| 82 | + } catch (FileNotFoundException e) { | |
| 83 | + e.printStackTrace(); | |
| 84 | + } catch (UnsupportedEncodingException e) { | |
| 85 | + e.printStackTrace(); | |
| 86 | + } catch (IOException e) { | |
| 87 | + e.printStackTrace(); | |
| 88 | + } | |
| 89 | + | |
| 90 | + | |
| 91 | + } | |
| 92 | + | |
| 93 | + | |
| 94 | +} | ... | ... |
cloud/server2/src/main/java/com/sincere/server2/listener/EurekaInstanceCanceledListener.java
| ... | ... | @@ -4,6 +4,7 @@ package com.sincere.server2.listener; |
| 4 | 4 | import com.netflix.discovery.shared.Applications; |
| 5 | 5 | import com.netflix.eureka.EurekaServerContextHolder; |
| 6 | 6 | import com.netflix.eureka.registry.PeerAwareInstanceRegistry; |
| 7 | +import com.sincere.server2.FileUtils; | |
| 7 | 8 | import lombok.extern.slf4j.Slf4j; |
| 8 | 9 | import org.springframework.cloud.netflix.eureka.server.event.EurekaInstanceCanceledEvent; |
| 9 | 10 | import org.springframework.cloud.netflix.eureka.server.event.EurekaInstanceRegisteredEvent; |
| ... | ... | @@ -29,27 +30,43 @@ public class EurekaInstanceCanceledListener implements ApplicationListener { |
| 29 | 30 | PeerAwareInstanceRegistry registry = EurekaServerContextHolder.getInstance().getServerContext().getRegistry(); |
| 30 | 31 | Applications applications = registry.getApplications(); |
| 31 | 32 | // 遍历获取已注册节点中与当前失效节点ID一致的节点信息 |
| 32 | - applications.getRegisteredApplications().forEach((registeredApplication) -> { | |
| 33 | - registeredApplication.getInstances().forEach((instance) -> { | |
| 34 | - if (instance.getInstanceId().equals(event.getServerId())) { | |
| 35 | - log.debug("服务:" + instance.getAppName() + " 挂啦。。。"); | |
| 36 | - // // TODO: 2017/9/3 扩展消息提醒 邮件、手机短信、微信等 | |
| 37 | - } | |
| 38 | - }); | |
| 39 | - }); | |
| 33 | + if (null != applications && null != event) { | |
| 34 | + applications.getRegisteredApplications().forEach((registeredApplication) -> { | |
| 35 | + | |
| 36 | + registeredApplication.getInstances().forEach((instance) -> { | |
| 37 | + | |
| 38 | + if (null != instance && instance.getInstanceId().equals(event.getServerId())) { | |
| 39 | + System.out.println("服务:" + instance.getAppName() + " 挂啦。。。"); | |
| 40 | + // // TODO: 2017/9/3 扩展消息提醒 邮件、手机短信、微信等 | |
| 41 | + FileUtils.getInstance().writeLogs("服务:" + instance.getAppName() + " 挂啦。。。","服务监控"); | |
| 42 | + } | |
| 40 | 43 | |
| 44 | + }); | |
| 45 | + | |
| 46 | + }); | |
| 47 | + } | |
| 41 | 48 | |
| 42 | 49 | } |
| 50 | + | |
| 43 | 51 | if (applicationEvent instanceof EurekaInstanceRegisteredEvent) { |
| 44 | 52 | EurekaInstanceRegisteredEvent event = (EurekaInstanceRegisteredEvent) applicationEvent; |
| 45 | - log.debug("服务:" + event.getInstanceInfo().getAppName() + " 注册成功啦。。。"); | |
| 53 | + if (null!=event){ | |
| 54 | + System.out.println("服务:" + event.getInstanceInfo().getAppName() + " 注册成功啦。。。"); | |
| 55 | + FileUtils.getInstance().writeLogs("服务:" +event.getInstanceInfo().getAppName() + " 注册成功啦。。。","服务注册监控"); | |
| 56 | + }else System.out.println("服务EurekaInstanceRegisteredEvent"); | |
| 46 | 57 | } |
| 47 | 58 | if (applicationEvent instanceof EurekaInstanceRenewedEvent) { |
| 48 | 59 | EurekaInstanceRenewedEvent event = (EurekaInstanceRenewedEvent) applicationEvent; |
| 49 | - log.debug("心跳检测服务:" + event.getInstanceInfo().getAppName() + "。。"); | |
| 60 | + if (null!=event){ | |
| 61 | + System.out.println("心跳检测服务:" + event.getInstanceInfo().getAppName() + "。。"); | |
| 62 | + FileUtils.getInstance().writeLogs("心跳检测服务:" +event.getInstanceInfo().getAppName() + "。。","服务心跳监控"); | |
| 63 | + }else { | |
| 64 | + System.out.println("心跳检测服务EurekaInstanceRenewedEvent"); | |
| 65 | + } | |
| 50 | 66 | } |
| 51 | 67 | if (applicationEvent instanceof EurekaRegistryAvailableEvent) { |
| 52 | - log.debug("服务 Aualiable。。"); | |
| 68 | + System.out.println("服务 Aualiable。。"); | |
| 69 | + FileUtils.getInstance().writeLogs("服务 Aualiable。。","服务Aualiable"); | |
| 53 | 70 | } |
| 54 | 71 | |
| 55 | 72 | } | ... | ... |