Commit 3009e2ac365fd61592b29348170bb183d2ef47db
1 parent
cd07eb23
Exists in
master
权限模板增加
Showing
26 changed files
with
768 additions
and
236 deletions
Show diff stats
cloud/dahua/src/main/java/com/example/dahua/bean/StudentBean.java
@@ -39,7 +39,7 @@ public class StudentBean implements Serializable { | @@ -39,7 +39,7 @@ public class StudentBean implements Serializable { | ||
39 | 39 | ||
40 | private String Face; | 40 | private String Face; |
41 | 41 | ||
42 | - private String StudentCode; | 42 | +// private String StudentCode; |
43 | 43 | ||
44 | private String student_num; | 44 | private String student_num; |
45 | 45 | ||
@@ -201,13 +201,13 @@ public class StudentBean implements Serializable { | @@ -201,13 +201,13 @@ public class StudentBean implements Serializable { | ||
201 | Face = face; | 201 | Face = face; |
202 | } | 202 | } |
203 | 203 | ||
204 | - public String getStudentCode() { | ||
205 | - return StudentCode; | ||
206 | - } | ||
207 | - | ||
208 | - public void setStudentCode(String studentCode) { | ||
209 | - StudentCode = studentCode; | ||
210 | - } | 204 | +// public String getStudentCode() { |
205 | +// return StudentCode; | ||
206 | +// } | ||
207 | +// | ||
208 | +// public void setStudentCode(String studentCode) { | ||
209 | +// StudentCode = studentCode; | ||
210 | +// } | ||
211 | 211 | ||
212 | public long getID() { | 212 | public long getID() { |
213 | return ID; | 213 | return ID; |
@@ -245,7 +245,7 @@ public class StudentBean implements Serializable { | @@ -245,7 +245,7 @@ public class StudentBean implements Serializable { | ||
245 | ", AddTime=" + AddTime + | 245 | ", AddTime=" + AddTime + |
246 | ", Sex=" + Sex + | 246 | ", Sex=" + Sex + |
247 | ", Face='" + Face + '\'' + | 247 | ", Face='" + Face + '\'' + |
248 | - ", StudentCode='" + StudentCode + '' + | 248 | +// ", StudentCode='" + StudentCode + '' + |
249 | ", student_num='" + student_num + '\'' + | 249 | ", student_num='" + student_num + '\'' + |
250 | ", student_id='" + student_id + '\'' + | 250 | ", student_id='" + student_id + '\'' + |
251 | ", user_id='" + user_id + '\'' + | 251 | ", user_id='" + user_id + '\'' + |
cloud/dahua/src/main/java/com/example/dahua/control/FaceUnifyController.java
@@ -44,4 +44,12 @@ public class FaceUnifyController { | @@ -44,4 +44,12 @@ public class FaceUnifyController { | ||
44 | return JSON.toJSONString(permissFaceService.getPermissions(schoolId)); | 44 | return JSON.toJSONString(permissFaceService.getPermissions(schoolId)); |
45 | } | 45 | } |
46 | 46 | ||
47 | + | ||
48 | + @RequestMapping(value = "addFace",method = RequestMethod.POST) | ||
49 | + @ApiOperation("上传学生/老师人脸") | ||
50 | + public String addFace(@RequestParam("imgUrl")String imgUrl,@RequestParam("userId")String userId) throws UnsupportedEncodingException { | ||
51 | + return JSON.toJSONString(permissFaceService.addFace(imgUrl,userId)); | ||
52 | + } | ||
53 | + | ||
54 | + | ||
47 | } | 55 | } |
cloud/dahua/src/main/java/com/example/dahua/control/UserControl.java
@@ -115,186 +115,15 @@ public class UserControl { | @@ -115,186 +115,15 @@ public class UserControl { | ||
115 | @RequestMapping(value = "checkFace", method = RequestMethod.GET) | 115 | @RequestMapping(value = "checkFace", method = RequestMethod.GET) |
116 | @ApiOperation("在线活体检测") | 116 | @ApiOperation("在线活体检测") |
117 | public boolean checkFace(@RequestParam("url") String httpurl) { | 117 | public boolean checkFace(@RequestParam("url") String httpurl) { |
118 | - // 请求url | ||
119 | - String url = "https://aip.baidubce.com/rest/2.0/face/v3/faceverify"; | ||
120 | - try { | ||
121 | - | ||
122 | - List list = new ArrayList(); | ||
123 | - Map<String, String> map = new HashMap<>(); | ||
124 | - String image_type = ""; | ||
125 | - String imgFilePath = httpurl; | ||
126 | - File target = new File("./huoti/"); | ||
127 | - if (!target.exists()) target.mkdirs(); | ||
128 | - File target1 = new File(target.getAbsolutePath(), new File(httpurl).getName()); | ||
129 | - if (httpurl.startsWith("http")) image_type = "URL"; | ||
130 | - else { | ||
131 | - CompressPic.CompressPic(httpurl, target1.getAbsolutePath(), "");//压缩后的图片 | ||
132 | - image_type = "BASE64"; | ||
133 | - httpurl = Base64Util.encode(image2byte(target1.getAbsolutePath())); | ||
134 | - } | ||
135 | - map.put("image", httpurl); | ||
136 | - map.put("image_type", image_type); | ||
137 | -// map.put("face_field",""); | ||
138 | -// map.put("option","GATE"); | ||
139 | - list.add(map); | ||
140 | - String param = GsonUtils.toJson(list); | ||
141 | - // 注意这里仅为了简化编码每一次请求都去获取access_token,线上环境access_token有过期时间, 客户端可自行缓存,过期后重新获取。 | ||
142 | - String accessToken = getAuth(); | ||
143 | - | ||
144 | - String result1 = HttpUtil.post(url, accessToken, "application/json", param); | ||
145 | - JSONObject jsonObject = new JSONObject(result1); | ||
146 | - String error_msg = jsonObject.optString("error_msg"); | ||
147 | - JSONObject result = jsonObject.optJSONObject("result"); | ||
148 | - if (error_msg.equals("SUCCESS")) { | ||
149 | - double face_liveness = result.optDouble("face_liveness", 0.00);//活体分数值 | ||
150 | - JSONArray face_list = result.optJSONArray("face_list"); | ||
151 | - JSONObject location = face_list.optJSONObject(0).optJSONObject("location"); | ||
152 | - double rotation = location.optDouble("rotation", 0.0);//竖直方向旋转角度 | ||
153 | - System.out.println(" face_liveness:" + face_liveness); | ||
154 | - if (face_liveness > 0.4) { | ||
155 | - int angel = 0; | ||
156 | - if (45 < rotation && rotation < 135) {//右向横图,需要旋转270度 | ||
157 | - System.out.println("旋转270度"); | ||
158 | - angel = 270; | ||
159 | - } else if (rotation > -135 && rotation < -45) {//左向横图,需要旋转90度 | ||
160 | - System.out.println("旋转90度"); | ||
161 | - angel = 90; | ||
162 | - } else if (rotation >= -180 && rotation <= -135 || rotation >= 135 && rotation <= 180) {//倒向图片,需要旋转180度 | ||
163 | - System.out.println("旋转180度"); | ||
164 | - angel = 180; | ||
165 | - } | ||
166 | - System.out.println("图片检验成功"); | ||
167 | - FileUtils.getInstance().writeLogs("检测成功:" + imgFilePath, FileUtils.checkSuc); | ||
168 | - //E:\wwwhtdocs\SmartCampus\face17e50\School | ||
169 | - //http://campus.myjxt.com//face17e5/School861/Student/GBZX20171134.jpg | ||
170 | - //F:\wwwroot\smartcampus\face17e5 | ||
171 | -// imgFilePath =httpurl.replace("http://campus.myjxt.com","E:\\wwwhtdocs\\SmartCampus"); | ||
172 | -// imgFilePath = httpurl.replace("http://60.190.202.57:1000","F:\\wwwroot\\smartcampus"); | ||
173 | -// System.out.println("图片是否存在:" + imgFilePath); | ||
174 | - if (angel != 0) | ||
175 | - ImageUtils.rotatePhonePhoto(imgFilePath, angel); | ||
176 | - return true; | ||
177 | - } else { | ||
178 | - FileUtils.getInstance().writeLogs("检测失败,活体分数:" + face_liveness + " " + imgFilePath, FileUtils.checkFail); | ||
179 | - System.out.println("图片不合格" + imgFilePath); | ||
180 | - deleteImgFile(imgFilePath); | ||
181 | - return false; | ||
182 | - } | ||
183 | - } else { | ||
184 | - System.out.println("检测失败"); | ||
185 | - FileUtils.getInstance().writeLogs("检测失败:" + error_msg + imgFilePath, FileUtils.checkFail); | ||
186 | - deleteImgFile(imgFilePath); | ||
187 | - return false; | ||
188 | - } | ||
189 | - } catch (Exception e) { | ||
190 | - e.printStackTrace(); | ||
191 | - } | ||
192 | - return true; | ||
193 | - } | ||
194 | 118 | ||
195 | - private boolean deleteImgFile(String imgFilePath) { | ||
196 | - imgFilePath = imgFilePath.replace("http://campus.myjxt.com", "E:\\wwwhtdocs\\SmartCampus"); | ||
197 | - File file = new File(imgFilePath); | ||
198 | - if (file.exists()) { | ||
199 | - return file.delete(); | ||
200 | - } | ||
201 | - return false; | ||
202 | - } | 119 | + return BaiduUtils.getBaiduUtils().checkImg(httpurl); |
203 | 120 | ||
204 | - //图片到byte数组 | ||
205 | - public byte[] image2byte(String path) { | ||
206 | - byte[] data = null; | ||
207 | - FileImageInputStream input = null; | ||
208 | - try { | ||
209 | - input = new FileImageInputStream(new File(path)); | ||
210 | - ByteArrayOutputStream output = new ByteArrayOutputStream(); | ||
211 | - byte[] buf = new byte[1024]; | ||
212 | - int numBytesRead = 0; | ||
213 | - while ((numBytesRead = input.read(buf)) != -1) { | ||
214 | - output.write(buf, 0, numBytesRead); | ||
215 | - } | ||
216 | - data = output.toByteArray(); | ||
217 | - output.close(); | ||
218 | - input.close(); | ||
219 | - } catch (FileNotFoundException ex1) { | ||
220 | - ex1.printStackTrace(); | ||
221 | - } catch (IOException ex1) { | ||
222 | - ex1.printStackTrace(); | ||
223 | - } | ||
224 | - return data; | ||
225 | } | 121 | } |
226 | 122 | ||
227 | - /** | ||
228 | - * 获取权限token | ||
229 | - * | ||
230 | - * @return 返回示例: | ||
231 | - * { | ||
232 | - * "access_token": "24.460da4889caad24cccdb1fea17221975.2592000.1491995545.282335-1234567", | ||
233 | - * "expires_in": 2592000 | ||
234 | - * } | ||
235 | - */ | ||
236 | - public String getAuth() { | ||
237 | - // 官网获取的 API Key 更新为你注册的 | ||
238 | - String clientId = "u6rV4YxRZmwzKj56N0DCW8eO"; | ||
239 | - // 官网获取的 Secret Key 更新为你注册的 | ||
240 | - String clientSecret = "Krp3KhmIBdnNEsRa1LavMHuZl0KhQGVm"; | ||
241 | - return getAuth(clientId, clientSecret); | ||
242 | - } | ||
243 | 123 | ||
244 | - /** | ||
245 | - * 获取API访问token | ||
246 | - * 该token有一定的有效期,需要自行管理,当失效时需重新获取. | ||
247 | - * | ||
248 | - * @param ak - 百度云官网获取的 API Key | ||
249 | - * @param sk - 百度云官网获取的 Securet Key | ||
250 | - * @return assess_token 示例: | ||
251 | - * "24.460da4889caad24cccdb1fea17221975.2592000.1491995545.282335-1234567" | ||
252 | - */ | ||
253 | - public static String getAuth(String ak, String sk) { | ||
254 | - // 获取token地址 | ||
255 | - String authHost = "https://aip.baidubce.com/oauth/2.0/token?"; | ||
256 | - String getAccessTokenUrl = authHost | ||
257 | - // 1. grant_type为固定参数 | ||
258 | - + "grant_type=client_credentials" | ||
259 | - // 2. 官网获取的 API Key | ||
260 | - + "&client_id=" + ak | ||
261 | - // 3. 官网获取的 Secret Key | ||
262 | - + "&client_secret=" + sk; | ||
263 | - try { | ||
264 | - URL realUrl = new URL(getAccessTokenUrl); | ||
265 | - // 打开和URL之间的连接 | ||
266 | - HttpURLConnection connection = (HttpURLConnection) realUrl.openConnection(); | ||
267 | - connection.setRequestMethod("GET"); | ||
268 | - connection.connect(); | ||
269 | - // 获取所有响应头字段 | ||
270 | - Map<String, List<String>> map = connection.getHeaderFields(); | ||
271 | - // 遍历所有的响应头字段 | ||
272 | -// for (String key : map.keySet()) { | ||
273 | -// System.err.println(key + "--->" + map.get(key)); | ||
274 | -// } | ||
275 | - // 定义 BufferedReader输入流来读取URL的响应 | ||
276 | - BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream())); | ||
277 | - String result = ""; | ||
278 | - String line; | ||
279 | - while ((line = in.readLine()) != null) { | ||
280 | - result += line; | ||
281 | - } | ||
282 | - /** | ||
283 | - * 返回结果示例 | ||
284 | - */ | ||
285 | -// System.err.println("result:" + result); | ||
286 | - JSONObject jsonObject = new JSONObject(result); | ||
287 | - String access_token = jsonObject.getString("access_token"); | ||
288 | - return access_token; | ||
289 | - } catch (Exception e) { | ||
290 | - System.err.printf("获取token失败!"); | ||
291 | - e.printStackTrace(System.err); | ||
292 | - } | ||
293 | - return null; | ||
294 | - } | ||
295 | 124 | ||
296 | 125 | ||
297 | - @RequestMapping(value = "tranpic", method = RequestMethod.GET) | 126 | + /*@RequestMapping(value = "tranpic", method = RequestMethod.GET) |
298 | @ApiOperation("旋转图片") | 127 | @ApiOperation("旋转图片") |
299 | public void tranPic(@RequestParam("path") String httpurl) { | 128 | public void tranPic(@RequestParam("path") String httpurl) { |
300 | // 请求url | 129 | // 请求url |
@@ -366,7 +195,7 @@ public class UserControl { | @@ -366,7 +195,7 @@ public class UserControl { | ||
366 | } catch (Exception e) { | 195 | } catch (Exception e) { |
367 | e.printStackTrace(); | 196 | e.printStackTrace(); |
368 | } | 197 | } |
369 | - } | 198 | + }*/ |
370 | 199 | ||
371 | // @RequestMapping(value = "deleteFace", method = RequestMethod.GET) | 200 | // @RequestMapping(value = "deleteFace", method = RequestMethod.GET) |
372 | // @ApiOperation("删除人脸") | 201 | // @ApiOperation("删除人脸") |
@@ -377,7 +206,7 @@ public class UserControl { | @@ -377,7 +206,7 @@ public class UserControl { | ||
377 | // } | 206 | // } |
378 | 207 | ||
379 | 208 | ||
380 | - @RequestMapping(value = "FaceSearch", method = RequestMethod.POST) | 209 | + /* @RequestMapping(value = "FaceSearch", method = RequestMethod.POST) |
381 | @ApiOperation("人脸搜索") | 210 | @ApiOperation("人脸搜索") |
382 | public String FaceSearch(@RequestPart("file") MultipartFile file) { | 211 | public String FaceSearch(@RequestPart("file") MultipartFile file) { |
383 | 212 | ||
@@ -401,7 +230,7 @@ public class UserControl { | @@ -401,7 +230,7 @@ public class UserControl { | ||
401 | } | 230 | } |
402 | return null; | 231 | return null; |
403 | 232 | ||
404 | - } | 233 | + }*/ |
405 | 234 | ||
406 | 235 | ||
407 | @RequestMapping(value = "movePic", method = RequestMethod.GET) | 236 | @RequestMapping(value = "movePic", method = RequestMethod.GET) |
@@ -451,7 +280,7 @@ public class UserControl { | @@ -451,7 +280,7 @@ public class UserControl { | ||
451 | 280 | ||
452 | } | 281 | } |
453 | 282 | ||
454 | - @RequestMapping(value = "translatePic", method = RequestMethod.POST) | 283 | + /* @RequestMapping(value = "translatePic", method = RequestMethod.POST) |
455 | @ApiOperation("图片转文字") | 284 | @ApiOperation("图片转文字") |
456 | public String translatePic(@RequestPart MultipartFile file) { | 285 | public String translatePic(@RequestPart MultipartFile file) { |
457 | try { | 286 | try { |
@@ -479,13 +308,13 @@ public class UserControl { | @@ -479,13 +308,13 @@ public class UserControl { | ||
479 | e.printStackTrace(); | 308 | e.printStackTrace(); |
480 | } | 309 | } |
481 | return "解析失败"; | 310 | return "解析失败"; |
482 | - } | 311 | + }*/ |
483 | 312 | ||
484 | 313 | ||
485 | private String url = "https://aip.baidubce.com/rest/2.0/ocr/v1/general_basic?access_token=" + AuthService.getAuth(); | 314 | private String url = "https://aip.baidubce.com/rest/2.0/ocr/v1/general_basic?access_token=" + AuthService.getAuth(); |
486 | // + AuthService.getAuth(); | 315 | // + AuthService.getAuth(); |
487 | 316 | ||
488 | - private String getAnswer(String imgUrl, int type) { | 317 | + /* private String getAnswer(String imgUrl, int type) { |
489 | RestTemplate restTemplate = new RestTemplate(); | 318 | RestTemplate restTemplate = new RestTemplate(); |
490 | 319 | ||
491 | HttpHeaders headers = new HttpHeaders(); | 320 | HttpHeaders headers = new HttpHeaders(); |
@@ -521,6 +350,6 @@ public class UserControl { | @@ -521,6 +350,6 @@ public class UserControl { | ||
521 | System.out.println("result:" + stringBuilder.toString()); | 350 | System.out.println("result:" + stringBuilder.toString()); |
522 | } | 351 | } |
523 | return stringBuilder.toString().equals("") ? "" : stringBuilder.toString(); | 352 | return stringBuilder.toString().equals("") ? "" : stringBuilder.toString(); |
524 | - } | 353 | + }*/ |
525 | 354 | ||
526 | } | 355 | } |
cloud/dahua/src/main/java/com/example/dahua/dao/UserDao.java
@@ -23,6 +23,9 @@ public interface UserDao { | @@ -23,6 +23,9 @@ public interface UserDao { | ||
23 | @Select(" select Top(1)* from SZ_V_School_Student where school_id = #{school_id} and studentcode = #{studentcode}") | 23 | @Select(" select Top(1)* from SZ_V_School_Student where school_id = #{school_id} and studentcode = #{studentcode}") |
24 | UserInfoBean getUserInfo(@Param("school_id") String school_id, @Param("studentcode") String studentcode); | 24 | UserInfoBean getUserInfo(@Param("school_id") String school_id, @Param("studentcode") String studentcode); |
25 | 25 | ||
26 | + @Select("select * from SZ_V_School_Student where school_id = 1066 and class_id between 78506 and 78514") | ||
27 | + List<UserInfoBean> getStuUserInfos(); | ||
28 | + | ||
26 | @Select(" select Top(1)* from SZ_V_School_Teacher where school_id = #{school_id} and num = #{num}") | 29 | @Select(" select Top(1)* from SZ_V_School_Teacher where school_id = #{school_id} and num = #{num}") |
27 | TeacherBean getTeacher(@Param("school_id") String school_id, @Param("num") String num); | 30 | TeacherBean getTeacher(@Param("school_id") String school_id, @Param("num") String num); |
28 | 31 | ||
@@ -88,6 +91,9 @@ public interface UserDao { | @@ -88,6 +91,9 @@ public interface UserDao { | ||
88 | @Select("select * from SZ_Attendance where clint_type = #{clint_type} and school_id = #{school_id}") | 91 | @Select("select * from SZ_Attendance where clint_type = #{clint_type} and school_id = #{school_id}") |
89 | List<AttendanceBean> selectDeviceWithschool_id(@Param("clint_type") String clint_type, @Param("school_id") String school_id); | 92 | List<AttendanceBean> selectDeviceWithschool_id(@Param("clint_type") String clint_type, @Param("school_id") String school_id); |
90 | 93 | ||
94 | + @Select("select * from SZ_Attendance where school_id = #{school_id}") | ||
95 | + List<AttendanceBean> getAllDevices(@Param("school_id") String school_id); | ||
96 | + | ||
91 | @Select("select * from SZ_V_School_Student where school_id = #{school_id} and len(photo)>0 and len(student_num)>0") | 97 | @Select("select * from SZ_V_School_Student where school_id = #{school_id} and len(photo)>0 and len(student_num)>0") |
92 | List<StudentBean> getAllStudentsWithSchoolId(@Param("school_id") String school_id); | 98 | List<StudentBean> getAllStudentsWithSchoolId(@Param("school_id") String school_id); |
93 | 99 | ||
@@ -118,4 +124,13 @@ public interface UserDao { | @@ -118,4 +124,13 @@ public interface UserDao { | ||
118 | 124 | ||
119 | @Select(" select * from SZ_V_School_Teacher where school_id = #{school_id}") | 125 | @Select(" select * from SZ_V_School_Teacher where school_id = #{school_id}") |
120 | List<TeacherBean> getTeachers(@Param("school_id") String school_id); | 126 | List<TeacherBean> getTeachers(@Param("school_id") String school_id); |
127 | + | ||
128 | + @Select("select * from SZ_User where user_id =#{userId} and state = 1") | ||
129 | + void getUserWidthUserId(@Param("userId") String userId); | ||
130 | + | ||
131 | + @Select("select * from SZ_V_School_Student where user_id = #{userId}") | ||
132 | + List<StudentBean> getStudentWithUserId(@Param("userId")String userId); | ||
133 | + | ||
134 | + @Select("select * from SZ_V_School_Teacher where user_id = #{userId}") | ||
135 | + List<TeacherBean> getTeaWithUserId(@Param("userId")String userId); | ||
121 | } | 136 | } |
cloud/dahua/src/main/java/com/example/dahua/service/PermissFaceService.java
@@ -16,4 +16,5 @@ public interface PermissFaceService { | @@ -16,4 +16,5 @@ public interface PermissFaceService { | ||
16 | public ResponseBeanList<PermissionFaceBean> getPermissionDetail(int permissionId); | 16 | public ResponseBeanList<PermissionFaceBean> getPermissionDetail(int permissionId); |
17 | 17 | ||
18 | 18 | ||
19 | + ResponseBean<String> addFace(String imgUrl, String userId); | ||
19 | } | 20 | } |
cloud/dahua/src/main/java/com/example/dahua/service/imp/PermissFaceServiceImp.java
@@ -5,12 +5,22 @@ import com.example.dahua.bean.*; | @@ -5,12 +5,22 @@ import com.example.dahua.bean.*; | ||
5 | import com.example.dahua.dao.PermissionFaceDao; | 5 | import com.example.dahua.dao.PermissionFaceDao; |
6 | import com.example.dahua.dao.UserDao; | 6 | import com.example.dahua.dao.UserDao; |
7 | import com.example.dahua.service.PermissFaceService; | 7 | import com.example.dahua.service.PermissFaceService; |
8 | +import com.example.dahua.utils.BaiduUtils; | ||
9 | +import com.example.dahua.utils.HttpUtil; | ||
8 | import com.example.dahua.utils.HttpUtils; | 10 | import com.example.dahua.utils.HttpUtils; |
9 | import lombok.extern.slf4j.Slf4j; | 11 | import lombok.extern.slf4j.Slf4j; |
10 | import org.springframework.beans.factory.annotation.Autowired; | 12 | import org.springframework.beans.factory.annotation.Autowired; |
13 | +import org.springframework.http.HttpMethod; | ||
14 | +import org.springframework.http.ResponseEntity; | ||
11 | import org.springframework.stereotype.Service; | 15 | import org.springframework.stereotype.Service; |
12 | import org.springframework.util.StringUtils; | 16 | import org.springframework.util.StringUtils; |
17 | +import org.springframework.web.client.RestTemplate; | ||
13 | 18 | ||
19 | +import java.io.File; | ||
20 | +import java.io.FileOutputStream; | ||
21 | +import java.io.IOException; | ||
22 | +import java.net.URI; | ||
23 | +import java.net.URISyntaxException; | ||
14 | import java.util.List; | 24 | import java.util.List; |
15 | 25 | ||
16 | @Slf4j | 26 | @Slf4j |
@@ -114,8 +124,6 @@ public class PermissFaceServiceImp implements PermissFaceService { | @@ -114,8 +124,6 @@ public class PermissFaceServiceImp implements PermissFaceService { | ||
114 | } | 124 | } |
115 | 125 | ||
116 | 126 | ||
117 | - | ||
118 | - | ||
119 | @Override | 127 | @Override |
120 | public ResponseBeanList<PermissionFaceBean> getPermissions(int schoolId) { | 128 | public ResponseBeanList<PermissionFaceBean> getPermissions(int schoolId) { |
121 | ResponseBeanList responseBeanList = new ResponseBeanList(); | 129 | ResponseBeanList responseBeanList = new ResponseBeanList(); |
@@ -149,4 +157,93 @@ public class PermissFaceServiceImp implements PermissFaceService { | @@ -149,4 +157,93 @@ public class PermissFaceServiceImp implements PermissFaceService { | ||
149 | } | 157 | } |
150 | return responseBeanList; | 158 | return responseBeanList; |
151 | } | 159 | } |
160 | + | ||
161 | + @Override | ||
162 | + public ResponseBean<String> addFace(String imgUrl, String userId) { | ||
163 | + | ||
164 | + RestTemplate restTemplate = new RestTemplate(); | ||
165 | + try { | ||
166 | + URI uri = new URI(imgUrl); | ||
167 | + ResponseEntity<byte[]> responseEntity = restTemplate.exchange(uri, HttpMethod.GET, null, byte[].class); | ||
168 | + | ||
169 | + byte[] bytes = responseEntity.getBody(); | ||
170 | + | ||
171 | + String savePath = "./imgsave/"; | ||
172 | + File saveFile = new File(savePath); | ||
173 | + if (!saveFile.exists()) saveFile.mkdirs(); | ||
174 | + File saveImgFile = new File(savePath, System.currentTimeMillis() + ".jpg"); | ||
175 | + if (!saveImgFile.exists()) saveImgFile.createNewFile(); | ||
176 | + FileOutputStream fileOutputStream = new FileOutputStream(saveImgFile); | ||
177 | + | ||
178 | + fileOutputStream.write(bytes); | ||
179 | + | ||
180 | + //检测图片 | ||
181 | + BaiduUtils.getBaiduUtils().checkImg(saveImgFile.getAbsolutePath()); | ||
182 | + | ||
183 | + List<StudentBean> studentBeans = userDao.getStudentWithUserId(userId); | ||
184 | + | ||
185 | + if (null != studentBeans && studentBeans.size() > 0) { | ||
186 | + log.error("学生下发"); | ||
187 | + for (int i = 0; i < studentBeans.size(); i++) { | ||
188 | + StudentBean studentBean = studentBeans.get(i); | ||
189 | + int schoolId = studentBean.getSchool_id(); | ||
190 | + uploadImgs(saveImgFile, schoolId + "", studentBean.getStudentcode(), 2, studentBean.getCard(), studentBean.getName()); | ||
191 | + } | ||
192 | + | ||
193 | + } else { | ||
194 | + List<TeacherBean> teacherBeans = userDao.getTeaWithUserId(userId); | ||
195 | +log.error("教师下发"); | ||
196 | + if (null != teacherBeans && teacherBeans.size() > 0) { | ||
197 | + | ||
198 | + for (int i = 0; i < teacherBeans.size(); i++) { | ||
199 | + TeacherBean teacherBean = teacherBeans.get(i); | ||
200 | + | ||
201 | + String schoolId = teacherBean.getSchool_id(); | ||
202 | + uploadImgs(saveImgFile, schoolId, teacherBean.getNum(), 1, teacherBean.getTeacher_num(), teacherBean.getName()); | ||
203 | + | ||
204 | + } | ||
205 | + | ||
206 | + } | ||
207 | + | ||
208 | + } | ||
209 | + | ||
210 | + fileOutputStream.close(); | ||
211 | + } catch (URISyntaxException | IOException e) { | ||
212 | + e.printStackTrace(); | ||
213 | + } | ||
214 | + | ||
215 | +// userDao.getUserWidthUserId(userId); | ||
216 | + | ||
217 | +// HttpUtils.uploadImgs() | ||
218 | + | ||
219 | + ResponseBean responseBean = new ResponseBean(); | ||
220 | + | ||
221 | + responseBean.setData(1); | ||
222 | + responseBean.setMessage("下发成功"); | ||
223 | + responseBean.setData(true); | ||
224 | + | ||
225 | + return responseBean; | ||
226 | + } | ||
227 | + | ||
228 | + private void uploadImgs(File saveImgFile, String schoolId, String studentcode, int userType, String card, String name) { | ||
229 | + List<AttendanceBean> attendanceBeanList = userDao.getAllDevices(schoolId + ""); | ||
230 | + if (null != attendanceBeanList && attendanceBeanList.size() > 0) | ||
231 | + for (int i = 0; i < attendanceBeanList.size(); i++) { | ||
232 | + AttendanceBean attendanceBean = attendanceBeanList.get(i); | ||
233 | + | ||
234 | + String clintType = attendanceBean.getClint_type(); | ||
235 | + //根据设备类型上传人脸 | ||
236 | + log.error("设备:{}",clintType); | ||
237 | + if (clintType.equals("18") || clintType.equals("28")) { | ||
238 | + HttpUtils.uploadImg2HK(saveImgFile.getAbsolutePath(), card, name, attendanceBean.getClint_id(), String.valueOf(userType)); | ||
239 | + | ||
240 | + } else if (clintType.equals("22") || clintType.equals("29")) { | ||
241 | + HttpUtils.uploadImgs(saveImgFile, schoolId, studentcode | ||
242 | + , clintType, userType); | ||
243 | + } | ||
244 | + | ||
245 | + } | ||
246 | + | ||
247 | + | ||
248 | + } | ||
152 | } | 249 | } |
cloud/dahua/src/main/java/com/example/dahua/utils/BaiduUtils.java
0 → 100644
@@ -0,0 +1,211 @@ | @@ -0,0 +1,211 @@ | ||
1 | +package com.example.dahua.utils; | ||
2 | + | ||
3 | +import com.example.dahua.async.ImageUtils; | ||
4 | +import com.example.dahua.lib.CompressPic; | ||
5 | +import org.json.JSONArray; | ||
6 | +import org.json.JSONObject; | ||
7 | + | ||
8 | +import javax.imageio.stream.FileImageInputStream; | ||
9 | +import java.io.*; | ||
10 | +import java.net.HttpURLConnection; | ||
11 | +import java.net.URL; | ||
12 | +import java.util.ArrayList; | ||
13 | +import java.util.HashMap; | ||
14 | +import java.util.List; | ||
15 | +import java.util.Map; | ||
16 | + | ||
17 | +public class BaiduUtils { | ||
18 | + | ||
19 | + private static BaiduUtils baiduUtils; | ||
20 | + | ||
21 | + public static BaiduUtils getBaiduUtils(){ | ||
22 | + | ||
23 | + if (null==baiduUtils){ | ||
24 | + synchronized (BaiduUtils.class){ | ||
25 | + if (null==baiduUtils)baiduUtils=new BaiduUtils(); | ||
26 | + } | ||
27 | + } | ||
28 | + return baiduUtils; | ||
29 | + } | ||
30 | + | ||
31 | + | ||
32 | + public boolean checkImg(String httpurl){ | ||
33 | + // 请求url | ||
34 | + String url = "https://aip.baidubce.com/rest/2.0/face/v3/faceverify"; | ||
35 | + try { | ||
36 | + | ||
37 | + List list = new ArrayList(); | ||
38 | + Map<String, String> map = new HashMap<>(); | ||
39 | + String image_type = ""; | ||
40 | + String imgFilePath = httpurl; | ||
41 | + File target = new File("./huoti/"); | ||
42 | + if (!target.exists()) target.mkdirs(); | ||
43 | + File target1 = new File(target.getAbsolutePath(), new File(httpurl).getName()); | ||
44 | + if (httpurl.startsWith("http")) image_type = "URL"; | ||
45 | + else { | ||
46 | + CompressPic.CompressPic(httpurl, target1.getAbsolutePath(), "");//压缩后的图片 | ||
47 | + image_type = "BASE64"; | ||
48 | + httpurl = Base64Util.encode(image2byte(target1.getAbsolutePath())); | ||
49 | + } | ||
50 | + map.put("image", httpurl); | ||
51 | + map.put("image_type", image_type); | ||
52 | +// map.put("face_field",""); | ||
53 | +// map.put("option","GATE"); | ||
54 | + list.add(map); | ||
55 | + String param = GsonUtils.toJson(list); | ||
56 | + // 注意这里仅为了简化编码每一次请求都去获取access_token,线上环境access_token有过期时间, 客户端可自行缓存,过期后重新获取。 | ||
57 | + String accessToken = getAuth(); | ||
58 | + | ||
59 | + String result1 = HttpUtil.post(url, accessToken, "application/json", param); | ||
60 | + JSONObject jsonObject = new JSONObject(result1); | ||
61 | + String error_msg = jsonObject.optString("error_msg"); | ||
62 | + JSONObject result = jsonObject.optJSONObject("result"); | ||
63 | + if (error_msg.equals("SUCCESS")) { | ||
64 | + double face_liveness = result.optDouble("face_liveness", 0.00);//活体分数值 | ||
65 | + JSONArray face_list = result.optJSONArray("face_list"); | ||
66 | + JSONObject location = face_list.optJSONObject(0).optJSONObject("location"); | ||
67 | + double rotation = location.optDouble("rotation", 0.0);//竖直方向旋转角度 | ||
68 | + System.out.println(" face_liveness:" + face_liveness); | ||
69 | + if (face_liveness > 0.4) { | ||
70 | + int angel = 0; | ||
71 | + if (45 < rotation && rotation < 135) {//右向横图,需要旋转270度 | ||
72 | + System.out.println("旋转270度"); | ||
73 | + angel = 270; | ||
74 | + } else if (rotation > -135 && rotation < -45) {//左向横图,需要旋转90度 | ||
75 | + System.out.println("旋转90度"); | ||
76 | + angel = 90; | ||
77 | + } else if (rotation >= -180 && rotation <= -135 || rotation >= 135 && rotation <= 180) {//倒向图片,需要旋转180度 | ||
78 | + System.out.println("旋转180度"); | ||
79 | + angel = 180; | ||
80 | + } | ||
81 | + System.out.println("图片检验成功"); | ||
82 | + FileUtils.getInstance().writeLogs("检测成功:" + imgFilePath, FileUtils.checkSuc); | ||
83 | + //E:\wwwhtdocs\SmartCampus\face17e50\School | ||
84 | + //http://campus.myjxt.com//face17e5/School861/Student/GBZX20171134.jpg | ||
85 | + //F:\wwwroot\smartcampus\face17e5 | ||
86 | +// imgFilePath =httpurl.replace("http://campus.myjxt.com","E:\\wwwhtdocs\\SmartCampus"); | ||
87 | +// imgFilePath = httpurl.replace("http://60.190.202.57:1000","F:\\wwwroot\\smartcampus"); | ||
88 | +// System.out.println("图片是否存在:" + imgFilePath); | ||
89 | + if (angel != 0) | ||
90 | + ImageUtils.rotatePhonePhoto(imgFilePath, angel); | ||
91 | + return true; | ||
92 | + } else { | ||
93 | + FileUtils.getInstance().writeLogs("检测失败,活体分数:" + face_liveness + " " + imgFilePath, FileUtils.checkFail); | ||
94 | + System.out.println("图片不合格" + imgFilePath); | ||
95 | + deleteImgFile(imgFilePath); | ||
96 | + return false; | ||
97 | + } | ||
98 | + } else { | ||
99 | + System.out.println("检测失败"); | ||
100 | + FileUtils.getInstance().writeLogs("检测失败:" + error_msg + imgFilePath, FileUtils.checkFail); | ||
101 | + deleteImgFile(imgFilePath); | ||
102 | + return false; | ||
103 | + } | ||
104 | + } catch (Exception e) { | ||
105 | + e.printStackTrace(); | ||
106 | + } | ||
107 | + return true; | ||
108 | + } | ||
109 | + | ||
110 | + //图片到byte数组 | ||
111 | + public byte[] image2byte(String path) { | ||
112 | + byte[] data = null; | ||
113 | + FileImageInputStream input = null; | ||
114 | + try { | ||
115 | + input = new FileImageInputStream(new File(path)); | ||
116 | + ByteArrayOutputStream output = new ByteArrayOutputStream(); | ||
117 | + byte[] buf = new byte[1024]; | ||
118 | + int numBytesRead = 0; | ||
119 | + while ((numBytesRead = input.read(buf)) != -1) { | ||
120 | + output.write(buf, 0, numBytesRead); | ||
121 | + } | ||
122 | + data = output.toByteArray(); | ||
123 | + output.close(); | ||
124 | + input.close(); | ||
125 | + } catch (FileNotFoundException ex1) { | ||
126 | + ex1.printStackTrace(); | ||
127 | + } catch (IOException ex1) { | ||
128 | + ex1.printStackTrace(); | ||
129 | + } | ||
130 | + return data; | ||
131 | + } | ||
132 | + | ||
133 | + private boolean deleteImgFile(String imgFilePath) { | ||
134 | + imgFilePath = imgFilePath.replace("http://campus.myjxt.com", "E:\\wwwhtdocs\\SmartCampus"); | ||
135 | + File file = new File(imgFilePath); | ||
136 | + if (file.exists()) { | ||
137 | + return file.delete(); | ||
138 | + } | ||
139 | + return false; | ||
140 | + } | ||
141 | + | ||
142 | + /** | ||
143 | + * 获取权限token | ||
144 | + * | ||
145 | + * @return 返回示例: | ||
146 | + * { | ||
147 | + * "access_token": "24.460da4889caad24cccdb1fea17221975.2592000.1491995545.282335-1234567", | ||
148 | + * "expires_in": 2592000 | ||
149 | + * } | ||
150 | + */ | ||
151 | + public String getAuth() { | ||
152 | + // 官网获取的 API Key 更新为你注册的 | ||
153 | + String clientId = "u6rV4YxRZmwzKj56N0DCW8eO"; | ||
154 | + // 官网获取的 Secret Key 更新为你注册的 | ||
155 | + String clientSecret = "Krp3KhmIBdnNEsRa1LavMHuZl0KhQGVm"; | ||
156 | + return getAuth(clientId, clientSecret); | ||
157 | + } | ||
158 | + | ||
159 | + /** | ||
160 | + * 获取API访问token | ||
161 | + * 该token有一定的有效期,需要自行管理,当失效时需重新获取. | ||
162 | + * | ||
163 | + * @param ak - 百度云官网获取的 API Key | ||
164 | + * @param sk - 百度云官网获取的 Securet Key | ||
165 | + * @return assess_token 示例: | ||
166 | + * "24.460da4889caad24cccdb1fea17221975.2592000.1491995545.282335-1234567" | ||
167 | + */ | ||
168 | + public static String getAuth(String ak, String sk) { | ||
169 | + // 获取token地址 | ||
170 | + String authHost = "https://aip.baidubce.com/oauth/2.0/token?"; | ||
171 | + String getAccessTokenUrl = authHost | ||
172 | + // 1. grant_type为固定参数 | ||
173 | + + "grant_type=client_credentials" | ||
174 | + // 2. 官网获取的 API Key | ||
175 | + + "&client_id=" + ak | ||
176 | + // 3. 官网获取的 Secret Key | ||
177 | + + "&client_secret=" + sk; | ||
178 | + try { | ||
179 | + URL realUrl = new URL(getAccessTokenUrl); | ||
180 | + // 打开和URL之间的连接 | ||
181 | + HttpURLConnection connection = (HttpURLConnection) realUrl.openConnection(); | ||
182 | + connection.setRequestMethod("GET"); | ||
183 | + connection.connect(); | ||
184 | + // 获取所有响应头字段 | ||
185 | + Map<String, List<String>> map = connection.getHeaderFields(); | ||
186 | + // 遍历所有的响应头字段 | ||
187 | +// for (String key : map.keySet()) { | ||
188 | +// System.err.println(key + "--->" + map.get(key)); | ||
189 | +// } | ||
190 | + // 定义 BufferedReader输入流来读取URL的响应 | ||
191 | + BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream())); | ||
192 | + String result = ""; | ||
193 | + String line; | ||
194 | + while ((line = in.readLine()) != null) { | ||
195 | + result += line; | ||
196 | + } | ||
197 | + /** | ||
198 | + * 返回结果示例 | ||
199 | + */ | ||
200 | +// System.err.println("result:" + result); | ||
201 | + JSONObject jsonObject = new JSONObject(result); | ||
202 | + String access_token = jsonObject.getString("access_token"); | ||
203 | + return access_token; | ||
204 | + } catch (Exception e) { | ||
205 | + System.err.printf("获取token失败!"); | ||
206 | + e.printStackTrace(System.err); | ||
207 | + } | ||
208 | + return null; | ||
209 | + } | ||
210 | + | ||
211 | +} |
cloud/dahua/src/main/java/com/example/dahua/utils/HttpUtils.java
@@ -63,6 +63,20 @@ public class HttpUtils { | @@ -63,6 +63,20 @@ public class HttpUtils { | ||
63 | } | 63 | } |
64 | 64 | ||
65 | 65 | ||
66 | + public static String uploadImg2HK(String filePath,String card,String name,String deviceId,String userType){ | ||
67 | + | ||
68 | + String url = String.format("http://114.55.30.100:8089/facereco/sendCardAndImg1?filePath=%s&card=%s&name=%s&userType=%s&deviceId=%s", | ||
69 | + filePath,card,name,userType,deviceId); | ||
70 | + | ||
71 | + RestTemplate restTemplate = new RestTemplate(); | ||
72 | + | ||
73 | + ResponseEntity<String> responseEntity = restTemplate.getForEntity(url, String.class); | ||
74 | + | ||
75 | + System.out.println("responseEntity:" + responseEntity.getBody()); | ||
76 | + return responseEntity.getBody(); | ||
77 | + } | ||
78 | + | ||
79 | + | ||
66 | public static boolean imgsSend(String schoolId, int type) { | 80 | public static boolean imgsSend(String schoolId, int type) { |
67 | String url = "http://121.40.109.21:8991/file/imgsSend?schoolId=" + schoolId + "&type=" + type; | 81 | String url = "http://121.40.109.21:8991/file/imgsSend?schoolId=" + schoolId + "&type=" + type; |
68 | RestTemplate restTemplate = new RestTemplate(); | 82 | RestTemplate restTemplate = new RestTemplate(); |
cloud/dahua/src/test/java/com/example/dahua/DahuaApplicationTests.java
@@ -23,6 +23,7 @@ import org.springframework.http.ResponseEntity; | @@ -23,6 +23,7 @@ import org.springframework.http.ResponseEntity; | ||
23 | import org.springframework.test.context.junit4.SpringRunner; | 23 | import org.springframework.test.context.junit4.SpringRunner; |
24 | import org.springframework.web.client.RestTemplate; | 24 | import org.springframework.web.client.RestTemplate; |
25 | 25 | ||
26 | +import java.io.*; | ||
26 | import java.util.*; | 27 | import java.util.*; |
27 | 28 | ||
28 | @RunWith(SpringRunner.class) | 29 | @RunWith(SpringRunner.class) |
@@ -368,7 +369,7 @@ public class DahuaApplicationTests { | @@ -368,7 +369,7 @@ public class DahuaApplicationTests { | ||
368 | sendCards.setStartTime("2020-06-23 00:07:59"); | 369 | sendCards.setStartTime("2020-06-23 00:07:59"); |
369 | sendCards.setType("1"); | 370 | sendCards.setType("1"); |
370 | 371 | ||
371 | - Map<String, String> body = new HashMap<String,String>(); | 372 | + Map<String, String> body = new HashMap<String, String>(); |
372 | body.put("cardNo", teacherBean.getTeacher_num()); | 373 | body.put("cardNo", teacherBean.getTeacher_num()); |
373 | body.put("endTime", "2030-06-23T00:07:59"); | 374 | body.put("endTime", "2030-06-23T00:07:59"); |
374 | body.put("id", "5"); | 375 | body.put("id", "5"); |
@@ -413,7 +414,7 @@ public class DahuaApplicationTests { | @@ -413,7 +414,7 @@ public class DahuaApplicationTests { | ||
413 | for (int j = 0; j < deviceids.length; j++) { | 414 | for (int j = 0; j < deviceids.length; j++) { |
414 | String deviceId = deviceids[j]; | 415 | String deviceId = deviceids[j]; |
415 | 416 | ||
416 | - Map<String, String> body = new HashMap<String,String>(); | 417 | + Map<String, String> body = new HashMap<String, String>(); |
417 | body.put("cardNo", teacherBean.getStudent_num()); | 418 | body.put("cardNo", teacherBean.getStudent_num()); |
418 | body.put("id", "8"); | 419 | body.put("id", "8"); |
419 | body.put("sn", deviceId); | 420 | body.put("sn", deviceId); |
@@ -454,7 +455,7 @@ public class DahuaApplicationTests { | @@ -454,7 +455,7 @@ public class DahuaApplicationTests { | ||
454 | for (int j = 0; j < deviceids.length; j++) { | 455 | for (int j = 0; j < deviceids.length; j++) { |
455 | String deviceId = deviceids[j]; | 456 | String deviceId = deviceids[j]; |
456 | 457 | ||
457 | - Map<String, String> body = new HashMap<String,String>(); | 458 | + Map<String, String> body = new HashMap<String, String>(); |
458 | body.put("cardNo", teacherBean.getStudent_num()); | 459 | body.put("cardNo", teacherBean.getStudent_num()); |
459 | body.put("id", "8"); | 460 | body.put("id", "8"); |
460 | body.put("sn", deviceId); | 461 | body.put("sn", deviceId); |
@@ -486,14 +487,37 @@ public class DahuaApplicationTests { | @@ -486,14 +487,37 @@ public class DahuaApplicationTests { | ||
486 | // | 487 | // |
487 | // System.out.println("list:" + list.toString()); | 488 | // System.out.println("list:" + list.toString()); |
488 | 489 | ||
489 | - List<AttendanceBean> attendanceBeanList = userDao.getAttendanceBeans("479","4"); | 490 | +// List<AttendanceBean> attendanceBeanList = userDao.getAttendanceBeans("479","4"); |
491 | +// | ||
492 | +// for (int i = 0; i < attendanceBeanList.size(); i++) { | ||
493 | +// AttendanceBean attendanceBean = attendanceBeanList.get(i); | ||
494 | +// | ||
495 | +// | ||
496 | +// } | ||
490 | 497 | ||
491 | - for (int i = 0; i < attendanceBeanList.size(); i++) { | ||
492 | - AttendanceBean attendanceBean = attendanceBeanList.get(i); | 498 | + File file = new File("D:\\新七年级\\名字.txt"); |
493 | 499 | ||
500 | + try { | ||
501 | + FileReader fileReader = new FileReader(file); | ||
502 | + BufferedReader bufferedReader = new BufferedReader(fileReader); | ||
503 | + List<UserInfoBean> userInfoBeans = userDao.getStuUserInfos(); | ||
504 | + String content = null; | ||
505 | + while ((content = bufferedReader.readLine()) != null) { | ||
494 | 506 | ||
495 | - } | 507 | + for (int i = 0; i < userInfoBeans.size(); i++) { |
508 | + UserInfoBean userInfoBean = userInfoBeans.get(i); | ||
509 | + if (content.equals(userInfoBean.getName())){ | ||
510 | + System.out.println(userInfoBean.getStudentcode()+"\t"); | ||
511 | + } | ||
512 | + } | ||
513 | + | ||
514 | + } | ||
496 | 515 | ||
516 | + } catch (FileNotFoundException e) { | ||
517 | + e.printStackTrace(); | ||
518 | + } catch (IOException e) { | ||
519 | + e.printStackTrace(); | ||
520 | + } | ||
497 | 521 | ||
498 | 522 | ||
499 | } | 523 | } |
@@ -506,7 +530,7 @@ public class DahuaApplicationTests { | @@ -506,7 +530,7 @@ public class DahuaApplicationTests { | ||
506 | 530 | ||
507 | mqttManager.init(); | 531 | mqttManager.init(); |
508 | 532 | ||
509 | - List<String> stringList = userDao.getAllDecWithSch(479); | 533 | + List<String> stringList = userDao.getAllDecWithSch(27); |
510 | System.out.println("stringList:" + stringList.size()); | 534 | System.out.println("stringList:" + stringList.size()); |
511 | for (int i = 0; i < stringList.size(); i++) { | 535 | for (int i = 0; i < stringList.size(); i++) { |
512 | String devId = stringList.get(i); | 536 | String devId = stringList.get(i); |
cloud/haikangface/mvnw
@@ -19,7 +19,7 @@ | @@ -19,7 +19,7 @@ | ||
19 | # ---------------------------------------------------------------------------- | 19 | # ---------------------------------------------------------------------------- |
20 | 20 | ||
21 | # ---------------------------------------------------------------------------- | 21 | # ---------------------------------------------------------------------------- |
22 | -# Maven2 Start Up Batch script | 22 | +# Maven Start Up Batch script |
23 | # | 23 | # |
24 | # Required ENV vars: | 24 | # Required ENV vars: |
25 | # ------------------ | 25 | # ------------------ |
@@ -114,7 +114,6 @@ if $mingw ; then | @@ -114,7 +114,6 @@ if $mingw ; then | ||
114 | M2_HOME="`(cd "$M2_HOME"; pwd)`" | 114 | M2_HOME="`(cd "$M2_HOME"; pwd)`" |
115 | [ -n "$JAVA_HOME" ] && | 115 | [ -n "$JAVA_HOME" ] && |
116 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" | 116 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" |
117 | - # TODO classpath? | ||
118 | fi | 117 | fi |
119 | 118 | ||
120 | if [ -z "$JAVA_HOME" ]; then | 119 | if [ -z "$JAVA_HOME" ]; then |
@@ -212,7 +211,11 @@ else | @@ -212,7 +211,11 @@ else | ||
212 | if [ "$MVNW_VERBOSE" = true ]; then | 211 | if [ "$MVNW_VERBOSE" = true ]; then |
213 | echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." | 212 | echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." |
214 | fi | 213 | fi |
215 | - jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar" | 214 | + if [ -n "$MVNW_REPOURL" ]; then |
215 | + jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" | ||
216 | + else | ||
217 | + jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" | ||
218 | + fi | ||
216 | while IFS="=" read key value; do | 219 | while IFS="=" read key value; do |
217 | case "$key" in (wrapperUrl) jarUrl="$value"; break ;; | 220 | case "$key" in (wrapperUrl) jarUrl="$value"; break ;; |
218 | esac | 221 | esac |
@@ -221,22 +224,38 @@ else | @@ -221,22 +224,38 @@ else | ||
221 | echo "Downloading from: $jarUrl" | 224 | echo "Downloading from: $jarUrl" |
222 | fi | 225 | fi |
223 | wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" | 226 | wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" |
227 | + if $cygwin; then | ||
228 | + wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` | ||
229 | + fi | ||
224 | 230 | ||
225 | if command -v wget > /dev/null; then | 231 | if command -v wget > /dev/null; then |
226 | if [ "$MVNW_VERBOSE" = true ]; then | 232 | if [ "$MVNW_VERBOSE" = true ]; then |
227 | echo "Found wget ... using wget" | 233 | echo "Found wget ... using wget" |
228 | fi | 234 | fi |
229 | - wget "$jarUrl" -O "$wrapperJarPath" | 235 | + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then |
236 | + wget "$jarUrl" -O "$wrapperJarPath" | ||
237 | + else | ||
238 | + wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" | ||
239 | + fi | ||
230 | elif command -v curl > /dev/null; then | 240 | elif command -v curl > /dev/null; then |
231 | if [ "$MVNW_VERBOSE" = true ]; then | 241 | if [ "$MVNW_VERBOSE" = true ]; then |
232 | echo "Found curl ... using curl" | 242 | echo "Found curl ... using curl" |
233 | fi | 243 | fi |
234 | - curl -o "$wrapperJarPath" "$jarUrl" | 244 | + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then |
245 | + curl -o "$wrapperJarPath" "$jarUrl" -f | ||
246 | + else | ||
247 | + curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f | ||
248 | + fi | ||
249 | + | ||
235 | else | 250 | else |
236 | if [ "$MVNW_VERBOSE" = true ]; then | 251 | if [ "$MVNW_VERBOSE" = true ]; then |
237 | echo "Falling back to using Java to download" | 252 | echo "Falling back to using Java to download" |
238 | fi | 253 | fi |
239 | javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" | 254 | javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" |
255 | + # For Cygwin, switch paths to Windows format before running javac | ||
256 | + if $cygwin; then | ||
257 | + javaClass=`cygpath --path --windows "$javaClass"` | ||
258 | + fi | ||
240 | if [ -e "$javaClass" ]; then | 259 | if [ -e "$javaClass" ]; then |
241 | if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then | 260 | if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then |
242 | if [ "$MVNW_VERBOSE" = true ]; then | 261 | if [ "$MVNW_VERBOSE" = true ]; then |
@@ -277,6 +296,11 @@ if $cygwin; then | @@ -277,6 +296,11 @@ if $cygwin; then | ||
277 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` | 296 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` |
278 | fi | 297 | fi |
279 | 298 | ||
299 | +# Provide a "standardized" way to retrieve the CLI args that will | ||
300 | +# work with both Windows and non-Windows executions. | ||
301 | +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" | ||
302 | +export MAVEN_CMD_LINE_ARGS | ||
303 | + | ||
280 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain | 304 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain |
281 | 305 | ||
282 | exec "$JAVACMD" \ | 306 | exec "$JAVACMD" \ |
cloud/haikangface/mvnw.cmd
@@ -18,7 +18,7 @@ | @@ -18,7 +18,7 @@ | ||
18 | @REM ---------------------------------------------------------------------------- | 18 | @REM ---------------------------------------------------------------------------- |
19 | 19 | ||
20 | @REM ---------------------------------------------------------------------------- | 20 | @REM ---------------------------------------------------------------------------- |
21 | -@REM Maven2 Start Up Batch script | 21 | +@REM Maven Start Up Batch script |
22 | @REM | 22 | @REM |
23 | @REM Required ENV vars: | 23 | @REM Required ENV vars: |
24 | @REM JAVA_HOME - location of a JDK home dir | 24 | @REM JAVA_HOME - location of a JDK home dir |
@@ -26,7 +26,7 @@ | @@ -26,7 +26,7 @@ | ||
26 | @REM Optional ENV vars | 26 | @REM Optional ENV vars |
27 | @REM M2_HOME - location of maven2's installed home dir | 27 | @REM M2_HOME - location of maven2's installed home dir |
28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands | 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands |
29 | -@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending | 29 | +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending |
30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven | 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven |
31 | @REM e.g. to debug Maven itself, use | 31 | @REM e.g. to debug Maven itself, use |
32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 | 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 |
@@ -37,7 +37,7 @@ | @@ -37,7 +37,7 @@ | ||
37 | @echo off | 37 | @echo off |
38 | @REM set title of command window | 38 | @REM set title of command window |
39 | title %0 | 39 | title %0 |
40 | -@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' | 40 | +@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' |
41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% | 41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% |
42 | 42 | ||
43 | @REM set %HOME% to equivalent of $HOME | 43 | @REM set %HOME% to equivalent of $HOME |
@@ -120,23 +120,44 @@ SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" | @@ -120,23 +120,44 @@ SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" | ||
120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" | 120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" |
121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain | 121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain |
122 | 122 | ||
123 | -set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar" | ||
124 | -FOR /F "tokens=1,2 delims==" %%A IN (%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties) DO ( | ||
125 | - IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B | 123 | +set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" |
124 | + | ||
125 | +FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( | ||
126 | + IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B | ||
126 | ) | 127 | ) |
127 | 128 | ||
128 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central | 129 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central |
129 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. | 130 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. |
130 | if exist %WRAPPER_JAR% ( | 131 | if exist %WRAPPER_JAR% ( |
131 | - echo Found %WRAPPER_JAR% | 132 | + if "%MVNW_VERBOSE%" == "true" ( |
133 | + echo Found %WRAPPER_JAR% | ||
134 | + ) | ||
132 | ) else ( | 135 | ) else ( |
133 | - echo Couldn't find %WRAPPER_JAR%, downloading it ... | ||
134 | - echo Downloading from: %DOWNLOAD_URL% | ||
135 | - powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')" | ||
136 | - echo Finished downloading %WRAPPER_JAR% | 136 | + if not "%MVNW_REPOURL%" == "" ( |
137 | + SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" | ||
138 | + ) | ||
139 | + if "%MVNW_VERBOSE%" == "true" ( | ||
140 | + echo Couldn't find %WRAPPER_JAR%, downloading it ... | ||
141 | + echo Downloading from: %DOWNLOAD_URL% | ||
142 | + ) | ||
143 | + | ||
144 | + powershell -Command "&{"^ | ||
145 | + "$webclient = new-object System.Net.WebClient;"^ | ||
146 | + "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ | ||
147 | + "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ | ||
148 | + "}"^ | ||
149 | + "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ | ||
150 | + "}" | ||
151 | + if "%MVNW_VERBOSE%" == "true" ( | ||
152 | + echo Finished downloading %WRAPPER_JAR% | ||
153 | + ) | ||
137 | ) | 154 | ) |
138 | @REM End of extension | 155 | @REM End of extension |
139 | 156 | ||
157 | +@REM Provide a "standardized" way to retrieve the CLI args that will | ||
158 | +@REM work with both Windows and non-Windows executions. | ||
159 | +set MAVEN_CMD_LINE_ARGS=%* | ||
160 | + | ||
140 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* | 161 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* |
141 | if ERRORLEVEL 1 goto error | 162 | if ERRORLEVEL 1 goto error |
142 | goto end | 163 | goto end |
cloud/haikangface/src/main/java/com/sincere/haikangface/CMSServer.java
1 | package com.sincere.haikangface; | 1 | package com.sincere.haikangface; |
2 | 2 | ||
3 | import com.alibaba.fastjson.JSON; | 3 | import com.alibaba.fastjson.JSON; |
4 | +import com.alibaba.fastjson.JSONArray; | ||
4 | import com.alibaba.fastjson.JSONObject; | 5 | import com.alibaba.fastjson.JSONObject; |
5 | import com.sincere.haikangface.bean.*; | 6 | import com.sincere.haikangface.bean.*; |
7 | +import com.sincere.haikangface.bean.face.BaiduUserInfoBean; | ||
6 | import com.sincere.haikangface.bean.xiaoan.Face_Recoder; | 8 | import com.sincere.haikangface.bean.xiaoan.Face_Recoder; |
7 | import com.sincere.haikangface.dao.DeviceDao; | 9 | import com.sincere.haikangface.dao.DeviceDao; |
8 | import com.sincere.haikangface.dao.UserDao; | 10 | import com.sincere.haikangface.dao.UserDao; |
@@ -21,8 +23,14 @@ import org.springframework.beans.factory.annotation.Autowired; | @@ -21,8 +23,14 @@ import org.springframework.beans.factory.annotation.Autowired; | ||
21 | import org.springframework.beans.factory.annotation.Value; | 23 | import org.springframework.beans.factory.annotation.Value; |
22 | import org.springframework.boot.ApplicationArguments; | 24 | import org.springframework.boot.ApplicationArguments; |
23 | import org.springframework.boot.ApplicationRunner; | 25 | import org.springframework.boot.ApplicationRunner; |
26 | +import org.springframework.core.io.FileSystemResource; | ||
27 | +import org.springframework.http.HttpEntity; | ||
28 | +import org.springframework.http.HttpHeaders; | ||
29 | +import org.springframework.http.MediaType; | ||
24 | import org.springframework.http.ResponseEntity; | 30 | import org.springframework.http.ResponseEntity; |
25 | import org.springframework.stereotype.Component; | 31 | import org.springframework.stereotype.Component; |
32 | +import org.springframework.util.LinkedMultiValueMap; | ||
33 | +import org.springframework.util.MultiValueMap; | ||
26 | import org.springframework.util.StringUtils; | 34 | import org.springframework.util.StringUtils; |
27 | import org.springframework.web.client.RestTemplate; | 35 | import org.springframework.web.client.RestTemplate; |
28 | 36 | ||
@@ -30,6 +38,8 @@ import java.io.*; | @@ -30,6 +38,8 @@ import java.io.*; | ||
30 | import java.net.InetAddress; | 38 | import java.net.InetAddress; |
31 | import java.net.UnknownHostException; | 39 | import java.net.UnknownHostException; |
32 | import java.nio.ByteBuffer; | 40 | import java.nio.ByteBuffer; |
41 | +import java.text.DecimalFormat; | ||
42 | +import java.text.ParseException; | ||
33 | import java.text.SimpleDateFormat; | 43 | import java.text.SimpleDateFormat; |
34 | import java.util.Date; | 44 | import java.util.Date; |
35 | import java.util.HashMap; | 45 | import java.util.HashMap; |
@@ -54,8 +64,8 @@ public class CMSServer implements ApplicationRunner { | @@ -54,8 +64,8 @@ public class CMSServer implements ApplicationRunner { | ||
54 | //114.55.30.100 | 64 | //114.55.30.100 |
55 | //120.26.116.253 | 65 | //120.26.116.253 |
56 | // private String ip_cloud = "120.26.116.253"; | 66 | // private String ip_cloud = "120.26.116.253"; |
57 | - private String ip_cloud = "172.16.2.53"; | ||
58 | - // private String ip_cloud = "114.55.30.100"; | 67 | +// private String ip_cloud = "192.168.71.242"; |
68 | + private String ip_cloud = "114.55.30.100"; | ||
59 | private String ip; | 69 | private String ip; |
60 | 70 | ||
61 | { | 71 | { |
@@ -144,6 +154,7 @@ public class CMSServer implements ApplicationRunner { | @@ -144,6 +154,7 @@ public class CMSServer implements ApplicationRunner { | ||
144 | pInBuffer.dwSize = pInBuffer.size(); | 154 | pInBuffer.dwSize = pInBuffer.size(); |
145 | AttendanceBean attendanceBean = new AttendanceBean(); | 155 | AttendanceBean attendanceBean = new AttendanceBean(); |
146 | attendanceBean.setClint_id(deviceId); | 156 | attendanceBean.setClint_id(deviceId); |
157 | + | ||
147 | if (deviceId.startsWith("ytj")) | 158 | if (deviceId.startsWith("ytj")) |
148 | attendanceBean.setClint_type("28"); | 159 | attendanceBean.setClint_type("28"); |
149 | else | 160 | else |
@@ -291,6 +302,7 @@ public class CMSServer implements ApplicationRunner { | @@ -291,6 +302,7 @@ public class CMSServer implements ApplicationRunner { | ||
291 | public class PSS_Storage_Callback implements HCEHomeSS.EHomeSSStorageCallBack { | 302 | public class PSS_Storage_Callback implements HCEHomeSS.EHomeSSStorageCallBack { |
292 | 303 | ||
293 | public boolean invoke(NativeLong iHandle, String pFileName, Pointer pFileBuf, int dwFileLen, Pointer pFilePath, Pointer pUser) { | 304 | public boolean invoke(NativeLong iHandle, String pFileName, Pointer pFileBuf, int dwFileLen, Pointer pFilePath, Pointer pUser) { |
305 | + log.error("图片进来:{}" , pFileName); | ||
294 | String strPath = "C://EhomePicServer/"; | 306 | String strPath = "C://EhomePicServer/"; |
295 | // System.out.println("pFileName:" + pFileName); | 307 | // System.out.println("pFileName:" + pFileName); |
296 | pFileName = pFileName.replace("_", ""); | 308 | pFileName = pFileName.replace("_", ""); |
@@ -335,6 +347,9 @@ public class CMSServer implements ApplicationRunner { | @@ -335,6 +347,9 @@ public class CMSServer implements ApplicationRunner { | ||
335 | buffers.get(bytes); | 347 | buffers.get(bytes); |
336 | fout.write(bytes); | 348 | fout.write(bytes); |
337 | fout.close(); | 349 | fout.close(); |
350 | + | ||
351 | + sendToKB(strFilePathFile); | ||
352 | + | ||
338 | } catch (FileNotFoundException e) { | 353 | } catch (FileNotFoundException e) { |
339 | // TODO Auto-generated catch block | 354 | // TODO Auto-generated catch block |
340 | e.printStackTrace(); | 355 | e.printStackTrace(); |
@@ -354,6 +369,77 @@ public class CMSServer implements ApplicationRunner { | @@ -354,6 +369,77 @@ public class CMSServer implements ApplicationRunner { | ||
354 | } | 369 | } |
355 | } | 370 | } |
356 | 371 | ||
372 | + /** | ||
373 | + * 发送人脸到看板 | ||
374 | + * | ||
375 | + * @param strFilePathFile | ||
376 | + */ | ||
377 | + public void sendToKB(File strFilePathFile) { | ||
378 | + try { | ||
379 | + | ||
380 | + log.error("开始识别....."); | ||
381 | + String url = "http://120.26.116.253:9214/baiduapi/search/16"; | ||
382 | + | ||
383 | + RestTemplate restTemplate = new RestTemplate(); | ||
384 | + | ||
385 | + HttpHeaders headers = new HttpHeaders(); | ||
386 | + MediaType mediaType = MediaType.parseMediaType(MediaType.MULTIPART_FORM_DATA_VALUE); | ||
387 | + headers.setContentType(mediaType); | ||
388 | + MultiValueMap<String, Object> multiValueMap = new LinkedMultiValueMap<>(); | ||
389 | + FileSystemResource fileSystemResource = new FileSystemResource(strFilePathFile); | ||
390 | + | ||
391 | + multiValueMap.add("file ", fileSystemResource); | ||
392 | + HttpEntity<MultiValueMap<String, Object>> httpEntity = new HttpEntity<>(multiValueMap, headers); | ||
393 | + | ||
394 | + ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, httpEntity, String.class); | ||
395 | + log.error("识别结果:{}" , responseEntity.getBody()); | ||
396 | + JSONObject jsonObject = JSON.parseObject(responseEntity.getBody()); | ||
397 | + | ||
398 | + String face = jsonObject.getString("data"); | ||
399 | + if (face.startsWith("face"))return; | ||
400 | + | ||
401 | + JSONObject data = jsonObject.getJSONObject("data"); | ||
402 | + String error_msg = data.getString("error_msg"); | ||
403 | + | ||
404 | + if (error_msg.equals("SUCCESS")) {//识别成功 | ||
405 | + JSONObject result = data.getJSONObject("result"); | ||
406 | + JSONArray user_list = result.getJSONArray("user_list"); | ||
407 | + | ||
408 | + if (user_list != null && user_list.size() > 0) { | ||
409 | + | ||
410 | + for (int i = 0; i < user_list.size(); i++) { | ||
411 | + JSONObject user = user_list.getJSONObject(i); | ||
412 | + | ||
413 | + String user_id = user.getString("user_id"); | ||
414 | + String score = user.getString("score"); | ||
415 | + double sc = Double.valueOf(score.split("\\.")[0]); | ||
416 | + if (sc >= 60) { | ||
417 | + System.out.println("user_id:" + user_id); | ||
418 | + TeacherBean teacherBean = userDao.getTeacherWithUserId1(user_id); | ||
419 | + if (null != teacherBean) { | ||
420 | + if (TextUtils.isEmpty(teacherBean.getTeacer_num()))teacherBean.setTeacer_num(user_id); | ||
421 | + MqtUtils.getInstance().sendMsg("09EA8EB5142F2964", 1, teacherBean.toString()); | ||
422 | + } else { | ||
423 | + System.out.println("用户身份信息不存在"); | ||
424 | + } | ||
425 | + }else { | ||
426 | + System.out.println("用户身份信息不存在"+score); | ||
427 | + } | ||
428 | + | ||
429 | + } | ||
430 | + | ||
431 | + } | ||
432 | + } else { | ||
433 | + System.out.println("识别失败:" + error_msg); | ||
434 | + } | ||
435 | + log.error("发送成功....."); | ||
436 | +// System.out.println("responseEntity:"+responseEntity.getBody()); | ||
437 | + }catch (Exception e){ | ||
438 | + e.printStackTrace(); | ||
439 | + } | ||
440 | + | ||
441 | + } | ||
442 | + | ||
357 | HCEHomeAlarm.NET_EHOME_ALARM_LISTEN_PARAM net_ehome_alarm_listen_param = new HCEHomeAlarm.NET_EHOME_ALARM_LISTEN_PARAM(); | 443 | HCEHomeAlarm.NET_EHOME_ALARM_LISTEN_PARAM net_ehome_alarm_listen_param = new HCEHomeAlarm.NET_EHOME_ALARM_LISTEN_PARAM(); |
358 | EHomeMsgCallBack cbEHomeMsgCallBack; | 444 | EHomeMsgCallBack cbEHomeMsgCallBack; |
359 | ;//报警监听回调函数实现 | 445 | ;//报警监听回调函数实现 |
@@ -420,8 +506,8 @@ public class CMSServer implements ApplicationRunner { | @@ -420,8 +506,8 @@ public class CMSServer implements ApplicationRunner { | ||
420 | strXMLData.read(); | 506 | strXMLData.read(); |
421 | 507 | ||
422 | String strXML = new String(strXMLData.byValue); | 508 | String strXML = new String(strXMLData.byValue); |
423 | - System.out.println(strXML); | ||
424 | - | 509 | +// System.out.println(strXML); |
510 | +// log.error("报警监听:{}",strXML); | ||
425 | if (null == alarmUtils) { | 511 | if (null == alarmUtils) { |
426 | alarmUtils = new AlarmUtils(deviceDao); | 512 | alarmUtils = new AlarmUtils(deviceDao); |
427 | alarmUtils.setCallBack(new AlarmUtils.AlarmCallBack() { | 513 | alarmUtils.setCallBack(new AlarmUtils.AlarmCallBack() { |
@@ -477,7 +563,7 @@ public class CMSServer implements ApplicationRunner { | @@ -477,7 +563,7 @@ public class CMSServer implements ApplicationRunner { | ||
477 | cardNo = sendRecoderUtils.getCard(card); | 563 | cardNo = sendRecoderUtils.getCard(card); |
478 | 564 | ||
479 | StudentBean studentBean = userDao.getStudentWithCard(cardNo); | 565 | StudentBean studentBean = userDao.getStudentWithCard(cardNo); |
480 | - | 566 | + log.error("studentBean:{}",studentBean); |
481 | if (null != studentBean) { | 567 | if (null != studentBean) { |
482 | FileUtils.getInstance().writeLogs(studentBean.getName() + " " + cardNo, FileUtils.facerecoder); | 568 | FileUtils.getInstance().writeLogs(studentBean.getName() + " " + cardNo, FileUtils.facerecoder); |
483 | 569 | ||
@@ -501,7 +587,6 @@ public class CMSServer implements ApplicationRunner { | @@ -501,7 +587,6 @@ public class CMSServer implements ApplicationRunner { | ||
501 | } else { | 587 | } else { |
502 | //教师点名 | 588 | //教师点名 |
503 | isTeacher(cardNo, deviceID); | 589 | isTeacher(cardNo, deviceID); |
504 | - FileUtils.getInstance().writeLogs("card:" + card, FileUtils.faceSuccess); | ||
505 | } | 590 | } |
506 | 591 | ||
507 | if (deviceID.startsWith("qj")) {//枪击 用来抓拍人脸考勤用 | 592 | if (deviceID.startsWith("qj")) {//枪击 用来抓拍人脸考勤用 |
@@ -529,10 +614,12 @@ public class CMSServer implements ApplicationRunner { | @@ -529,10 +614,12 @@ public class CMSServer implements ApplicationRunner { | ||
529 | public void isTeacher(String cardNo, String deviceID) { | 614 | public void isTeacher(String cardNo, String deviceID) { |
530 | 615 | ||
531 | List<String> devLists = userDao.getDeviceRoomRelation(deviceID); | 616 | List<String> devLists = userDao.getDeviceRoomRelation(deviceID); |
617 | + log.error("cardNo:{},devLists{}",cardNo,devLists); | ||
532 | 618 | ||
533 | if (null != devLists && devLists.size() > 0) { | 619 | if (null != devLists && devLists.size() > 0) { |
534 | 620 | ||
535 | StudentBean teacher = userDao.getTeacherWithCard(cardNo); | 621 | StudentBean teacher = userDao.getTeacherWithCard(cardNo); |
622 | + FileUtils.getInstance().writeLogs("teacher:" + teacher+"----"+cardNo, "教师点名.txt"); | ||
536 | if (null != teacher) { | 623 | if (null != teacher) { |
537 | String url = String.format("http://campus.myjxt.com/api/RollCall/AddRollCallPersonnelRecord?userId=%s&deviceId=%s", teacher.getUser_id(), deviceID); | 624 | String url = String.format("http://campus.myjxt.com/api/RollCall/AddRollCallPersonnelRecord?userId=%s&deviceId=%s", teacher.getUser_id(), deviceID); |
538 | 625 | ||
@@ -540,7 +627,7 @@ public class CMSServer implements ApplicationRunner { | @@ -540,7 +627,7 @@ public class CMSServer implements ApplicationRunner { | ||
540 | 627 | ||
541 | String res = restTemplate.getForObject(url, String.class); | 628 | String res = restTemplate.getForObject(url, String.class); |
542 | JSONObject jsonObject = JSON.parseObject(res); | 629 | JSONObject jsonObject = JSON.parseObject(res); |
543 | - | 630 | + FileUtils.getInstance().writeLogs("card:" + res, "教师点名.txt"); |
544 | System.out.println("result:" + res + "------url:" + jsonObject.getBoolean("data")); | 631 | System.out.println("result:" + res + "------url:" + jsonObject.getBoolean("data")); |
545 | 632 | ||
546 | } | 633 | } |
@@ -657,11 +744,11 @@ public class CMSServer implements ApplicationRunner { | @@ -657,11 +744,11 @@ public class CMSServer implements ApplicationRunner { | ||
657 | "<password>MTIzNDU2</password>\r\n" + | 744 | "<password>MTIzNDU2</password>\r\n" + |
658 | "<maxSwipeTime></maxSwipeTime>\r\n" + | 745 | "<maxSwipeTime></maxSwipeTime>\r\n" + |
659 | "<swipeTime></swipeTime>\r\n" + | 746 | "<swipeTime></swipeTime>\r\n" + |
660 | - "<groupNo>5</groupNo>\r\n" + | 747 | + "<groupNo></groupNo>\r\n" + |
661 | "<name>"; | 748 | "<name>"; |
662 | String nameAfter = "</name>\r\n" + | 749 | String nameAfter = "</name>\r\n" + |
663 | "<employeeNo>" + employeeNo + "</employeeNo>\r\n" + | 750 | "<employeeNo>" + employeeNo + "</employeeNo>\r\n" + |
664 | - "<departmentNo>3</departmentNo>\r\n" + | 751 | + "<departmentNo></departmentNo>\r\n" + |
665 | "<schedulePlanNo></schedulePlanNo>\r\n" + | 752 | "<schedulePlanNo></schedulePlanNo>\r\n" + |
666 | "<schedulePlanType></schedulePlanType>\r\n" + | 753 | "<schedulePlanType></schedulePlanType>\r\n" + |
667 | "</CardCfg>\r\n" + | 754 | "</CardCfg>\r\n" + |
cloud/haikangface/src/main/java/com/sincere/haikangface/async/SendUserAsync.java
@@ -105,7 +105,7 @@ public class SendUserAsync { | @@ -105,7 +105,7 @@ public class SendUserAsync { | ||
105 | if (weekDay.getDeviceIds() != null && weekDay.getDeviceIds().size() > 0) { | 105 | if (weekDay.getDeviceIds() != null && weekDay.getDeviceIds().size() > 0) { |
106 | permissionBean.setDeviceIds(weekDay.getDeviceIds()); | 106 | permissionBean.setDeviceIds(weekDay.getDeviceIds()); |
107 | } | 107 | } |
108 | - List<String> deviceIds = permissionBean.getDeviceIds(); | 108 | + List<String> deviceIds = weekDay.getDeviceIds(); |
109 | List<String> cardNumList = new ArrayList<>(); | 109 | List<String> cardNumList = new ArrayList<>(); |
110 | String sex = weekDay.getSex(); | 110 | String sex = weekDay.getSex(); |
111 | if (userType.equals("1")) { | 111 | if (userType.equals("1")) { |
cloud/haikangface/src/main/java/com/sincere/haikangface/bean/TeacherBean.java
@@ -10,6 +10,16 @@ public class TeacherBean implements Serializable { | @@ -10,6 +10,16 @@ public class TeacherBean implements Serializable { | ||
10 | 10 | ||
11 | private String num; | 11 | private String num; |
12 | 12 | ||
13 | + private String face; | ||
14 | + | ||
15 | + public String getTeacher_num() { | ||
16 | + return teacher_num; | ||
17 | + } | ||
18 | + | ||
19 | + public void setTeacher_num(String teacher_num) { | ||
20 | + this.teacher_num = teacher_num; | ||
21 | + } | ||
22 | + | ||
13 | public String getNum() { | 23 | public String getNum() { |
14 | return num; | 24 | return num; |
15 | } | 25 | } |
@@ -33,4 +43,20 @@ public class TeacherBean implements Serializable { | @@ -33,4 +43,20 @@ public class TeacherBean implements Serializable { | ||
33 | public void setTeacer_num(String teacer_num) { | 43 | public void setTeacer_num(String teacer_num) { |
34 | this.teacher_num = teacer_num; | 44 | this.teacher_num = teacer_num; |
35 | } | 45 | } |
46 | + | ||
47 | + public String getFace() { | ||
48 | + return face; | ||
49 | + } | ||
50 | + | ||
51 | + public void setFace(String face) { | ||
52 | + this.face = face; | ||
53 | + } | ||
54 | + | ||
55 | + @Override | ||
56 | + public String toString() { | ||
57 | + return "{\"name\":\"" + name + '\"' + | ||
58 | + ", \"teacher_num\":\"" + teacher_num + '\"' + | ||
59 | + ", \"num\":\"" + num + '\"' + | ||
60 | + ", \"face\":\"" + face + '\"' +"}"; | ||
61 | + } | ||
36 | } | 62 | } |
cloud/haikangface/src/main/java/com/sincere/haikangface/bean/face/BaiduUserInfoBean.java
0 → 100644
@@ -0,0 +1,45 @@ | @@ -0,0 +1,45 @@ | ||
1 | +package com.sincere.haikangface.bean.face; | ||
2 | + | ||
3 | +import java.io.Serializable; | ||
4 | + | ||
5 | +public class BaiduUserInfoBean implements Serializable { | ||
6 | + | ||
7 | + private int status; | ||
8 | + | ||
9 | + private String message; | ||
10 | + | ||
11 | + private BaiduUserInfoDataBean data; | ||
12 | + | ||
13 | + public int getStatus() { | ||
14 | + return status; | ||
15 | + } | ||
16 | + | ||
17 | + public void setStatus(int status) { | ||
18 | + this.status = status; | ||
19 | + } | ||
20 | + | ||
21 | + public String getMessage() { | ||
22 | + return message; | ||
23 | + } | ||
24 | + | ||
25 | + public void setMessage(String message) { | ||
26 | + this.message = message; | ||
27 | + } | ||
28 | + | ||
29 | + public BaiduUserInfoDataBean getData() { | ||
30 | + return data; | ||
31 | + } | ||
32 | + | ||
33 | + public void setData(BaiduUserInfoDataBean data) { | ||
34 | + this.data = data; | ||
35 | + } | ||
36 | + | ||
37 | + @Override | ||
38 | + public String toString() { | ||
39 | + return "BaiduUserInfoBean{" + | ||
40 | + "status=" + status + | ||
41 | + ", message='" + message + '\'' + | ||
42 | + ", data=" + data + | ||
43 | + '}'; | ||
44 | + } | ||
45 | +} |
cloud/haikangface/src/main/java/com/sincere/haikangface/bean/face/BaiduUserInfoDataBean.java
0 → 100644
@@ -0,0 +1,45 @@ | @@ -0,0 +1,45 @@ | ||
1 | +package com.sincere.haikangface.bean.face; | ||
2 | + | ||
3 | +import java.io.Serializable; | ||
4 | + | ||
5 | +public class BaiduUserInfoDataBean implements Serializable { | ||
6 | + | ||
7 | + private String error_msg; | ||
8 | + | ||
9 | + private int error_code; | ||
10 | + | ||
11 | + private BaiduUserInfoResultBean data; | ||
12 | + | ||
13 | + public String getError_msg() { | ||
14 | + return error_msg; | ||
15 | + } | ||
16 | + | ||
17 | + public void setError_msg(String error_msg) { | ||
18 | + this.error_msg = error_msg; | ||
19 | + } | ||
20 | + | ||
21 | + public int getError_code() { | ||
22 | + return error_code; | ||
23 | + } | ||
24 | + | ||
25 | + public void setError_code(int error_code) { | ||
26 | + this.error_code = error_code; | ||
27 | + } | ||
28 | + | ||
29 | + public BaiduUserInfoResultBean getData() { | ||
30 | + return data; | ||
31 | + } | ||
32 | + | ||
33 | + public void setData(BaiduUserInfoResultBean data) { | ||
34 | + this.data = data; | ||
35 | + } | ||
36 | + | ||
37 | + @Override | ||
38 | + public String toString() { | ||
39 | + return "BaiduUserInfoDataBean{" + | ||
40 | + "error_msg='" + error_msg + '\'' + | ||
41 | + ", error_code=" + error_code + | ||
42 | + ", data=" + data + | ||
43 | + '}'; | ||
44 | + } | ||
45 | +} |
cloud/haikangface/src/main/java/com/sincere/haikangface/bean/face/BaiduUserInfoListBean.java
0 → 100644
@@ -0,0 +1,23 @@ | @@ -0,0 +1,23 @@ | ||
1 | +package com.sincere.haikangface.bean.face; | ||
2 | + | ||
3 | +import java.io.Serializable; | ||
4 | + | ||
5 | +public class BaiduUserInfoListBean implements Serializable { | ||
6 | + | ||
7 | + private String user_id; | ||
8 | + | ||
9 | + public String getUser_id() { | ||
10 | + return user_id; | ||
11 | + } | ||
12 | + | ||
13 | + public void setUser_id(String user_id) { | ||
14 | + this.user_id = user_id; | ||
15 | + } | ||
16 | + | ||
17 | + @Override | ||
18 | + public String toString() { | ||
19 | + return "BaiduUserInfoListBean{" + | ||
20 | + "user_id='" + user_id + '\'' + | ||
21 | + '}'; | ||
22 | + } | ||
23 | +} |
cloud/haikangface/src/main/java/com/sincere/haikangface/bean/face/BaiduUserInfoResultBean.java
0 → 100644
@@ -0,0 +1,24 @@ | @@ -0,0 +1,24 @@ | ||
1 | +package com.sincere.haikangface.bean.face; | ||
2 | + | ||
3 | +import java.io.Serializable; | ||
4 | +import java.util.List; | ||
5 | + | ||
6 | +public class BaiduUserInfoResultBean implements Serializable { | ||
7 | + | ||
8 | + private List<BaiduUserInfoListBean> user_list; | ||
9 | + | ||
10 | + public List<BaiduUserInfoListBean> getUser_list() { | ||
11 | + return user_list; | ||
12 | + } | ||
13 | + | ||
14 | + public void setUser_list(List<BaiduUserInfoListBean> user_list) { | ||
15 | + this.user_list = user_list; | ||
16 | + } | ||
17 | + | ||
18 | + @Override | ||
19 | + public String toString() { | ||
20 | + return "BaiduUserInfoResultBean{" + | ||
21 | + "user_list=" + user_list + | ||
22 | + '}'; | ||
23 | + } | ||
24 | +} |
cloud/haikangface/src/main/java/com/sincere/haikangface/control/FileControl.java
@@ -81,7 +81,7 @@ public class FileControl { | @@ -81,7 +81,7 @@ public class FileControl { | ||
81 | String filePath = dest.getAbsolutePath(); | 81 | String filePath = dest.getAbsolutePath(); |
82 | FileUtils.getInstance().writeLogs("filePath:" + filePath + " card:" + card + " name:" + name + " deviceId:" + deviceId, FileUtils.sendUserInfo); | 82 | FileUtils.getInstance().writeLogs("filePath:" + filePath + " card:" + card + " name:" + name + " deviceId:" + deviceId, FileUtils.sendUserInfo); |
83 | long time = System.currentTimeMillis(); | 83 | long time = System.currentTimeMillis(); |
84 | - if (filePath.contains(".jpg")) filePath = filePath.replace(".jpg", ".png"); | 84 | +// if (filePath.contains(".jpg")) filePath = filePath.replace(".jpg", ".png"); |
85 | if (new File(filePath.trim()).exists()) { | 85 | if (new File(filePath.trim()).exists()) { |
86 | String targetPath = FileUtils.picPathComp + new File(filePath).getName().replace(".png", ".jpg"); | 86 | String targetPath = FileUtils.picPathComp + new File(filePath).getName().replace(".png", ".jpg"); |
87 | 87 |
cloud/haikangface/src/main/java/com/sincere/haikangface/control/UserControl.java
@@ -67,6 +67,7 @@ public class UserControl { | @@ -67,6 +67,7 @@ public class UserControl { | ||
67 | @ApiOperation("下发权限给设备") | 67 | @ApiOperation("下发权限给设备") |
68 | public boolean sendPermiss(@RequestBody PermissionBean permissionBean) { | 68 | public boolean sendPermiss(@RequestBody PermissionBean permissionBean) { |
69 | log.error("permissionBean:{}", JSON.toJSONString(permissionBean)); | 69 | log.error("permissionBean:{}", JSON.toJSONString(permissionBean)); |
70 | + FileUtils.getInstance().writeLogs("传入权限模板:"+JSON.toJSONString(permissionBean),"设置权限内容.txt"); | ||
70 | if (!StringUtils.isEmpty(permissionBean.getDeviceIds())) { | 71 | if (!StringUtils.isEmpty(permissionBean.getDeviceIds())) { |
71 | // List<String> cardNumList = userDao.getStudentCardsWidthSchoolId(permissionBean.getSchoolId()); | 72 | // List<String> cardNumList = userDao.getStudentCardsWidthSchoolId(permissionBean.getSchoolId()); |
72 | return sendUserAsync.sendPermiss(permissionBean, 0); | 73 | return sendUserAsync.sendPermiss(permissionBean, 0); |
@@ -97,6 +98,16 @@ public class UserControl { | @@ -97,6 +98,16 @@ public class UserControl { | ||
97 | } | 98 | } |
98 | } | 99 | } |
99 | 100 | ||
101 | + @RequestMapping(value = "sendToKB", method = RequestMethod.GET) | ||
102 | + @ApiOperation("发送数据到看板") | ||
103 | + public void sendToKB(@RequestParam("filePath") String filePath) { | ||
104 | + try { | ||
105 | + cmsServer.sendToKB(new File(filePath)); | ||
106 | + } catch (Exception e) { | ||
107 | + e.printStackTrace(); | ||
108 | + } | ||
109 | + } | ||
110 | + | ||
100 | 111 | ||
101 | @RequestMapping(value = "sendStuCardAndImg", method = RequestMethod.GET) | 112 | @RequestMapping(value = "sendStuCardAndImg", method = RequestMethod.GET) |
102 | @ApiOperation("下发人脸给设备") | 113 | @ApiOperation("下发人脸给设备") |
@@ -106,10 +117,18 @@ public class UserControl { | @@ -106,10 +117,18 @@ public class UserControl { | ||
106 | return sendImg2Device(filePath, card, name, deviceId, userType); | 117 | return sendImg2Device(filePath, card, name, deviceId, userType); |
107 | } | 118 | } |
108 | 119 | ||
120 | + @RequestMapping(value = "sendCardAndImg1", method = RequestMethod.GET) | ||
121 | + @ApiOperation("下发人脸给设备") | ||
122 | + public boolean sendCardAndImg1(@RequestParam("filePath") String filePath, @RequestParam("card") String card | ||
123 | + , @RequestParam("name") String name, @RequestParam("deviceId") String deviceId, @RequestParam("userType") String userType) { | ||
124 | + log.error("sendCardAndImg1:---------------------------------"); | ||
125 | + return sendImg2Device(filePath, card, name, deviceId, userType); | ||
126 | + } | ||
127 | + | ||
109 | private boolean sendImg2Device(String filePath, String card, String name, String deviceId, String userType) { | 128 | private boolean sendImg2Device(String filePath, String card, String name, String deviceId, String userType) { |
110 | try { | 129 | try { |
111 | 130 | ||
112 | - if (filePath.contains(".jpg")) filePath = filePath.replace(".jpg", ".png"); | 131 | +// if (filePath.contains(".jpg")) filePath = filePath.replace(".jpg", ".png"); |
113 | if (new File(filePath.trim()).exists()) { | 132 | if (new File(filePath.trim()).exists()) { |
114 | String targetPath = FileUtils.picPathComp + new File(filePath).getName(); | 133 | String targetPath = FileUtils.picPathComp + new File(filePath).getName(); |
115 | try { | 134 | try { |
cloud/haikangface/src/main/java/com/sincere/haikangface/dao/UserDao.java
@@ -239,6 +239,9 @@ public interface UserDao { | @@ -239,6 +239,9 @@ public interface UserDao { | ||
239 | @Select("select Top(1) * from SZ_V_School_Teacher where user_id = #{userId} and teacher_num<>''") | 239 | @Select("select Top(1) * from SZ_V_School_Teacher where user_id = #{userId} and teacher_num<>''") |
240 | TeacherBean getTeacherWithUserId(@Param("userId") String userId); | 240 | TeacherBean getTeacherWithUserId(@Param("userId") String userId); |
241 | 241 | ||
242 | + @Select("select Top(1) * from SZ_V_School_Teacher where user_id = #{userId}") | ||
243 | + TeacherBean getTeacherWithUserId1(@Param("userId") String userId); | ||
244 | + | ||
242 | 245 | ||
243 | List<String> getStudentWiSidAndSex(@Param("schoolId") String schoolId, @Param("sexs") List<String> sexs); | 246 | List<String> getStudentWiSidAndSex(@Param("schoolId") String schoolId, @Param("sexs") List<String> sexs); |
244 | 247 |
cloud/haikangface/src/main/java/com/sincere/haikangface/mqtt/MqttManager.java
@@ -20,6 +20,22 @@ public class MqttManager { | @@ -20,6 +20,22 @@ public class MqttManager { | ||
20 | 20 | ||
21 | private static int qosLevel; | 21 | private static int qosLevel; |
22 | 22 | ||
23 | + private static MqttManager mqttManager; | ||
24 | + | ||
25 | +// public static MqttManager getInstance(){ | ||
26 | +// | ||
27 | +// if (null==mqttManager){ | ||
28 | +// synchronized (MqttManager.class){ | ||
29 | +// if (null==mqttManager) { | ||
30 | +// mqttManager = new MqttManager(); | ||
31 | +// init(); | ||
32 | +// } | ||
33 | +// } | ||
34 | +// } | ||
35 | +// return mqttManager; | ||
36 | +// } | ||
37 | + | ||
38 | + | ||
23 | public void init() { | 39 | public void init() { |
24 | final String brokerUrl = "tcp://post-cn-4590mq2hr03.mqtt.aliyuncs.com:1883"; | 40 | final String brokerUrl = "tcp://post-cn-4590mq2hr03.mqtt.aliyuncs.com:1883"; |
25 | groupId = "GID_HFJSIURFHAQO110"; | 41 | groupId = "GID_HFJSIURFHAQO110"; |
@@ -95,7 +111,7 @@ public class MqttManager { | @@ -95,7 +111,7 @@ public class MqttManager { | ||
95 | public void sendMq(String deviceId, int cmd, String msg) { | 111 | public void sendMq(String deviceId, int cmd, String msg) { |
96 | String recvClientId = groupId + "@@@" + deviceId; | 112 | String recvClientId = groupId + "@@@" + deviceId; |
97 | final String p2pSendTopic = topic + "/p2p/" + recvClientId; | 113 | final String p2pSendTopic = topic + "/p2p/" + recvClientId; |
98 | - String content = "{\"cmd\":\"" + cmd + "\",\"clientId\":\"\",\"data\": \"" + msg + "\"}"; | 114 | + String content = "{\"cmd\":\"" + cmd + "\",\"clientId\":\"\",\"data\": " + msg + "}"; |
99 | MqttMessage message = new MqttMessage(content.getBytes()); | 115 | MqttMessage message = new MqttMessage(content.getBytes()); |
100 | message.setQos(qosLevel); | 116 | message.setQos(qosLevel); |
101 | System.out.println("发送内容:" + p2pSendTopic + " msg:---------" + msg); | 117 | System.out.println("发送内容:" + p2pSendTopic + " msg:---------" + msg); |
cloud/haikangface/src/main/java/com/sincere/haikangface/utils/CompressPic.java
@@ -22,10 +22,10 @@ public class CompressPic { | @@ -22,10 +22,10 @@ public class CompressPic { | ||
22 | int width = bufferedImage.getWidth(null); | 22 | int width = bufferedImage.getWidth(null); |
23 | int height = bufferedImage.getHeight(null); | 23 | int height = bufferedImage.getHeight(null); |
24 | long fileLength = file.length(); | 24 | long fileLength = file.length(); |
25 | - System.out.println("fileLength:" + fileLength); | ||
26 | - System.out.println("原始宽高:" + "width:" + width + "--height:" + height); | 25 | +// System.out.println("fileLength:" + fileLength); |
26 | +// System.out.println("原始宽高:" + "width:" + width + "--height:" + height); | ||
27 | if ((fileLength / 1024) < 200) { | 27 | if ((fileLength / 1024) < 200) { |
28 | - System.out.println("小于200k压缩:" + "width:" + width + "--height:" + height); | 28 | +// System.out.println("小于200k压缩:" + "width:" + width + "--height:" + height); |
29 | writeImgToFile(bufferedImage, width, height, targetPath); | 29 | writeImgToFile(bufferedImage, width, height, targetPath); |
30 | } else { | 30 | } else { |
31 | while ((fileLength / 1024) >= 200) { | 31 | while ((fileLength / 1024) >= 200) { |
@@ -40,8 +40,8 @@ public class CompressPic { | @@ -40,8 +40,8 @@ public class CompressPic { | ||
40 | width = bufferedImage1.getWidth(null); | 40 | width = bufferedImage1.getWidth(null); |
41 | height = bufferedImage1.getHeight(null); | 41 | height = bufferedImage1.getHeight(null); |
42 | fileLength = file1.length(); | 42 | fileLength = file1.length(); |
43 | - System.out.println("最终宽高:" + "width:" + width + "--height:" + height); | ||
44 | - System.out.println("fileLength1:" + fileLength); | 43 | +// System.out.println("最终宽高:" + "width:" + width + "--height:" + height); |
44 | +// System.out.println("fileLength1:" + fileLength); | ||
45 | fileInputStream.close(); | 45 | fileInputStream.close(); |
46 | } | 46 | } |
47 | } | 47 | } |
cloud/haikangface/src/main/java/com/sincere/haikangface/utils/HttpUtil.java
@@ -124,7 +124,7 @@ public class HttpUtil { | @@ -124,7 +124,7 @@ public class HttpUtil { | ||
124 | 124 | ||
125 | ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, httpEntity, String.class); | 125 | ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, httpEntity, String.class); |
126 | 126 | ||
127 | - System.out.println("responseEntity:" + responseEntity.getBody()); | 127 | + System.out.println("responseEntity:" + responseEntity.getBody()+name); |
128 | return responseEntity.getBody().equals("1"); | 128 | return responseEntity.getBody().equals("1"); |
129 | } | 129 | } |
130 | 130 |
cloud/haikangface/src/main/resources/mapper/usermapper.xml
@@ -19,7 +19,7 @@ | @@ -19,7 +19,7 @@ | ||
19 | </select> | 19 | </select> |
20 | 20 | ||
21 | <select id="getDeviceRoomRelation" resultType="java.lang.String"> | 21 | <select id="getDeviceRoomRelation" resultType="java.lang.String"> |
22 | - select clint_id from SZ_DeviceRoomRelation where clint_id = #{clint_id}; | 22 | + select clint_id from SZ_DeviceRoomRelation where clint_id = #{clint_id} and state = 1; |
23 | </select> | 23 | </select> |
24 | 24 | ||
25 | </mapper> | 25 | </mapper> |
cloud/mypulsar/src/main/java/com/example/mypulsar/MyRunnerableInt.java
@@ -40,7 +40,7 @@ public class MyRunnerableInt implements ApplicationRunner { | @@ -40,7 +40,7 @@ public class MyRunnerableInt implements ApplicationRunner { | ||
40 | 40 | ||
41 | @Override | 41 | @Override |
42 | public void run(ApplicationArguments args) throws Exception { | 42 | public void run(ApplicationArguments args) throws Exception { |
43 | - initMqConsumer(); | 43 | +// initMqConsumer(); |
44 | } | 44 | } |
45 | 45 | ||
46 | /** | 46 | /** |