Commit 40e7c30e25ba578b20fc94e19d01e49739909955
1 parent
5a926884
Exists in
master
增加负载均衡客户端服务
Showing
35 changed files
with
982 additions
and
55 deletions
Show diff stats
@@ -0,0 +1,40 @@ | @@ -0,0 +1,40 @@ | ||
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
3 | + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
4 | + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
5 | + <parent> | ||
6 | + <artifactId>cloud</artifactId> | ||
7 | + <groupId>com.sincere</groupId> | ||
8 | + <version>1.0.0</version> | ||
9 | + </parent> | ||
10 | + <modelVersion>4.0.0</modelVersion> | ||
11 | + | ||
12 | + <artifactId>RibbonConsume</artifactId> | ||
13 | + | ||
14 | + <properties> | ||
15 | + <ribbon>2.1.3.RELEASE</ribbon> | ||
16 | + </properties> | ||
17 | + | ||
18 | + <dependencies> | ||
19 | + | ||
20 | + <dependency> | ||
21 | + <groupId>org.springframework.cloud</groupId> | ||
22 | + <artifactId>spring-cloud-starter-netflix-ribbon</artifactId> | ||
23 | + <version>${ribbon}</version> | ||
24 | + </dependency> | ||
25 | + | ||
26 | + <dependency> | ||
27 | + <groupId>org.springframework.boot</groupId> | ||
28 | + <artifactId>spring-boot-starter-web</artifactId> | ||
29 | + </dependency> | ||
30 | + | ||
31 | + </dependencies> | ||
32 | + | ||
33 | + <build> | ||
34 | + | ||
35 | + | ||
36 | + <finalName>RibbonConsume</finalName> | ||
37 | + | ||
38 | + </build> | ||
39 | + | ||
40 | +</project> | ||
0 | \ No newline at end of file | 41 | \ No newline at end of file |
cloud/RibbonConsume/src/main/java/com/sincere/ribbon/RibbonApplication.java
0 → 100644
@@ -0,0 +1,27 @@ | @@ -0,0 +1,27 @@ | ||
1 | +package com.sincere.ribbon; | ||
2 | + | ||
3 | +import org.springframework.boot.SpringApplication; | ||
4 | +import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
5 | +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; | ||
6 | +import org.springframework.cloud.client.loadbalancer.LoadBalanced; | ||
7 | +import org.springframework.context.annotation.Bean; | ||
8 | +import org.springframework.web.client.RestTemplate; | ||
9 | + | ||
10 | +@SpringBootApplication | ||
11 | +@EnableDiscoveryClient | ||
12 | +public class RibbonApplication { | ||
13 | + | ||
14 | + | ||
15 | + @Bean | ||
16 | + @LoadBalanced | ||
17 | + RestTemplate restTemplate(){ | ||
18 | + return new RestTemplate(); | ||
19 | + } | ||
20 | + | ||
21 | + public static void main(String[] args) { | ||
22 | + SpringApplication.run(RibbonApplication.class,args); | ||
23 | + } | ||
24 | + | ||
25 | + | ||
26 | + | ||
27 | +} |
cloud/RibbonConsume/src/main/java/com/sincere/ribbon/control/FileRibbonControl.java
0 → 100644
@@ -0,0 +1,53 @@ | @@ -0,0 +1,53 @@ | ||
1 | +package com.sincere.ribbon.control; | ||
2 | + | ||
3 | +import org.slf4j.Logger; | ||
4 | +import org.slf4j.LoggerFactory; | ||
5 | +import org.springframework.beans.factory.annotation.Autowired; | ||
6 | +import org.springframework.http.HttpEntity; | ||
7 | +import org.springframework.http.HttpHeaders; | ||
8 | +import org.springframework.http.HttpMethod; | ||
9 | +import org.springframework.http.ResponseEntity; | ||
10 | +import org.springframework.web.bind.annotation.*; | ||
11 | +import org.springframework.web.client.RestTemplate; | ||
12 | + | ||
13 | +import javax.servlet.http.HttpServletRequest; | ||
14 | +import java.util.Enumeration; | ||
15 | +import java.util.HashMap; | ||
16 | +import java.util.Map; | ||
17 | + | ||
18 | +@RestController | ||
19 | +@RequestMapping("/file/*") | ||
20 | +public class FileRibbonControl { | ||
21 | + | ||
22 | + Logger logger = LoggerFactory.getLogger(FileRibbonControl.class); | ||
23 | + | ||
24 | + @Autowired | ||
25 | + RestTemplate restTemplate; | ||
26 | + | ||
27 | + @RequestMapping(value = "deleteFile/{fileName}", method = RequestMethod.GET) | ||
28 | + public boolean deleteFile(@PathVariable String fileName, HttpServletRequest req) { | ||
29 | + | ||
30 | + HttpServletRequest request = req; | ||
31 | + //获取header信息 | ||
32 | + HttpHeaders requestHeaders = new HttpHeaders(); | ||
33 | +// Enumeration<String> headerNames = request.getHeaderNames(); | ||
34 | +// while (headerNames.hasMoreElements()) { | ||
35 | +// String key = (String) headerNames.nextElement(); | ||
36 | +// String value = request.getHeader(key); | ||
37 | +// requestHeaders.add(key, value); | ||
38 | +// } | ||
39 | + requestHeaders.add("ossPath","ceshi"); | ||
40 | + Map<String, String[]> params = new HashMap<>(); | ||
41 | + //获取parameter信息 | ||
42 | + if (params == null) { | ||
43 | + params = request.getParameterMap(); | ||
44 | + } | ||
45 | + | ||
46 | + HttpEntity<String> requestEntity = new HttpEntity<String>(null, requestHeaders); | ||
47 | + ResponseEntity<String> rss = restTemplate.exchange("http://file-center/file/deleteFile/"+fileName, HttpMethod.DELETE, requestEntity, String.class, params); | ||
48 | + logger.error("删除文件:" + rss.getStatusCodeValue()); | ||
49 | + return true; | ||
50 | + | ||
51 | + } | ||
52 | + | ||
53 | +} |
cloud/RibbonConsume/src/main/java/com/sincere/ribbon/control/RibbonConsumeControl.java
0 → 100644
@@ -0,0 +1,60 @@ | @@ -0,0 +1,60 @@ | ||
1 | +package com.sincere.ribbon.control; | ||
2 | + | ||
3 | +import com.sincere.ribbon.model.Login; | ||
4 | +import org.slf4j.Logger; | ||
5 | +import org.slf4j.LoggerFactory; | ||
6 | +import org.springframework.beans.factory.annotation.Autowired; | ||
7 | +import org.springframework.cloud.client.ServiceInstance; | ||
8 | +import org.springframework.cloud.client.discovery.DiscoveryClient; | ||
9 | +import org.springframework.http.HttpEntity; | ||
10 | +import org.springframework.http.HttpHeaders; | ||
11 | +import org.springframework.http.MediaType; | ||
12 | +import org.springframework.util.LinkedMultiValueMap; | ||
13 | +import org.springframework.util.MultiValueMap; | ||
14 | +import org.springframework.web.bind.annotation.*; | ||
15 | +import org.springframework.web.client.RestTemplate; | ||
16 | + | ||
17 | +import java.util.HashMap; | ||
18 | +import java.util.List; | ||
19 | +import java.util.Map; | ||
20 | + | ||
21 | +@RestController | ||
22 | +@RequestMapping(value = "/ribbon/*") | ||
23 | +public class RibbonConsumeControl { | ||
24 | + private static final Logger LOG = LoggerFactory.getLogger(RibbonConsumeControl.class); | ||
25 | + | ||
26 | + @Autowired | ||
27 | + RestTemplate restTemplate; | ||
28 | + | ||
29 | + @Autowired | ||
30 | + private DiscoveryClient discoveryClient; | ||
31 | + | ||
32 | + @RequestMapping(value = "login",method = RequestMethod.GET ) | ||
33 | + public String login(@RequestParam("account")String account,@RequestParam("password")String password,@RequestParam("userType")String userType){ | ||
34 | + LOG.error("登录中:"+account+password+userType); | ||
35 | + HttpHeaders headers = new HttpHeaders(); | ||
36 | + | ||
37 | + Login login = new Login(); | ||
38 | + login.setAccount(account); | ||
39 | + login.setPassword(password); | ||
40 | + login.setUserType(userType); | ||
41 | + | ||
42 | + String result = restTemplate.postForEntity("http://authserver/login",login,String.class).getBody(); | ||
43 | + LOG.error("登录结果:"+result); | ||
44 | + return result; | ||
45 | + | ||
46 | + } | ||
47 | + | ||
48 | + @GetMapping("serviceurl") | ||
49 | + public Map<String, List<ServiceInstance>> serviceUrl() { | ||
50 | + Map<String, List<ServiceInstance>> msl = new HashMap<>(); | ||
51 | + List<String> services = discoveryClient.getServices(); | ||
52 | + for (String service : services) { | ||
53 | + List<ServiceInstance> sis = discoveryClient.getInstances(service); | ||
54 | + msl.put(service, sis); | ||
55 | + } | ||
56 | + return msl; | ||
57 | + } | ||
58 | + | ||
59 | + | ||
60 | +} |
cloud/RibbonConsume/src/main/java/com/sincere/ribbon/model/Login.java
0 → 100644
@@ -0,0 +1,44 @@ | @@ -0,0 +1,44 @@ | ||
1 | +package com.sincere.ribbon.model; | ||
2 | + | ||
3 | +public class Login { | ||
4 | + | ||
5 | + private String account; | ||
6 | + | ||
7 | + private String password; | ||
8 | + | ||
9 | + private String userType; | ||
10 | + | ||
11 | + public String getAccount() { | ||
12 | + return account; | ||
13 | + } | ||
14 | + | ||
15 | + public void setAccount(String account) { | ||
16 | + this.account = account; | ||
17 | + } | ||
18 | + | ||
19 | + public String getPassword() { | ||
20 | + return password; | ||
21 | + } | ||
22 | + | ||
23 | + public void setPassword(String password) { | ||
24 | + this.password = password; | ||
25 | + } | ||
26 | + | ||
27 | + public String getUserType() { | ||
28 | + return userType; | ||
29 | + } | ||
30 | + | ||
31 | + public void setUserType(String userType) { | ||
32 | + this.userType = userType; | ||
33 | + } | ||
34 | + | ||
35 | + @Override | ||
36 | + public String toString() { | ||
37 | + return "Login{" + | ||
38 | + "account='" + account + '\'' + | ||
39 | + ", password='" + password + '\'' + | ||
40 | + ", userType='" + userType + '\'' + | ||
41 | + '}'; | ||
42 | + } | ||
43 | +} | ||
44 | + |
@@ -0,0 +1,30 @@ | @@ -0,0 +1,30 @@ | ||
1 | +#端口 | ||
2 | +server: | ||
3 | + port: 8091 #固定端口 | ||
4 | +# port: ${randomServerPort.value[5000,5005]} #随机端口 | ||
5 | + | ||
6 | +#服务名称 | ||
7 | +spring: | ||
8 | + application: | ||
9 | + name: ribbon-consume | ||
10 | + | ||
11 | +#eureka client配置 | ||
12 | +eureka: | ||
13 | + client: | ||
14 | + serviceUrl: | ||
15 | +# 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 | + #http://134.224.249.33:1111/eureka/ 正式库 | ||
18 | + #http://134.224.249.33:1111/eureka/ 测试库 | ||
19 | + #http://127.0.0.1:8761/eureka,http://127.0.0.1:8762/eureka | ||
20 | + registry-fetch-interval-seconds: 5 | ||
21 | + instance-info-replication-interval-seconds: 10 | ||
22 | + instance: | ||
23 | +# prefer-ip-address: true | ||
24 | + instance-id: ${spring.application.name} | ||
25 | +# instance-id: ${spring.application.name}:${spring.cloud.client.ip-address}:${spring.application.instance_id:${server.port}} #固定端口 | ||
26 | +# instance-id: ${spring.application.name}:${spring.cloud.client.ip-address}:${spring.application.instance_id:${randomServerPort.value[5000,5005]}} #随机端口 | ||
27 | + lease-renewal-interval-in-seconds: 10 #每隔几秒告诉eureka服务器我还存活,用于心跳检测 | ||
28 | + lease-expiration-duration-in-seconds: 10 #如果心跳检测一直没有发送,10秒后会从eureka服务器中将此服务剔除 | ||
29 | + status-page-url: http://${spring.cloud.client.ip-address}:${server.port}/doc.html # ${server.port}为该服务的端口号 | ||
30 | +# status-page-url: http://${spring.cloud.client.ip-address}:${randomServerPort.value[5000,5005]}/document.html # ${server.port}为该服务的端口号 | ||
0 | \ No newline at end of file | 31 | \ No newline at end of file |
cloud/autho/src/main/java/com/sincere/autho/control/LoginController.java
@@ -21,6 +21,7 @@ public class LoginController { | @@ -21,6 +21,7 @@ public class LoginController { | ||
21 | 21 | ||
22 | @RequestMapping(value = "/login" , method = RequestMethod.POST) | 22 | @RequestMapping(value = "/login" , method = RequestMethod.POST) |
23 | public BaseDto<String> login(@RequestBody LoginReqDto loginReqDto){ | 23 | public BaseDto<String> login(@RequestBody LoginReqDto loginReqDto){ |
24 | + System.out.println("登录接口"); | ||
24 | BaseDto<String> result = new BaseDto<>() ; | 25 | BaseDto<String> result = new BaseDto<>() ; |
25 | String userId = loginService.login(loginReqDto); | 26 | String userId = loginService.login(loginReqDto); |
26 | if(StringUtils.isNotBlank(userId)){ | 27 | if(StringUtils.isNotBlank(userId)){ |
cloud/autho/src/main/resources/application.yaml
@@ -25,4 +25,5 @@ eureka: | @@ -25,4 +25,5 @@ eureka: | ||
25 | client: | 25 | client: |
26 | service-url: | 26 | service-url: |
27 | defaultZone: http://121.40.109.21:8761/eureka/,http://121.40.109.21:8762/eureka/ | 27 | defaultZone: http://121.40.109.21:8761/eureka/,http://121.40.109.21:8762/eureka/ |
28 | +# defaultZone: http://localhost:8761/eureka/,http://localhost:8762/eureka/ | ||
28 | 29 |
cloud/fIle-center/pom.xml
@@ -58,6 +58,17 @@ | @@ -58,6 +58,17 @@ | ||
58 | </goals> | 58 | </goals> |
59 | </execution> | 59 | </execution> |
60 | </executions> | 60 | </executions> |
61 | + <configuration> | ||
62 | + <includeSystemScope>true</includeSystemScope> | ||
63 | + <layout>ZIP</layout> | ||
64 | + <includes> | ||
65 | + <include> | ||
66 | + <!-- 排除所有Jar --> | ||
67 | + <groupId>nothing</groupId> | ||
68 | + <artifactId>nothing</artifactId> | ||
69 | + </include> | ||
70 | + </includes> | ||
71 | + </configuration> | ||
61 | </plugin> | 72 | </plugin> |
62 | 73 | ||
63 | </plugins> | 74 | </plugins> |
cloud/fIle-center/src/main/java/com/sincere/file/control/FileControl.java
@@ -37,6 +37,9 @@ public class FileControl { | @@ -37,6 +37,9 @@ public class FileControl { | ||
37 | public boolean deleteFile(@PathVariable String fileName,HttpServletRequest request){ | 37 | public boolean deleteFile(@PathVariable String fileName,HttpServletRequest request){ |
38 | String ossPath = request.getHeader("ossPath");//oss的二级目录 | 38 | String ossPath = request.getHeader("ossPath");//oss的二级目录 |
39 | fileService.delete(fileName,ossPath); | 39 | fileService.delete(fileName,ossPath); |
40 | + | ||
41 | + System.out.println("fileName:"+fileName+"----ossPath:"+ossPath); | ||
42 | + | ||
40 | return true; | 43 | return true; |
41 | } | 44 | } |
42 | } | 45 | } |
cloud/fIle-center/src/main/resources/bootstrap.yml
@@ -33,11 +33,12 @@ eureka: | @@ -33,11 +33,12 @@ eureka: | ||
33 | registry-fetch-interval-seconds: 5 | 33 | registry-fetch-interval-seconds: 5 |
34 | instance-info-replication-interval-seconds: 10 | 34 | instance-info-replication-interval-seconds: 10 |
35 | instance: | 35 | instance: |
36 | - prefer-ip-address: true | 36 | +# prefer-ip-address: false |
37 | instance-id: ${spring.application.name} | 37 | instance-id: ${spring.application.name} |
38 | # instance-id: ${spring.application.name}:${spring.cloud.client.ip-address}:${spring.application.instance_id:${server.port}} #固定端口 | 38 | # instance-id: ${spring.application.name}:${spring.cloud.client.ip-address}:${spring.application.instance_id:${server.port}} #固定端口 |
39 | # instance-id: ${spring.application.name}:${spring.cloud.client.ip-address}:${spring.application.instance_id:${randomServerPort.value[5000,5005]}} #随机端口 | 39 | # instance-id: ${spring.application.name}:${spring.cloud.client.ip-address}:${spring.application.instance_id:${randomServerPort.value[5000,5005]}} #随机端口 |
40 | lease-renewal-interval-in-seconds: 10 #每隔几秒告诉eureka服务器我还存活,用于心跳检测 | 40 | lease-renewal-interval-in-seconds: 10 #每隔几秒告诉eureka服务器我还存活,用于心跳检测 |
41 | lease-expiration-duration-in-seconds: 10 #如果心跳检测一直没有发送,10秒后会从eureka服务器中将此服务剔除 | 41 | lease-expiration-duration-in-seconds: 10 #如果心跳检测一直没有发送,10秒后会从eureka服务器中将此服务剔除 |
42 | - status-page-url: http://${spring.cloud.client.ip-address}:${server.port}/doc.html # ${server.port}为该服务的端口号 | ||
43 | -# status-page-url: http://${spring.cloud.client.ip-address}:${randomServerPort.value[5000,5005]}/document.html # ${server.port}为该服务的端口号 | ||
44 | \ No newline at end of file | 42 | \ No newline at end of file |
43 | +# status-page-url: http://${spring.cloud.client.ip-address}:${server.port}/doc.html # ${server.port}为该服务的端口号 | ||
44 | + hostname: 121.40.30.78 | ||
45 | +# status-page-url: http://${spring.cloud.client.ip-address}:${randomServerPort.value[5000,5005]}/document.html # ${server.port}为该服务的端口号 | ||
45 | \ No newline at end of file | 46 | \ No newline at end of file |
cloud/getaway/pom.xml
@@ -58,6 +58,17 @@ | @@ -58,6 +58,17 @@ | ||
58 | </goals> | 58 | </goals> |
59 | </execution> | 59 | </execution> |
60 | </executions> | 60 | </executions> |
61 | + <configuration> | ||
62 | + <includeSystemScope>true</includeSystemScope> | ||
63 | + <layout>ZIP</layout> | ||
64 | + <includes> | ||
65 | + <include> | ||
66 | + <!-- 排除所有Jar --> | ||
67 | + <groupId>nothing</groupId> | ||
68 | + <artifactId>nothing</artifactId> | ||
69 | + </include> | ||
70 | + </includes> | ||
71 | + </configuration> | ||
61 | </plugin> | 72 | </plugin> |
62 | </plugins> | 73 | </plugins> |
63 | <finalName>${project.artifactId}</finalName> | 74 | <finalName>${project.artifactId}</finalName> |
cloud/getaway/src/main/java/com/sincere/getaway/client/config/CorsConfig.java
@@ -17,6 +17,7 @@ | @@ -17,6 +17,7 @@ | ||
17 | //import org.springframework.web.server.ServerWebExchange; | 17 | //import org.springframework.web.server.ServerWebExchange; |
18 | //import org.springframework.web.server.WebFilter; | 18 | //import org.springframework.web.server.WebFilter; |
19 | //import org.springframework.web.server.WebFilterChain; | 19 | //import org.springframework.web.server.WebFilterChain; |
20 | +// | ||
20 | //import reactor.core.publisher.Mono; | 21 | //import reactor.core.publisher.Mono; |
21 | // | 22 | // |
22 | ///** | 23 | ///** |
@@ -37,7 +38,7 @@ | @@ -37,7 +38,7 @@ | ||
37 | // | 38 | // |
38 | // @Bean | 39 | // @Bean |
39 | // public RouteDefinitionLocator discoveryClientRouteDefinitionLocator(DiscoveryClient discoveryClient, | 40 | // public RouteDefinitionLocator discoveryClientRouteDefinitionLocator(DiscoveryClient discoveryClient, |
40 | -// DiscoveryLocatorProperties properties) { | 41 | +// DiscoveryLocatorProperties properties) { |
41 | // return new DiscoveryClientRouteDefinitionLocator(discoveryClient, properties); | 42 | // return new DiscoveryClientRouteDefinitionLocator(discoveryClient, properties); |
42 | // } | 43 | // } |
43 | // | 44 | // |
cloud/getaway/src/main/resources/application.yml
@@ -43,12 +43,19 @@ spring: | @@ -43,12 +43,19 @@ spring: | ||
43 | - StripPrefix=1 | 43 | - StripPrefix=1 |
44 | - id: authserver | 44 | - id: authserver |
45 | uri: http://121.40.30.78:9005 | 45 | uri: http://121.40.30.78:9005 |
46 | +# uri: lb://authserver | ||
46 | predicates: | 47 | predicates: |
47 | - Path=/authserver/** | 48 | - Path=/authserver/** |
48 | filters: | 49 | filters: |
49 | - StripPrefix=1 | 50 | - StripPrefix=1 |
50 | - default-filters: | ||
51 | - - DedupeResponseHeader=Access-Control-Allow-Origin, RETAIN_UNIQUE | 51 | + - id: NewSmartCampus |
52 | + uri: http://114.55.30.100:1111 | ||
53 | + predicates: | ||
54 | + - Path=/NewSmartCampus/** | ||
55 | + filters: | ||
56 | + - StripPrefix=1 | ||
57 | +# default-filters: | ||
58 | +# - DedupeResponseHeader=Access-Control-Allow-Origin, RETAIN_UNIQUE | ||
52 | # discovery: | 59 | # discovery: |
53 | # locator: | 60 | # locator: |
54 | # lowerCaseServiceId: true | 61 | # lowerCaseServiceId: true |
@@ -70,4 +77,4 @@ ribbon: | @@ -70,4 +77,4 @@ ribbon: | ||
70 | 77 | ||
71 | 78 | ||
72 | url: | 79 | url: |
73 | - ignored: /SmartCampusWebApi/**,/authserver/** | ||
74 | \ No newline at end of file | 80 | \ No newline at end of file |
81 | + ignored: /SmartCampusWebApi/**,/authserver/**,/NewSmartCampus/** | ||
75 | \ No newline at end of file | 82 | \ No newline at end of file |
cloud/haikangface/pom.xml
@@ -97,11 +97,11 @@ | @@ -97,11 +97,11 @@ | ||
97 | <scope>compile</scope> | 97 | <scope>compile</scope> |
98 | </dependency> | 98 | </dependency> |
99 | 99 | ||
100 | - <!--<dependency>--> | ||
101 | - <!--<groupId>com.baidu.aip</groupId>--> | ||
102 | - <!--<artifactId>java-sdk</artifactId>--> | ||
103 | - <!--<version>4.10.0</version>--> | ||
104 | - <!--</dependency>--> | 100 | + <dependency> |
101 | + <groupId>com.baidu.aip</groupId> | ||
102 | + <artifactId>java-sdk</artifactId> | ||
103 | + <version>4.10.0</version> | ||
104 | + </dependency> | ||
105 | <dependency> | 105 | <dependency> |
106 | <groupId>com.sun.image.jce</groupId> | 106 | <groupId>com.sun.image.jce</groupId> |
107 | <artifactId>jce</artifactId> | 107 | <artifactId>jce</artifactId> |
cloud/haikangface/src/main/java/com/sincere/haikangface/CMSServer.java
@@ -326,7 +326,7 @@ public class CMSServer implements ApplicationRunner { | @@ -326,7 +326,7 @@ public class CMSServer implements ApplicationRunner { | ||
326 | pFilePath.write(0, strFilePath.getBytes(), 0, strFilePath.getBytes().length); | 326 | pFilePath.write(0, strFilePath.getBytes(), 0, strFilePath.getBytes().length); |
327 | 327 | ||
328 | if (isZhuaPai) { | 328 | if (isZhuaPai) { |
329 | - MqtUtils.getInstance().sendMsg("http://campus.myjxt.com//face17e5/School16/Student/" + pFileName); | 329 | +// MqtUtils.getInstance().sendMsg("http://campus.myjxt.com//face17e5/School16/Student/" + pFileName); |
330 | } | 330 | } |
331 | 331 | ||
332 | return true; | 332 | return true; |
@@ -509,7 +509,7 @@ public class CMSServer implements ApplicationRunner { | @@ -509,7 +509,7 @@ public class CMSServer implements ApplicationRunner { | ||
509 | int err = hCEhomeSS.NET_ESS_GetLastError(); | 509 | int err = hCEhomeSS.NET_ESS_GetLastError(); |
510 | System.out.println("NET_ESS_ClientDoUpload失败,错误号:" + err); | 510 | System.out.println("NET_ESS_ClientDoUpload失败,错误号:" + err); |
511 | } else { | 511 | } else { |
512 | - url = "http://" + ip + ":" + 8081 + new String(szUrl).trim(); | 512 | + url = "http://120.26.116.253:" + 8081 + new String(szUrl).trim(); |
513 | // System.err.println("NET_ESS_ClientDoUpload成功!:" + url); | 513 | // System.err.println("NET_ESS_ClientDoUpload成功!:" + url); |
514 | } | 514 | } |
515 | hCEhomeSS.NET_ESS_DestroyClient(client);//释放资源 | 515 | hCEhomeSS.NET_ESS_DestroyClient(client);//释放资源 |
cloud/haikangface/src/main/java/com/sincere/haikangface/admindao/ZuoyeAdminDao.java
@@ -11,13 +11,13 @@ import java.util.List; | @@ -11,13 +11,13 @@ import java.util.List; | ||
11 | public interface ZuoyeAdminDao { | 11 | public interface ZuoyeAdminDao { |
12 | 12 | ||
13 | 13 | ||
14 | - @Select("select Id from ZY_YYChapter where Name like #{chapter}") | 14 | + @Select("select Top(1) Id from ZY_YYChapter where Name like #{chapter}") |
15 | String getChapterId(@Param("chapter") String chapter); | 15 | String getChapterId(@Param("chapter") String chapter); |
16 | 16 | ||
17 | - @Select("select Id from ZY_YYKnowledge where name like #{knowledge}") | 17 | + @Select("select Top(1) Id from ZY_YYKnowledge where name like #{knowledge}") |
18 | String getKnowledgeId(@Param("knowledge") String knowledge); | 18 | String getKnowledgeId(@Param("knowledge") String knowledge); |
19 | 19 | ||
20 | - @Select("select Id from ZY_YYGrade where name like #{gradeId}") | 20 | + @Select("select Top(1) Id from ZY_YYGrade where name like #{gradeId}") |
21 | String getGradeId(@Param("gradeId") String gradeId); | 21 | String getGradeId(@Param("gradeId") String gradeId); |
22 | 22 | ||
23 | @Insert("insert into ZY_YYQuestion (Question, Qtype, Answer, CorrectAnswer, Analysis, State, Intime, StemId, ExamineFlag, SubjectId, SuggestionTime, DifficulteId, ChapterId, GradeId, SourceId, QuestionSource, AutomaticCorrection)" + | 23 | @Insert("insert into ZY_YYQuestion (Question, Qtype, Answer, CorrectAnswer, Analysis, State, Intime, StemId, ExamineFlag, SubjectId, SuggestionTime, DifficulteId, ChapterId, GradeId, SourceId, QuestionSource, AutomaticCorrection)" + |
cloud/haikangface/src/main/java/com/sincere/haikangface/async/SendUserAsync.java
@@ -39,7 +39,7 @@ public class SendUserAsync { | @@ -39,7 +39,7 @@ public class SendUserAsync { | ||
39 | 39 | ||
40 | // @Async("taskExecutor") | 40 | // @Async("taskExecutor") |
41 | public void sendStuToHaiKang(String srcFile, String picUrl, String card, String startTime, String endTime, int validTimeEnabled, String name, String deviceId, String userType, int isPiliang) { | 41 | public void sendStuToHaiKang(String srcFile, String picUrl, String card, String startTime, String endTime, int validTimeEnabled, String name, String deviceId, String userType, int isPiliang) { |
42 | - System.out.println("下发时间设置:"+validTimeEnabled); | 42 | +// System.out.println("下发时间设置:"+validTimeEnabled); |
43 | if (null == sendRecoderUtils) sendRecoderUtils = new SendRecoderUtils(); | 43 | if (null == sendRecoderUtils) sendRecoderUtils = new SendRecoderUtils(); |
44 | //1、检测图片是否合格 | 44 | //1、检测图片是否合格 |
45 | boolean check = true; | 45 | boolean check = true; |
@@ -68,7 +68,6 @@ public class SendUserAsync { | @@ -68,7 +68,6 @@ public class SendUserAsync { | ||
68 | 68 | ||
69 | } | 69 | } |
70 | 70 | ||
71 | - | ||
72 | /** | 71 | /** |
73 | * 调用传图片接口 | 72 | * 调用传图片接口 |
74 | * @param filePath | 73 | * @param filePath |
@@ -80,13 +79,12 @@ public class SendUserAsync { | @@ -80,13 +79,12 @@ public class SendUserAsync { | ||
80 | * @param validTimeEnabled | 79 | * @param validTimeEnabled |
81 | * @param userType | 80 | * @param userType |
82 | */ | 81 | */ |
83 | - @Async("taskExecutor") | 82 | +// @Async("taskExecutor") |
84 | public void uploadImgs(String filePath,String card,String name,String deviceId,String startTime,String endTime,int validTimeEnabled,String userType){ | 83 | 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); | 84 | HttpUtil.uploadImgs(filePath,card,name,deviceId,startTime,endTime,validTimeEnabled,userType); |
87 | } | 85 | } |
88 | 86 | ||
89 | - @Async("taskExecutor") | 87 | +// @Async("taskExecutor") |
90 | public void deleteCard(String deviceId, String card){ | 88 | public void deleteCard(String deviceId, String card){ |
91 | HttpUtil.deleteCard(deviceId,card); | 89 | HttpUtil.deleteCard(deviceId,card); |
92 | } | 90 | } |
cloud/haikangface/src/main/java/com/sincere/haikangface/bean/Answer.java
0 → 100644
@@ -0,0 +1,37 @@ | @@ -0,0 +1,37 @@ | ||
1 | +package com.sincere.haikangface.bean; | ||
2 | + | ||
3 | +import io.swagger.annotations.ApiModelProperty; | ||
4 | + | ||
5 | +public class Answer { | ||
6 | + | ||
7 | + @ApiModelProperty(value = "题目id") | ||
8 | + private String queId; | ||
9 | + | ||
10 | + @ApiModelProperty(value = "答案图片链接") | ||
11 | + private String ansUrl; | ||
12 | + | ||
13 | + public String getQueId() { | ||
14 | + return queId; | ||
15 | + } | ||
16 | + | ||
17 | + public void setQueId(String queId) { | ||
18 | + this.queId = queId; | ||
19 | + } | ||
20 | + | ||
21 | + public String getAnsUrl() { | ||
22 | + return ansUrl; | ||
23 | + } | ||
24 | + | ||
25 | + public void setAnsUrl(String ansUrl) { | ||
26 | + this.ansUrl = ansUrl; | ||
27 | + } | ||
28 | + | ||
29 | + @Override | ||
30 | + public String toString() { | ||
31 | + return "Answer{" + | ||
32 | + "queId='" + queId + '\'' + | ||
33 | + ", ansUrl='" + ansUrl + '\'' + | ||
34 | + '}'; | ||
35 | + } | ||
36 | + | ||
37 | +} |
cloud/haikangface/src/main/java/com/sincere/haikangface/bean/Images2Ddevices.java
0 → 100644
@@ -0,0 +1,48 @@ | @@ -0,0 +1,48 @@ | ||
1 | +package com.sincere.haikangface.bean; | ||
2 | + | ||
3 | +import io.swagger.annotations.ApiModelProperty; | ||
4 | + | ||
5 | +/** | ||
6 | + * 下发图片到设备集合对象 | ||
7 | + */ | ||
8 | +public class Images2Ddevices { | ||
9 | + | ||
10 | + @ApiModelProperty("设备集合,用,隔开") | ||
11 | + private String devices; | ||
12 | + @ApiModelProperty("图片目录") | ||
13 | + private String imgPath; | ||
14 | + @ApiModelProperty("身份类型1:老师,2:学生") | ||
15 | + private String userType; | ||
16 | + | ||
17 | + public String getUserType() { | ||
18 | + return userType; | ||
19 | + } | ||
20 | + | ||
21 | + public void setUserType(String userType) { | ||
22 | + this.userType = userType; | ||
23 | + } | ||
24 | + | ||
25 | + public String getDevices() { | ||
26 | + return devices; | ||
27 | + } | ||
28 | + | ||
29 | + public void setDevices(String devices) { | ||
30 | + this.devices = devices; | ||
31 | + } | ||
32 | + | ||
33 | + public String getImgPath() { | ||
34 | + return imgPath; | ||
35 | + } | ||
36 | + | ||
37 | + public void setImgPath(String imgPath) { | ||
38 | + this.imgPath = imgPath; | ||
39 | + } | ||
40 | + | ||
41 | + @Override | ||
42 | + public String toString() { | ||
43 | + return "Images2Ddevices{" + | ||
44 | + "devices='" + devices + '\'' + | ||
45 | + ", imgPath='" + imgPath + '\'' + | ||
46 | + '}'; | ||
47 | + } | ||
48 | +} |
cloud/haikangface/src/main/java/com/sincere/haikangface/bean/ShijiBean.java
0 → 100644
@@ -0,0 +1,79 @@ | @@ -0,0 +1,79 @@ | ||
1 | +package com.sincere.haikangface.bean; | ||
2 | + | ||
3 | +import io.swagger.annotations.Api; | ||
4 | +import io.swagger.annotations.ApiModelProperty; | ||
5 | + | ||
6 | +import java.util.List; | ||
7 | + | ||
8 | +public class ShijiBean { | ||
9 | + @ApiModelProperty(value = "章节") | ||
10 | + private String chapter;//章节 | ||
11 | + @ApiModelProperty(value = "请求链接") | ||
12 | + private String requestUrl;//请求链接 | ||
13 | + @ApiModelProperty(value = "年级") | ||
14 | + private String grade;//年级 | ||
15 | + @ApiModelProperty(value = "科目") | ||
16 | + private String subject;//科目 | ||
17 | + @ApiModelProperty(value = "学校id") | ||
18 | + private String schoolId;//科目 | ||
19 | + @ApiModelProperty(value = "答案") | ||
20 | + private List<Answer> answer; | ||
21 | + | ||
22 | + | ||
23 | + public String getSchoolId() { | ||
24 | + return schoolId; | ||
25 | + } | ||
26 | + | ||
27 | + public void setSchoolId(String schoolId) { | ||
28 | + this.schoolId = schoolId; | ||
29 | + } | ||
30 | + | ||
31 | + public String getSubject() { | ||
32 | + return subject; | ||
33 | + } | ||
34 | + | ||
35 | + public void setSubject(String subject) { | ||
36 | + this.subject = subject; | ||
37 | + } | ||
38 | + | ||
39 | + public String getChapter() { | ||
40 | + return chapter; | ||
41 | + } | ||
42 | + | ||
43 | + public void setChapter(String chapter) { | ||
44 | + this.chapter = chapter; | ||
45 | + } | ||
46 | + | ||
47 | + public String getRequestUrl() { | ||
48 | + return requestUrl; | ||
49 | + } | ||
50 | + | ||
51 | + public void setRequestUrl(String requestUrl) { | ||
52 | + this.requestUrl = requestUrl; | ||
53 | + } | ||
54 | + | ||
55 | + public List<Answer> getAnswer() { | ||
56 | + return answer; | ||
57 | + } | ||
58 | + | ||
59 | + public void setAnswer(List<Answer> answer) { | ||
60 | + this.answer = answer; | ||
61 | + } | ||
62 | + | ||
63 | + public String getGrade() { | ||
64 | + return grade; | ||
65 | + } | ||
66 | + | ||
67 | + public void setGrade(String grade) { | ||
68 | + this.grade = grade; | ||
69 | + } | ||
70 | + | ||
71 | + @Override | ||
72 | + public String toString() { | ||
73 | + return "ShijiBean{" + | ||
74 | + "chapter='" + chapter + '\'' + | ||
75 | + ", requestUrl='" + requestUrl + '\'' + | ||
76 | + ", answer=" + answer + | ||
77 | + '}'; | ||
78 | + } | ||
79 | +} |
cloud/haikangface/src/main/java/com/sincere/haikangface/bean/StudentBean.java
@@ -276,11 +276,30 @@ public class StudentBean implements Serializable { | @@ -276,11 +276,30 @@ public class StudentBean implements Serializable { | ||
276 | @Override | 276 | @Override |
277 | public String toString() { | 277 | public String toString() { |
278 | return "StudentBean{" + | 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 + | ||
279 | ", name='" + name + '\'' + | 286 | ", name='" + name + '\'' + |
287 | + ", ClassId=" + ClassId + | ||
280 | ", ClassName='" + ClassName + '\'' + | 288 | ", ClassName='" + ClassName + '\'' + |
289 | + ", OldCard='" + OldCard + '\'' + | ||
281 | ", Card='" + Card + '\'' + | 290 | ", Card='" + Card + '\'' + |
282 | ", SchoolId=" + SchoolId + | 291 | ", SchoolId=" + SchoolId + |
283 | ", school_id=" + school_id + | 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 + '\'' + | ||
284 | ", teacher_num='" + teacher_num + '\'' + | 303 | ", teacher_num='" + teacher_num + '\'' + |
285 | ", num='" + num + '\'' + | 304 | ", num='" + num + '\'' + |
286 | '}'; | 305 | '}'; |
cloud/haikangface/src/main/java/com/sincere/haikangface/bean/UploadBean.java
0 → 100644
@@ -0,0 +1,124 @@ | @@ -0,0 +1,124 @@ | ||
1 | +package com.sincere.haikangface.bean; | ||
2 | + | ||
3 | +/** | ||
4 | + * 上传人脸的元素 | ||
5 | + */ | ||
6 | +public class UploadBean { | ||
7 | + | ||
8 | + | ||
9 | + private String filePath;//源文件 | ||
10 | + | ||
11 | + private String targetPath;//目标文件 | ||
12 | + | ||
13 | + private String cardNUm;//十进制卡号 | ||
14 | + | ||
15 | + private String startTime;//开始时间 | ||
16 | + | ||
17 | + private String endTime;//结束时间 | ||
18 | + | ||
19 | + private int validTimeEnabled;//1:增加,0:删除 | ||
20 | + | ||
21 | + private String name;//姓名 | ||
22 | + | ||
23 | + private String deviceId;//设备id | ||
24 | + | ||
25 | + private String userType;//用户身份 | ||
26 | + | ||
27 | + private String isPiliang;//0:批量,1:单张 | ||
28 | + | ||
29 | + public String getFilePath() { | ||
30 | + return filePath; | ||
31 | + } | ||
32 | + | ||
33 | + public void setFilePath(String filePath) { | ||
34 | + this.filePath = filePath; | ||
35 | + } | ||
36 | + | ||
37 | + public String getTargetPath() { | ||
38 | + return targetPath; | ||
39 | + } | ||
40 | + | ||
41 | + public void setTargetPath(String targetPath) { | ||
42 | + this.targetPath = targetPath; | ||
43 | + } | ||
44 | + | ||
45 | + public String getCardNUm() { | ||
46 | + return cardNUm; | ||
47 | + } | ||
48 | + | ||
49 | + public void setCardNUm(String cardNUm) { | ||
50 | + this.cardNUm = cardNUm; | ||
51 | + } | ||
52 | + | ||
53 | + public String getStartTime() { | ||
54 | + return startTime; | ||
55 | + } | ||
56 | + | ||
57 | + public void setStartTime(String startTime) { | ||
58 | + this.startTime = startTime; | ||
59 | + } | ||
60 | + | ||
61 | + public String getEndTime() { | ||
62 | + return endTime; | ||
63 | + } | ||
64 | + | ||
65 | + public void setEndTime(String endTime) { | ||
66 | + this.endTime = endTime; | ||
67 | + } | ||
68 | + | ||
69 | + public int getValidTimeEnabled() { | ||
70 | + return validTimeEnabled; | ||
71 | + } | ||
72 | + | ||
73 | + public void setValidTimeEnabled(int validTimeEnabled) { | ||
74 | + this.validTimeEnabled = validTimeEnabled; | ||
75 | + } | ||
76 | + | ||
77 | + public String getName() { | ||
78 | + return name; | ||
79 | + } | ||
80 | + | ||
81 | + public void setName(String name) { | ||
82 | + this.name = name; | ||
83 | + } | ||
84 | + | ||
85 | + public String getDeviceId() { | ||
86 | + return deviceId; | ||
87 | + } | ||
88 | + | ||
89 | + public void setDeviceId(String deviceId) { | ||
90 | + this.deviceId = deviceId; | ||
91 | + } | ||
92 | + | ||
93 | + public String getUserType() { | ||
94 | + return userType; | ||
95 | + } | ||
96 | + | ||
97 | + public void setUserType(String userType) { | ||
98 | + this.userType = userType; | ||
99 | + } | ||
100 | + | ||
101 | + public String getIsPiliang() { | ||
102 | + return isPiliang; | ||
103 | + } | ||
104 | + | ||
105 | + public void setIsPiliang(String isPiliang) { | ||
106 | + this.isPiliang = isPiliang; | ||
107 | + } | ||
108 | + | ||
109 | + @Override | ||
110 | + public String toString() { | ||
111 | + return "UploadBean{" + | ||
112 | + "filePath='" + filePath + '\'' + | ||
113 | + ", targetPath='" + targetPath + '\'' + | ||
114 | + ", cardNUm='" + cardNUm + '\'' + | ||
115 | + ", startTime='" + startTime + '\'' + | ||
116 | + ", endTime='" + endTime + '\'' + | ||
117 | + ", validTimeEnabled=" + validTimeEnabled + | ||
118 | + ", name='" + name + '\'' + | ||
119 | + ", deviceId='" + deviceId + '\'' + | ||
120 | + ", userType='" + userType + '\'' + | ||
121 | + ", isPiliang='" + isPiliang + '\'' + | ||
122 | + '}'; | ||
123 | + } | ||
124 | +} |
cloud/haikangface/src/main/java/com/sincere/haikangface/control/FileControl.java
@@ -2,19 +2,25 @@ package com.sincere.haikangface.control; | @@ -2,19 +2,25 @@ package com.sincere.haikangface.control; | ||
2 | 2 | ||
3 | import com.sincere.haikangface.CMSServer; | 3 | import com.sincere.haikangface.CMSServer; |
4 | import com.sincere.haikangface.async.SendUserAsync; | 4 | import com.sincere.haikangface.async.SendUserAsync; |
5 | -import com.sincere.haikangface.bean.face.SendFaceBean; | 5 | +import com.sincere.haikangface.bean.Images2Ddevices; |
6 | +import com.sincere.haikangface.bean.StudentBean; | ||
7 | +import com.sincere.haikangface.bean.UploadBean; | ||
6 | import com.sincere.haikangface.dao.UserDao; | 8 | import com.sincere.haikangface.dao.UserDao; |
7 | import com.sincere.haikangface.utils.FileUtils; | 9 | import com.sincere.haikangface.utils.FileUtils; |
8 | import com.sincere.haikangface.utils.SendRecoderUtils; | 10 | import com.sincere.haikangface.utils.SendRecoderUtils; |
9 | import com.sincere.haikangface.xiananDao.SendRecordDao; | 11 | import com.sincere.haikangface.xiananDao.SendRecordDao; |
10 | import io.swagger.annotations.Api; | 12 | import io.swagger.annotations.Api; |
11 | import io.swagger.annotations.ApiOperation; | 13 | import io.swagger.annotations.ApiOperation; |
14 | +import org.slf4j.Logger; | ||
15 | +import org.slf4j.LoggerFactory; | ||
12 | import org.springframework.beans.factory.annotation.Autowired; | 16 | import org.springframework.beans.factory.annotation.Autowired; |
13 | import org.springframework.web.bind.annotation.*; | 17 | import org.springframework.web.bind.annotation.*; |
14 | import org.springframework.web.multipart.MultipartFile; | 18 | import org.springframework.web.multipart.MultipartFile; |
15 | 19 | ||
16 | import java.io.File; | 20 | import java.io.File; |
17 | import java.io.FileOutputStream; | 21 | import java.io.FileOutputStream; |
22 | +import java.text.SimpleDateFormat; | ||
23 | +import java.util.*; | ||
18 | 24 | ||
19 | @RestController | 25 | @RestController |
20 | @Api("文件管理器") | 26 | @Api("文件管理器") |
@@ -35,14 +41,21 @@ public class FileControl { | @@ -35,14 +41,21 @@ public class FileControl { | ||
35 | 41 | ||
36 | SendRecoderUtils sendRecoderUtils; | 42 | SendRecoderUtils sendRecoderUtils; |
37 | 43 | ||
44 | + Queue<UploadBean> uploadBeanQueue = new LinkedList<>(); | ||
45 | + | ||
38 | @RequestMapping(method = RequestMethod.POST, value = "uploadImg") | 46 | @RequestMapping(method = RequestMethod.POST, value = "uploadImg") |
39 | public String uploadImg(@RequestParam("file") MultipartFile file, @RequestParam("card") String card | 47 | public String uploadImg(@RequestParam("file") MultipartFile file, @RequestParam("card") String card |
40 | , @RequestParam("name") String name, @RequestParam("deviceId") String deviceId, @RequestParam("startTime") String startTime, | 48 | , @RequestParam("name") String name, @RequestParam("deviceId") String deviceId, @RequestParam("startTime") String startTime, |
41 | @RequestParam("endTime") String endTime, @RequestParam("validTimeEnabled") int validTimeEnabled, @RequestParam("userType") String userType) { | 49 | @RequestParam("endTime") String endTime, @RequestParam("validTimeEnabled") int validTimeEnabled, @RequestParam("userType") String userType) { |
42 | 50 | ||
51 | + | ||
43 | try { | 52 | try { |
44 | - String fileName = file.getOriginalFilename();//文件名 | 53 | + if (!cmsServer.getIsDeviceOnline(deviceId)){ |
54 | + FileUtils.getInstance().writeLogs("设备不在线:" +deviceId, FileUtils.devices); | ||
55 | + return "0"; | ||
56 | + } | ||
45 | 57 | ||
58 | + String fileName = file.getOriginalFilename();//文件名 | ||
46 | File outFile = new File(".//imgCom"); | 59 | File outFile = new File(".//imgCom"); |
47 | if (!outFile.exists()) outFile.mkdirs(); | 60 | if (!outFile.exists()) outFile.mkdirs(); |
48 | File dest = new File(outFile, fileName); | 61 | File dest = new File(outFile, fileName); |
@@ -54,7 +67,7 @@ public class FileControl { | @@ -54,7 +67,7 @@ public class FileControl { | ||
54 | long time = System.currentTimeMillis(); | 67 | long time = System.currentTimeMillis(); |
55 | if (filePath.contains(".jpg")) filePath = filePath.replace(".jpg", ".png"); | 68 | if (filePath.contains(".jpg")) filePath = filePath.replace(".jpg", ".png"); |
56 | if (new File(filePath.trim()).exists()) { | 69 | if (new File(filePath.trim()).exists()) { |
57 | - String targetPath = FileUtils.picPathComp + new File(filePath).getName(); | 70 | + String targetPath = FileUtils.picPathComp + new File(filePath).getName().replace(".png",".jpg"); |
58 | try { | 71 | try { |
59 | int isPiliang = 0;//0:批量,1:单张 | 72 | int isPiliang = 0;//0:批量,1:单张 |
60 | if (filePath.contains("face17e50")) {//批量发送 | 73 | if (filePath.contains("face17e50")) {//批量发送 |
cloud/haikangface/src/main/java/com/sincere/haikangface/control/QueControl21.java
0 → 100644
@@ -0,0 +1,274 @@ | @@ -0,0 +1,274 @@ | ||
1 | +package com.sincere.haikangface.control; | ||
2 | + | ||
3 | +import com.baidu.aip.util.Base64Util; | ||
4 | +import com.sincere.common.util.AuthService; | ||
5 | +import com.sincere.haikangface.admindao.ZuoyeAdminDao; | ||
6 | +import com.sincere.haikangface.bean.Answer; | ||
7 | +import com.sincere.haikangface.bean.ShijiBean; | ||
8 | +import com.sincere.haikangface.bean.homework.QuestionBean; | ||
9 | +import com.sincere.haikangface.dao.UserDao; | ||
10 | +import com.sincere.haikangface.dao.ZuoYeDao; | ||
11 | +import com.sincere.haikangface.utils.HttpUtil; | ||
12 | +import io.swagger.annotations.Api; | ||
13 | +import io.swagger.annotations.ApiOperation; | ||
14 | +import org.json.JSONArray; | ||
15 | +import org.json.JSONException; | ||
16 | +import org.json.JSONObject; | ||
17 | +import org.springframework.beans.factory.annotation.Autowired; | ||
18 | +import org.springframework.http.HttpEntity; | ||
19 | +import org.springframework.http.HttpHeaders; | ||
20 | +import org.springframework.http.MediaType; | ||
21 | +import org.springframework.http.ResponseEntity; | ||
22 | +import org.springframework.util.LinkedMultiValueMap; | ||
23 | +import org.springframework.util.MultiValueMap; | ||
24 | +import org.springframework.util.StringUtils; | ||
25 | +import org.springframework.web.bind.annotation.RequestBody; | ||
26 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
27 | +import org.springframework.web.bind.annotation.RequestMethod; | ||
28 | +import org.springframework.web.bind.annotation.RestController; | ||
29 | +import org.springframework.web.client.RestTemplate; | ||
30 | + | ||
31 | +import java.io.*; | ||
32 | +import java.net.URL; | ||
33 | +import java.net.URLConnection; | ||
34 | +import java.net.URLEncoder; | ||
35 | +import java.text.SimpleDateFormat; | ||
36 | +import java.util.ArrayList; | ||
37 | +import java.util.Date; | ||
38 | +import java.util.HashMap; | ||
39 | +import java.util.List; | ||
40 | + | ||
41 | +@RestController | ||
42 | +@RequestMapping("/shiji/*") | ||
43 | +@Api("21世纪题目添加") | ||
44 | +public class QueControl21 { | ||
45 | + @Autowired | ||
46 | + ZuoYeDao zuoYeDao; | ||
47 | + | ||
48 | + @Autowired | ||
49 | + ZuoyeAdminDao zuoyeAdminDao; | ||
50 | + | ||
51 | + @RequestMapping(value = "addQuestion", method = RequestMethod.POST) | ||
52 | + @ApiOperation(value = "添加题目") | ||
53 | + public String addQuestion(@RequestBody ShijiBean shijiBean) { | ||
54 | + List<String> errQuesList = new ArrayList<>(); | ||
55 | + try { | ||
56 | + | ||
57 | + RestTemplate restTemplate = new RestTemplate(); | ||
58 | + | ||
59 | + String url = shijiBean.getRequestUrl(); | ||
60 | + | ||
61 | + String content = restTemplate.getForObject(url, String.class, new HashMap<>()); | ||
62 | + | ||
63 | + JSONObject jsonObject = new JSONObject(content); | ||
64 | + JSONObject data = jsonObject.optJSONObject("data"); | ||
65 | + JSONArray questions = data.optJSONArray("questions"); | ||
66 | + for (int i = 0; i < questions.length(); i++) { | ||
67 | + JSONObject question = questions.optJSONObject(i); | ||
68 | + String question_text = question.optString("question_text"); | ||
69 | + String question_id = question.optString("question_id"); | ||
70 | + String explanation = question.optString("explanation");//解析 | ||
71 | + String difficult_index = question.optString("difficult_index");//难度系数 | ||
72 | + String channel_type_name = question.optString("channel_type_name");//题目类型 | ||
73 | + JSONArray t_knowledge = question.optJSONArray("t_knowledge"); | ||
74 | + String Knowledge = ""; | ||
75 | + if (t_knowledge != null && t_knowledge.length() > 0) { | ||
76 | + JSONArray t_knowArr = t_knowledge.optJSONArray(0); | ||
77 | + if (t_knowArr != null && t_knowArr.length() > 0) | ||
78 | + Knowledge = t_knowArr.optJSONObject(0).optString("name"); | ||
79 | + } | ||
80 | + String chapterId = zuoyeAdminDao.getChapterId(shijiBean.getChapter()); | ||
81 | + String KnowledgeId = zuoyeAdminDao.getKnowledgeId(Knowledge); | ||
82 | + String gradeId = zuoyeAdminDao.getGradeId(shijiBean.getGrade()); | ||
83 | + explanation = "<p><img src=\"" + explanation + "\" title=\"image.png\" alt=\"image.png\"/></p>"; | ||
84 | + String answer = getAnswerUrl(question_id, shijiBean.getAnswer());//答案 | ||
85 | + System.out.println("answer:" + answer + "KnowledgeId:" + KnowledgeId + " chapterId:" + shijiBean.getChapter()+chapterId+" gradeId:"+gradeId+" Knowledge:"+Knowledge); | ||
86 | + | ||
87 | + | ||
88 | + if (StringUtils.isEmpty(chapterId)){ | ||
89 | + return "章节不存在"; | ||
90 | + } | ||
91 | + | ||
92 | + if (StringUtils.isEmpty(KnowledgeId)){ | ||
93 | + return "知识点不存在"; | ||
94 | + } | ||
95 | + | ||
96 | + if (StringUtils.isEmpty(gradeId)){ | ||
97 | + return "年级不存在"; | ||
98 | + } | ||
99 | + | ||
100 | + if (StringUtils.isEmpty(answer)){ | ||
101 | + return "答案解析失败"; | ||
102 | + } | ||
103 | + | ||
104 | + if (!answer.equals("") && KnowledgeId != null && chapterId != null && gradeId != null) { | ||
105 | + List<QuestionBean> questionBeans = zuoYeDao.getQuestions(question_text);//获取题目 | ||
106 | +// System.out.println("questionBeans:"+questionBeans); | ||
107 | + if (questionBeans != null && questionBeans.size() > 0) {//更新题库 | ||
108 | + for (int j = 0; j < questionBeans.size(); j++) { | ||
109 | + QuestionBean questionBean = questionBeans.get(j); | ||
110 | + zuoYeDao.updateQuestion(questionBean.getID(), answer, explanation); | ||
111 | + System.out.println("更新题库成功"); | ||
112 | + } | ||
113 | + } else {//新增题库 | ||
114 | + String dateTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); | ||
115 | + String subjectId = getSubjectId(shijiBean.getSubject()); | ||
116 | + if (subjectId == null) return "科目输入错误"; | ||
117 | + String createrUserId = jsonObject.optString("createUserId"); | ||
118 | + String schoolId = shijiBean.getSchoolId(); | ||
119 | + zuoYeDao.addQuestionStem(channel_type_name, "1", dateTime); | ||
120 | + int stemId = zuoYeDao.getStemId(); | ||
121 | + zuoYeDao.addQuestion(question_text, "1", "A,B,C,D", answer, explanation, "1", dateTime, | ||
122 | + "1", createrUserId, createrUserId, subjectId, schoolId, difficult_index, | ||
123 | + KnowledgeId, chapterId, gradeId, "1", "1", "1", stemId + "", "1", "0", "0"); | ||
124 | + System.out.println("添加题库成功"); | ||
125 | + } | ||
126 | + } else { | ||
127 | + System.out.println("导入题目失败"); | ||
128 | + errQuesList.add(question.toString()); | ||
129 | + } | ||
130 | + Thread.sleep(1000); | ||
131 | + } | ||
132 | + | ||
133 | + } catch (JSONException e) { | ||
134 | + e.printStackTrace(); | ||
135 | + } catch (InterruptedException e) { | ||
136 | + e.printStackTrace(); | ||
137 | + } | ||
138 | + return "导入题目成功"; | ||
139 | + } | ||
140 | + | ||
141 | + private String getSubjectId(String subject) { | ||
142 | + | ||
143 | + switch (subject) { | ||
144 | + case "数学": | ||
145 | + return "1"; | ||
146 | + case "语文": | ||
147 | + return "2"; | ||
148 | + case "化学": | ||
149 | + return "3"; | ||
150 | + case "英语": | ||
151 | + return "5"; | ||
152 | + case "科学": | ||
153 | + return "9"; | ||
154 | + } | ||
155 | + | ||
156 | + return null; | ||
157 | + } | ||
158 | + | ||
159 | + | ||
160 | + private String getAnswerUrl(String quesId, List<Answer> answer) { | ||
161 | + | ||
162 | + for (Answer ans : | ||
163 | + answer) { | ||
164 | + System.out.println("ans:" + ans.getQueId() + "-------quesId:" + quesId); | ||
165 | + if (quesId.equals(ans.getQueId())) { | ||
166 | + return getAnswer(ans.getAnsUrl(), 2); | ||
167 | + } | ||
168 | + | ||
169 | + } | ||
170 | + | ||
171 | + | ||
172 | + return ""; | ||
173 | + | ||
174 | + } | ||
175 | + | ||
176 | + | ||
177 | + private String url = "https://aip.baidubce.com/rest/2.0/ocr/v1/general_basic?access_token="+ AuthService.getAuth(); | ||
178 | + | ||
179 | + private String getAnswer(String imgUrl, int type) { | ||
180 | + | ||
181 | + RestTemplate restTemplate = new RestTemplate(); | ||
182 | + | ||
183 | + HttpHeaders headers = new HttpHeaders(); | ||
184 | + headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); | ||
185 | + | ||
186 | + MultiValueMap<String, String> multiValueMap = new LinkedMultiValueMap<>(); | ||
187 | + if (type == 1) { | ||
188 | + multiValueMap.add("url", imgUrl); | ||
189 | + } else if (type == 2) { | ||
190 | + multiValueMap.add("image", Base64Util.encode(download(imgUrl))); | ||
191 | + } | ||
192 | + HttpEntity<MultiValueMap> requestEntity = new HttpEntity<MultiValueMap>(multiValueMap, | ||
193 | + | ||
194 | + headers); | ||
195 | + | ||
196 | + ResponseEntity<String> result = restTemplate.postForEntity(url, requestEntity, String.class); | ||
197 | + | ||
198 | + JSONObject jsonObject = null; | ||
199 | + try { | ||
200 | + jsonObject = new JSONObject(result.getBody()); | ||
201 | + } catch (JSONException e) { | ||
202 | + e.printStackTrace(); | ||
203 | + } | ||
204 | +// System.out.println("result:"+result.getBody()); | ||
205 | + JSONArray words_result = jsonObject.optJSONArray("words_result"); | ||
206 | + System.out.println("words_result:"+words_result); | ||
207 | + StringBuilder stringBuilder = new StringBuilder(); | ||
208 | + if (words_result != null) { | ||
209 | + for (int i = 0; i < words_result.length(); i++) { | ||
210 | + String words = words_result.optJSONObject(i).optString("words"); | ||
211 | + stringBuilder.append(words + " "); | ||
212 | + } | ||
213 | + System.out.println("result:" + stringBuilder.toString()); | ||
214 | + } | ||
215 | + return stringBuilder.toString().equals("") ? "" : stringBuilder.toString(); | ||
216 | + } | ||
217 | + | ||
218 | + private byte[] download(String urlString) { | ||
219 | + try { | ||
220 | +System.out.println("urlString:"+urlString); | ||
221 | + // 构造URL | ||
222 | + URL url = new URL(urlString); | ||
223 | + // 打开连接 | ||
224 | + URLConnection con = url.openConnection(); | ||
225 | + // 输入流 | ||
226 | + InputStream is = con.getInputStream(); | ||
227 | + // 1K的数据缓冲 | ||
228 | + byte[] bs = new byte[1024]; | ||
229 | + // 读取到的数据长度 | ||
230 | + int len; | ||
231 | + // 输出的文件流 | ||
232 | + String filename = "./imgs/"; //下载路径及下载图片名称 | ||
233 | + File file = new File(filename); | ||
234 | + if (!file.exists())file.mkdirs(); | ||
235 | + | ||
236 | + String filePath = filename+File.separator+System.currentTimeMillis()+".png"; | ||
237 | + File outFile = new File(filePath); | ||
238 | + if (!outFile.exists())outFile.createNewFile(); | ||
239 | + FileOutputStream os = new FileOutputStream(outFile, true); | ||
240 | + // 开始读取 | ||
241 | + while ((len = is.read(bs)) != -1) { | ||
242 | + os.write(bs,0,len); | ||
243 | + } | ||
244 | + // 完毕,关闭所有链接 | ||
245 | + is.close(); | ||
246 | + os.close(); | ||
247 | + return InputStream2ByteArray(outFile.getAbsolutePath()); | ||
248 | + } catch (Exception e) { | ||
249 | + e.printStackTrace(); | ||
250 | + } | ||
251 | + return null; | ||
252 | + } | ||
253 | + | ||
254 | + private byte[] InputStream2ByteArray(String filePath) throws IOException { | ||
255 | + | ||
256 | + InputStream in = new FileInputStream(filePath); | ||
257 | + byte[] data = toByteArray(in); | ||
258 | + in.close(); | ||
259 | + | ||
260 | + return data; | ||
261 | + } | ||
262 | + | ||
263 | + private byte[] toByteArray(InputStream in) throws IOException { | ||
264 | + | ||
265 | + ByteArrayOutputStream out = new ByteArrayOutputStream(); | ||
266 | + byte[] buffer = new byte[1024 * 4]; | ||
267 | + int n = 0; | ||
268 | + while ((n = in.read(buffer)) != -1) { | ||
269 | + out.write(buffer, 0, n); | ||
270 | + } | ||
271 | + return out.toByteArray(); | ||
272 | + } | ||
273 | + | ||
274 | +} |
cloud/haikangface/src/main/java/com/sincere/haikangface/control/UserControl.java
1 | package com.sincere.haikangface.control; | 1 | package com.sincere.haikangface.control; |
2 | 2 | ||
3 | import com.sincere.common.dto.smartCampus.SZ_AttendanceDto; | 3 | import com.sincere.common.dto.smartCampus.SZ_AttendanceDto; |
4 | +import com.sincere.haikangface.bean.Images2Ddevices; | ||
4 | import com.sincere.haikangface.utils.BaiduApiUtiols; | 5 | import com.sincere.haikangface.utils.BaiduApiUtiols; |
5 | import com.sincere.haikangface.CMSServer; | 6 | import com.sincere.haikangface.CMSServer; |
6 | import com.sincere.haikangface.async.SendUserAsync; | 7 | import com.sincere.haikangface.async.SendUserAsync; |
@@ -14,13 +15,12 @@ import io.swagger.annotations.Api; | @@ -14,13 +15,12 @@ import io.swagger.annotations.Api; | ||
14 | import io.swagger.annotations.ApiImplicitParam; | 15 | import io.swagger.annotations.ApiImplicitParam; |
15 | import io.swagger.annotations.ApiImplicitParams; | 16 | import io.swagger.annotations.ApiImplicitParams; |
16 | import io.swagger.annotations.ApiOperation; | 17 | import io.swagger.annotations.ApiOperation; |
18 | +import org.slf4j.Logger; | ||
19 | +import org.slf4j.LoggerFactory; | ||
17 | import org.springframework.beans.factory.annotation.Autowired; | 20 | import org.springframework.beans.factory.annotation.Autowired; |
18 | import org.springframework.http.MediaType; | 21 | import org.springframework.http.MediaType; |
19 | import org.springframework.util.StringUtils; | 22 | import org.springframework.util.StringUtils; |
20 | -import org.springframework.web.bind.annotation.RequestMapping; | ||
21 | -import org.springframework.web.bind.annotation.RequestMethod; | ||
22 | -import org.springframework.web.bind.annotation.RequestParam; | ||
23 | -import org.springframework.web.bind.annotation.RestController; | 23 | +import org.springframework.web.bind.annotation.*; |
24 | import org.springframework.web.multipart.MultipartFile; | 24 | import org.springframework.web.multipart.MultipartFile; |
25 | 25 | ||
26 | import java.io.*; | 26 | import java.io.*; |
@@ -59,12 +59,9 @@ public class UserControl { | @@ -59,12 +59,9 @@ public class UserControl { | ||
59 | @RequestParam("endTime") String endTime, @RequestParam("validTimeEnabled") int validTimeEnabled, @RequestParam("userType") String userType) { | 59 | @RequestParam("endTime") String endTime, @RequestParam("validTimeEnabled") int validTimeEnabled, @RequestParam("userType") String userType) { |
60 | 60 | ||
61 | try { | 61 | try { |
62 | - | ||
63 | if (filePath.contains(".jpg")) filePath = filePath.replace(".jpg", ".png"); | 62 | if (filePath.contains(".jpg")) filePath = filePath.replace(".jpg", ".png"); |
64 | if (new File(filePath.trim()).exists()) { | 63 | if (new File(filePath.trim()).exists()) { |
65 | - | ||
66 | return sendImg(filePath, deviceId, card, name, userType); | 64 | return sendImg(filePath, deviceId, card, name, userType); |
67 | - | ||
68 | } else { | 65 | } else { |
69 | if (null == sendRecoderUtils) sendRecoderUtils = new SendRecoderUtils(); | 66 | if (null == sendRecoderUtils) sendRecoderUtils = new SendRecoderUtils(); |
70 | sendRecoderUtils.sendFail(sendRecordDao, Long.parseLong(getCard(card), 16) + "", filePath, deviceId, userDao, "文件不存在", userType); | 67 | sendRecoderUtils.sendFail(sendRecordDao, Long.parseLong(getCard(card), 16) + "", filePath, deviceId, userDao, "文件不存在", userType); |
@@ -96,7 +93,7 @@ public class UserControl { | @@ -96,7 +93,7 @@ public class UserControl { | ||
96 | else { | 93 | else { |
97 | sendUserAsync.uploadImgs(filePath, card, name, deviceId, startTime, endTime, 1, userType); | 94 | sendUserAsync.uploadImgs(filePath, card, name, deviceId, startTime, endTime, 1, userType); |
98 | } | 95 | } |
99 | - System.out.println("time:" + (System.currentTimeMillis() - time) / 1000); | 96 | +// System.out.println("time:" + (System.currentTimeMillis() - time) / 1000); |
100 | return true; | 97 | return true; |
101 | } catch (Exception e) { | 98 | } catch (Exception e) { |
102 | e.printStackTrace(); | 99 | e.printStackTrace(); |
@@ -105,6 +102,47 @@ public class UserControl { | @@ -105,6 +102,47 @@ public class UserControl { | ||
105 | 102 | ||
106 | } | 103 | } |
107 | 104 | ||
105 | + Logger logger = LoggerFactory.getLogger(FileControl.class); | ||
106 | + | ||
107 | + @RequestMapping(value = "sendImg2Devices", method = RequestMethod.POST) | ||
108 | + @ApiOperation("本地下发人脸给设备") | ||
109 | + public boolean sendImg2Devices(@RequestBody Images2Ddevices images2Ddevices) throws Exception { | ||
110 | + String startTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:dd").format(new Date()); | ||
111 | + Calendar calendar = Calendar.getInstance(); | ||
112 | + calendar.add(Calendar.YEAR, 10); | ||
113 | + String endTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:dd").format(calendar.getTime()); | ||
114 | + String devices = images2Ddevices.getDevices(); | ||
115 | + | ||
116 | + String imgPath = images2Ddevices.getImgPath(); | ||
117 | + | ||
118 | + String[] devStrs = devices.split(","); | ||
119 | + | ||
120 | + File[] imgStrs = new File(imgPath).listFiles(); | ||
121 | + | ||
122 | + if (null != imgStrs) { | ||
123 | + for (int i = 0; i < imgStrs.length; i++) { | ||
124 | + | ||
125 | + File filePath = imgStrs[i];//图片路径 | ||
126 | + if (filePath.exists()) { | ||
127 | + String studentCode = filePath.getName().split("\\.")[0]; | ||
128 | + StudentBean studentBean = userDao.getStudent_NumWitdCode(studentCode); | ||
129 | + if (null != studentBean) { | ||
130 | + for (int j = 0; j < devStrs.length; j++) { | ||
131 | + String devId = devStrs[j]; | ||
132 | + sendUserAsync.uploadImgs(filePath.getAbsolutePath(), studentBean.getStudent_num(), studentBean.getName(), devId, startTime, endTime, 1, images2Ddevices.getUserType()); | ||
133 | + } | ||
134 | + } else { | ||
135 | + logger.error("学生对象不存在"); | ||
136 | + } | ||
137 | + | ||
138 | + } | ||
139 | + | ||
140 | + } | ||
141 | + } | ||
142 | + | ||
143 | + return true; | ||
144 | + } | ||
145 | + | ||
108 | @RequestMapping(value = "sendFaces", method = RequestMethod.GET) | 146 | @RequestMapping(value = "sendFaces", method = RequestMethod.GET) |
109 | @ApiOperation(value = "下发学校下所有人脸给指定设备", notes = "下发所有人脸给指定设备") | 147 | @ApiOperation(value = "下发学校下所有人脸给指定设备", notes = "下发所有人脸给指定设备") |
110 | public void sendFaces(@RequestParam("deviceIds") String deviceIds, @RequestParam("schoolId") String schoolId, @RequestParam("userType") String userType) { | 148 | public void sendFaces(@RequestParam("deviceIds") String deviceIds, @RequestParam("schoolId") String schoolId, @RequestParam("userType") String userType) { |
@@ -131,13 +169,13 @@ public class UserControl { | @@ -131,13 +169,13 @@ public class UserControl { | ||
131 | StudentBean studentBean = null; | 169 | StudentBean studentBean = null; |
132 | String card = "", name = ""; | 170 | String card = "", name = ""; |
133 | if (userType.equals("1")) { | 171 | if (userType.equals("1")) { |
134 | - studentBean = userDao.getTeacherWithstudentcode(file.getName().split("\\.")[0],schoolId); | ||
135 | - if (null!=studentBean){ | 172 | + studentBean = userDao.getTeacherWithstudentcode(file.getName().split("\\.")[0], schoolId); |
173 | + if (null != studentBean) { | ||
136 | card = studentBean.getTeacher_num(); | 174 | card = studentBean.getTeacher_num(); |
137 | name = studentBean.getName(); | 175 | name = studentBean.getName(); |
138 | } | 176 | } |
139 | } else if (userType.equals("2")) { | 177 | } else if (userType.equals("2")) { |
140 | - studentBean = userDao.getStudentWithstudentcode(file.getName().split("\\.")[0],schoolId); | 178 | + studentBean = userDao.getStudentWithstudentcode(file.getName().split("\\.")[0], schoolId); |
141 | if (null != studentBean) { | 179 | if (null != studentBean) { |
142 | card = studentBean.getStudent_num(); | 180 | card = studentBean.getStudent_num(); |
143 | name = studentBean.getName(); | 181 | name = studentBean.getName(); |
@@ -158,10 +196,10 @@ public class UserControl { | @@ -158,10 +196,10 @@ public class UserControl { | ||
158 | 196 | ||
159 | @RequestMapping(value = "sendFaceToDevices", method = RequestMethod.GET) | 197 | @RequestMapping(value = "sendFaceToDevices", method = RequestMethod.GET) |
160 | @ApiOperation(value = "下发单个用户给指定设备", notes = "下发单个用户给指定设备") | 198 | @ApiOperation(value = "下发单个用户给指定设备", notes = "下发单个用户给指定设备") |
161 | - @ApiImplicitParams({@ApiImplicitParam(name = "deviceIds",value = "设备id用逗号,拼接"), | ||
162 | - @ApiImplicitParam(name = "file",value = "100服务器上图片绝对路径")}) | ||
163 | - public void sendFaceToDevices(@RequestParam("deviceIds") String deviceIds, @RequestParam("userType") String userType,@RequestParam("file") String file, | ||
164 | - @RequestParam("card") String card,@RequestParam("name") String name) { | 199 | + @ApiImplicitParams({@ApiImplicitParam(name = "deviceIds", value = "设备id用逗号,拼接"), |
200 | + @ApiImplicitParam(name = "file", value = "100服务器上图片绝对路径")}) | ||
201 | + public void sendFaceToDevices(@RequestParam("deviceIds") String deviceIds, @RequestParam("userType") String userType, @RequestParam("file") String file, | ||
202 | + @RequestParam("card") String card, @RequestParam("name") String name) { | ||
165 | 203 | ||
166 | String[] deviceIdsStr = deviceIds.split(","); | 204 | String[] deviceIdsStr = deviceIds.split(","); |
167 | 205 | ||
@@ -173,8 +211,7 @@ public class UserControl { | @@ -173,8 +211,7 @@ public class UserControl { | ||
173 | } | 211 | } |
174 | 212 | ||
175 | 213 | ||
176 | - | ||
177 | - @RequestMapping(value = "DeleteCard", method = RequestMethod.GET) | 214 | + @RequestMapping(value = "DeleteCard", method = RequestMethod.GET) |
178 | @ApiOperation("删除人脸") | 215 | @ApiOperation("删除人脸") |
179 | public boolean deleteCard(@RequestParam("deviceId") String deviceId, @RequestParam("card") String card) { | 216 | public boolean deleteCard(@RequestParam("deviceId") String deviceId, @RequestParam("card") String card) { |
180 | if (cmsServer.getIsDeviceOnline(deviceId)) | 217 | if (cmsServer.getIsDeviceOnline(deviceId)) |
cloud/haikangface/src/main/java/com/sincere/haikangface/control/ZuoYeControl.java
@@ -206,8 +206,11 @@ public class ZuoYeControl { | @@ -206,8 +206,11 @@ public class ZuoYeControl { | ||
206 | String channel_type_name = question.optString("channel_type_name");//题目类型 | 206 | String channel_type_name = question.optString("channel_type_name");//题目类型 |
207 | JSONArray t_knowledge = question.optJSONArray("t_knowledge"); | 207 | JSONArray t_knowledge = question.optJSONArray("t_knowledge"); |
208 | String Knowledge = ""; | 208 | String Knowledge = ""; |
209 | - if (t_knowledge != null && t_knowledge.length() > 0) | ||
210 | - Knowledge = t_knowledge.optJSONObject(0).optString("name"); | 209 | + if (t_knowledge != null && t_knowledge.length() > 0){ |
210 | + JSONArray t_knowArr = t_knowledge.optJSONArray(0); | ||
211 | + if (t_knowArr!=null&&t_knowArr.length()>0) | ||
212 | + Knowledge = t_knowArr.optJSONObject(0).optString("name"); | ||
213 | + } | ||
211 | 214 | ||
212 | String chapterId = zuoyeAdminDao.getChapterId(jsonObject.optString("chapter")); | 215 | String chapterId = zuoyeAdminDao.getChapterId(jsonObject.optString("chapter")); |
213 | String KnowledgeId = zuoyeAdminDao.getKnowledgeId(jsonObject.optString("chapter")); | 216 | String KnowledgeId = zuoyeAdminDao.getKnowledgeId(jsonObject.optString("chapter")); |
cloud/haikangface/src/main/java/com/sincere/haikangface/dao/UserDao.java
@@ -2,7 +2,6 @@ package com.sincere.haikangface.dao; | @@ -2,7 +2,6 @@ package com.sincere.haikangface.dao; | ||
2 | 2 | ||
3 | import com.sincere.haikangface.bean.*; | 3 | import com.sincere.haikangface.bean.*; |
4 | import org.apache.ibatis.annotations.*; | 4 | import org.apache.ibatis.annotations.*; |
5 | -import org.springframework.security.core.parameters.P; | ||
6 | import org.springframework.stereotype.Repository; | 5 | import org.springframework.stereotype.Repository; |
7 | 6 | ||
8 | import java.util.List; | 7 | import java.util.List; |
@@ -186,7 +185,7 @@ public interface UserDao { | @@ -186,7 +185,7 @@ public interface UserDao { | ||
186 | @Select("select class_id from SZ_V_School_Student where school_id = 479 and student_id = #{customerId} ") | 185 | @Select("select class_id from SZ_V_School_Student where school_id = 479 and student_id = #{customerId} ") |
187 | String getClassName(@Param("customerId") String customerId); | 186 | String getClassName(@Param("customerId") String customerId); |
188 | 187 | ||
189 | - @Select("select clint_id from SZ_AttendanceDto where school_id = #{schoolId} and clint_type=18") | 188 | + @Select("select clint_id from SZ_Attendance where school_id = #{schoolId} and clint_type=18") |
190 | List<String> getDeviceIdsWidthSchoolId(@Param("schoolId") int schoolId); | 189 | List<String> getDeviceIdsWidthSchoolId(@Param("schoolId") int schoolId); |
191 | 190 | ||
192 | 191 | ||
@@ -211,4 +210,7 @@ public interface UserDao { | @@ -211,4 +210,7 @@ public interface UserDao { | ||
211 | "from SZ_V_School_Teacher\n" + | 210 | "from SZ_V_School_Teacher\n" + |
212 | "where num = #{num} and school_id = #{schoolId}") | 211 | "where num = #{num} and school_id = #{schoolId}") |
213 | StudentBean getTeacherWithstudentcode(@Param("num") String num,@Param("schoolId")String schoolId); | 212 | StudentBean getTeacherWithstudentcode(@Param("num") String num,@Param("schoolId")String schoolId); |
213 | + | ||
214 | + @Select("select Top(1) * from SZ_V_School_Student where studentcode = #{studentcode}") | ||
215 | + StudentBean getStudent_NumWitdCode(@Param("studentcode") String studentcode); | ||
214 | } | 216 | } |
cloud/haikangface/src/main/java/com/sincere/haikangface/utils/CompressPic.java
@@ -16,7 +16,7 @@ import java.io.InputStream; | @@ -16,7 +16,7 @@ import java.io.InputStream; | ||
16 | public class CompressPic { | 16 | public class CompressPic { |
17 | 17 | ||
18 | public static String CompressPic(String srcPath, String targetPath) throws Exception { | 18 | public static String CompressPic(String srcPath, String targetPath) throws Exception { |
19 | - double cutPercent = 0.4; | 19 | + double cutPercent = 0.1; |
20 | File file = new File(srcPath.trim()); | 20 | File file = new File(srcPath.trim()); |
21 | FileInputStream fileInputStreamSrc = new FileInputStream(file); | 21 | FileInputStream fileInputStreamSrc = new FileInputStream(file); |
22 | BufferedImage bufferedImage = ImageIO.read(fileInputStreamSrc); | 22 | BufferedImage bufferedImage = ImageIO.read(fileInputStreamSrc); |
@@ -26,8 +26,9 @@ public class CompressPic { | @@ -26,8 +26,9 @@ public class CompressPic { | ||
26 | System.out.println("fileLength:"+fileLength); | 26 | System.out.println("fileLength:"+fileLength); |
27 | if ((fileLength / 1024) < 200) { | 27 | if ((fileLength / 1024) < 200) { |
28 | writeImgToFile(bufferedImage, width, height, targetPath); | 28 | writeImgToFile(bufferedImage, width, height, targetPath); |
29 | - } else | 29 | + } else{ |
30 | while ((fileLength / 1024) >= 200) { | 30 | while ((fileLength / 1024) >= 200) { |
31 | + System.out.println("fileLength:"+fileLength); | ||
31 | width = (int) (width * (1 - cutPercent)); | 32 | width = (int) (width * (1 - cutPercent)); |
32 | height = (int) (height * (1 - cutPercent)); | 33 | height = (int) (height * (1 - cutPercent)); |
33 | 34 | ||
@@ -41,6 +42,7 @@ public class CompressPic { | @@ -41,6 +42,7 @@ public class CompressPic { | ||
41 | fileLength = file1.length(); | 42 | fileLength = file1.length(); |
42 | fileInputStream.close(); | 43 | fileInputStream.close(); |
43 | } | 44 | } |
45 | + } | ||
44 | // System.out.printf("图片大小:"+fileLength/1024); | 46 | // System.out.printf("图片大小:"+fileLength/1024); |
45 | fileInputStreamSrc.close(); | 47 | fileInputStreamSrc.close(); |
46 | return targetPath; | 48 | return targetPath; |
@@ -64,10 +66,10 @@ public class CompressPic { | @@ -64,10 +66,10 @@ public class CompressPic { | ||
64 | } | 66 | } |
65 | 67 | ||
66 | }*/ | 68 | }*/ |
67 | - System.out.println("读写图片:" + write); | 69 | +// System.out.println("读写图片:" + write); |
68 | deskImage.close(); | 70 | deskImage.close(); |
69 | } catch (Exception e) { | 71 | } catch (Exception e) { |
70 | - System.out.println("读写图片:" + e.toString()); | 72 | +// System.out.println("读写图片:" + e.toString()); |
71 | e.printStackTrace(); | 73 | e.printStackTrace(); |
72 | } | 74 | } |
73 | } | 75 | } |
cloud/haikangface/src/main/java/com/sincere/haikangface/utils/SendRecoderUtils.java
@@ -100,7 +100,7 @@ public class SendRecoderUtils { | @@ -100,7 +100,7 @@ public class SendRecoderUtils { | ||
100 | 100 | ||
101 | break; | 101 | break; |
102 | } | 102 | } |
103 | - System.out.println("studentBean:" + studentBean); | 103 | +// System.out.println("studentBean:" + studentBean); |
104 | if (null != studentBean) { | 104 | if (null != studentBean) { |
105 | String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); | 105 | String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); |
106 | String schoolName = userDao.getSchoolName(studentBean.getSchool_id() + ""); | 106 | String schoolName = userDao.getSchoolName(studentBean.getSchool_id() + ""); |
cloud/haikangface/src/main/resources/application.yaml
@@ -38,8 +38,8 @@ eureka: | @@ -38,8 +38,8 @@ eureka: | ||
38 | lease-renewal-interval-in-seconds: 10 | 38 | lease-renewal-interval-in-seconds: 10 |
39 | client: | 39 | client: |
40 | service-url: | 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 | mybatis: | 44 | mybatis: |
45 | campus: | 45 | campus: |
cloud/pom.xml
@@ -44,6 +44,7 @@ | @@ -44,6 +44,7 @@ | ||
44 | <!-- <module>zkAttendance</module>--> | 44 | <!-- <module>zkAttendance</module>--> |
45 | <module>user_search</module> | 45 | <module>user_search</module> |
46 | <module>fIle-center</module> | 46 | <module>fIle-center</module> |
47 | + <module>RibbonConsume</module> | ||
47 | </modules> | 48 | </modules> |
48 | 49 | ||
49 | <dependencies> | 50 | <dependencies> |
cloud/server1/src/main/resources/application.yaml
@@ -4,7 +4,7 @@ eureka: | @@ -4,7 +4,7 @@ eureka: | ||
4 | lease-renewal-interval-in-seconds: 10 | 4 | lease-renewal-interval-in-seconds: 10 |
5 | lease-expiration-duration-in-seconds: 60 | 5 | lease-expiration-duration-in-seconds: 60 |
6 | hostname: localhost | 6 | hostname: localhost |
7 | - prefer-ip-address: true | 7 | + prefer-ip-address: false |
8 | server: | 8 | server: |
9 | #是否开启保护模式 | 9 | #是否开启保护模式 |
10 | enable-self-preservation: false #关闭服务器自我保护,客户端心跳检测15分钟内错误达到80%服务会保护,导致别人还认为是好用的服务 | 10 | enable-self-preservation: false #关闭服务器自我保护,客户端心跳检测15分钟内错误达到80%服务会保护,导致别人还认为是好用的服务 |
cloud/server2/src/main/resources/application.yaml
@@ -13,7 +13,7 @@ eureka: | @@ -13,7 +13,7 @@ eureka: | ||
13 | lease-renewal-interval-in-seconds: 10 | 13 | lease-renewal-interval-in-seconds: 10 |
14 | lease-expiration-duration-in-seconds: 60 | 14 | lease-expiration-duration-in-seconds: 60 |
15 | hostname: localhost | 15 | hostname: localhost |
16 | - prefer-ip-address: true | 16 | + prefer-ip-address: false |
17 | server: | 17 | server: |
18 | #是否开启保护模式 | 18 | #是否开启保护模式 |
19 | enable-self-preservation: false #关闭服务器自我保护,客户端心跳检测15分钟内错误达到80%服务会保护,导致别人还认为是好用的服务 | 19 | enable-self-preservation: false #关闭服务器自我保护,客户端心跳检测15分钟内错误达到80%服务会保护,导致别人还认为是好用的服务 |