Commit 191a8018cfea466624f86907b0df5ce41fb96082

Authored by 陶汉栋
1 parent 3009e2ac
Exists in master

无感考勤

Showing 21 changed files with 564 additions and 102 deletions   Show diff stats
cloud/dahua/src/main/java/com/example/dahua/MyTask.java
@@ -66,9 +66,9 @@ public class MyTask implements ApplicationRunner { @@ -66,9 +66,9 @@ public class MyTask implements ApplicationRunner {
66 public void run(ApplicationArguments args) throws Exception { 66 public void run(ApplicationArguments args) throws Exception {
67 // 121.40.109.21 67 // 121.40.109.21
68 68
69 - LoginModule.init(disConnect, haveReConnect); // 打开工程,初始化 69 +// LoginModule.init(disConnect, haveReConnect); // 打开工程,初始化
70 70
71 - autoRegister();//自注册 71 +// autoRegister();//自注册
72 72
73 // System.out.println(" sendRecordDao:"+sendRecordDao.getSenSuccess()); 73 // System.out.println(" sendRecordDao:"+sendRecordDao.getSenSuccess());
74 } 74 }
cloud/dahua/src/main/java/com/example/dahua/Test.java
@@ -16,8 +16,13 @@ public class Test { @@ -16,8 +16,13 @@ public class Test {
16 16
17 public static void main(String[] args) { 17 public static void main(String[] args) {
18 18
  19 + String url = "E:\\wwwhtdocs\\SmartCampus\\face17e5\\School112\\Student\\saa.png";
19 20
20 - Test test = new Test(); 21 + url = url.substring(url.indexOf("School")+6,url.indexOf("\\Student"));
  22 +
  23 + System.out.println("url:"+url);
  24 +
  25 + /*Test test = new Test();
21 26
22 File file = new File("C:\\Users\\Administrator\\Documents\\专业.txt"); 27 File file = new File("C:\\Users\\Administrator\\Documents\\专业.txt");
23 28
@@ -37,7 +42,7 @@ public class Test { @@ -37,7 +42,7 @@ public class Test {
37 e.printStackTrace(); 42 e.printStackTrace();
38 } catch (IOException e) { 43 } catch (IOException e) {
39 e.printStackTrace(); 44 e.printStackTrace();
40 - } 45 + }*/
41 46
42 47
43 } 48 }
cloud/dahua/src/main/java/com/example/dahua/control/UserControl.java
@@ -62,7 +62,7 @@ public class UserControl { @@ -62,7 +62,7 @@ public class UserControl {
62 @RequestMapping(value = "sendPermission", method = RequestMethod.POST) 62 @RequestMapping(value = "sendPermission", method = RequestMethod.POST)
63 @ApiOperation(value = "设置权限") 63 @ApiOperation(value = "设置权限")
64 public boolean sendPermission(@RequestBody PermissionBean permissionBean) { 64 public boolean sendPermission(@RequestBody PermissionBean permissionBean) {
65 - return HttpUtils.sendPermission(permissionBean); 65 + return HttpUtils.sendPermission(permissionBean);
66 } 66 }
67 67
68 @RequestMapping(value = "imgsSend", method = RequestMethod.GET) 68 @RequestMapping(value = "imgsSend", method = RequestMethod.GET)
@@ -116,7 +116,29 @@ public class UserControl { @@ -116,7 +116,29 @@ public class UserControl {
116 @ApiOperation("在线活体检测") 116 @ApiOperation("在线活体检测")
117 public boolean checkFace(@RequestParam("url") String httpurl) { 117 public boolean checkFace(@RequestParam("url") String httpurl) {
118 118
119 - return BaiduUtils.getBaiduUtils().checkImg(httpurl); 119 + boolean check = BaiduUtils.getBaiduUtils().checkImg(httpurl);
  120 +
  121 + if (check) {
  122 + File file = new File(httpurl);
  123 +
  124 + String userCode = file.getName().split("\\.")[0];
  125 +
  126 + String schoolId = "";
  127 +
  128 + if (httpurl.contains("Student")) {
  129 + schoolId = httpurl.substring(httpurl.indexOf("School") + 6, httpurl.indexOf("\\Student"));
  130 + } else if (httpurl.contains("Teacher")) {
  131 + schoolId = httpurl.substring(httpurl.indexOf("School") + 6, httpurl.indexOf("\\Teacher"));
  132 + }
  133 + System.out.println("choolId:" + schoolId + "userCode:" + userCode);
  134 + if (!StringUtils.isEmpty(schoolId) && !StringUtils.isEmpty(userCode)) {
  135 + String userId = userService.getUserId(userCode, schoolId);
  136 + BaiduUtils.getBaiduUtils().addFace(new File(httpurl), schoolId, userId, userId);
  137 + FileUtils.getInstance().writeLogs("人脸添加成功:" + userId, "人脸添加成功.txt");
  138 + }
  139 + }
  140 +
  141 + return check;
120 142
121 } 143 }
122 144
cloud/dahua/src/main/java/com/example/dahua/dao/UserDao.java
@@ -133,4 +133,8 @@ public interface UserDao { @@ -133,4 +133,8 @@ public interface UserDao {
133 133
134 @Select("select * from SZ_V_School_Teacher where user_id = #{userId}") 134 @Select("select * from SZ_V_School_Teacher where user_id = #{userId}")
135 List<TeacherBean> getTeaWithUserId(@Param("userId")String userId); 135 List<TeacherBean> getTeaWithUserId(@Param("userId")String userId);
  136 +
  137 + @Select("select Top(1) user_id from SZ_V_School_Student where studentcode = #{studentcode}")
  138 + String getStuWithCode(@Param("studentcode") String code);
  139 +
136 } 140 }
cloud/dahua/src/main/java/com/example/dahua/service/UserService.java
@@ -3,10 +3,7 @@ package com.example.dahua.service; @@ -3,10 +3,7 @@ package com.example.dahua.service;
3 import com.example.dahua.bean.AttendanceBean; 3 import com.example.dahua.bean.AttendanceBean;
4 import com.example.dahua.bean.PermissionBean; 4 import com.example.dahua.bean.PermissionBean;
5 import com.example.dahua.bean.UserInfoBean; 5 import com.example.dahua.bean.UserInfoBean;
6 -import org.springframework.scheduling.annotation.Async;  
7 -import org.springframework.web.multipart.MultipartFile;  
8 6
9 -import java.io.File;  
10 import java.util.List; 7 import java.util.List;
11 8
12 public interface UserService { 9 public interface UserService {
@@ -57,4 +54,7 @@ public interface UserService { @@ -57,4 +54,7 @@ public interface UserService {
57 */ 54 */
58 boolean sendPermission(PermissionBean permissionBean); 55 boolean sendPermission(PermissionBean permissionBean);
59 56
  57 + String getUserId(String code,String schoolId);
  58 +
  59 +
60 } 60 }
cloud/dahua/src/main/java/com/example/dahua/service/imp/UserServiceImp.java
@@ -117,4 +117,23 @@ public class UserServiceImp implements UserService { @@ -117,4 +117,23 @@ public class UserServiceImp implements UserService {
117 return false; 117 return false;
118 } 118 }
119 119
  120 + @Override
  121 + public String getUserId(String code,String schoolId) {
  122 +
  123 + String userId = "";
  124 +
  125 +
  126 + userId = userDao.getStuWithCode(code);
  127 +
  128 + if (StringUtils.isEmpty(userId)){
  129 +
  130 + TeacherBean teacherBean = userDao.getTeacher(schoolId,code);
  131 + userId = teacherBean.getUser_id();
  132 +
  133 + }
  134 +
  135 + return userId;
  136 + }
  137 +
  138 +
120 } 139 }
cloud/dahua/src/main/java/com/example/dahua/utils/BaiduUtils.java
1 package com.example.dahua.utils; 1 package com.example.dahua.utils;
2 2
  3 +import com.alibaba.fastjson.JSON;
3 import com.example.dahua.async.ImageUtils; 4 import com.example.dahua.async.ImageUtils;
4 import com.example.dahua.lib.CompressPic; 5 import com.example.dahua.lib.CompressPic;
5 import org.json.JSONArray; 6 import org.json.JSONArray;
@@ -9,10 +10,7 @@ import javax.imageio.stream.FileImageInputStream; @@ -9,10 +10,7 @@ import javax.imageio.stream.FileImageInputStream;
9 import java.io.*; 10 import java.io.*;
10 import java.net.HttpURLConnection; 11 import java.net.HttpURLConnection;
11 import java.net.URL; 12 import java.net.URL;
12 -import java.util.ArrayList;  
13 -import java.util.HashMap;  
14 -import java.util.List;  
15 -import java.util.Map; 13 +import java.util.*;
16 14
17 public class BaiduUtils { 15 public class BaiduUtils {
18 16
@@ -107,6 +105,21 @@ public class BaiduUtils { @@ -107,6 +105,21 @@ public class BaiduUtils {
107 return true; 105 return true;
108 } 106 }
109 107
  108 + /**
  109 + * 注册人脸到百度
  110 + * @param file
  111 + */
  112 + private void addToBaidu(File file) {
  113 +
  114 + //学籍号或者教职工编号
  115 + String userCode = file.getName().split("\\.")[0];
  116 +
  117 +
  118 +
  119 +// BaiduUtils.getBaiduUtils().addFace(file,)
  120 +
  121 + }
  122 +
110 //图片到byte数组 123 //图片到byte数组
111 public byte[] image2byte(String path) { 124 public byte[] image2byte(String path) {
112 byte[] data = null; 125 byte[] data = null;
@@ -208,4 +221,71 @@ public class BaiduUtils { @@ -208,4 +221,71 @@ public class BaiduUtils {
208 return null; 221 return null;
209 } 222 }
210 223
  224 +
  225 + //注册人脸
  226 + public String addFace(File img, String group_id, String user_id, String userInfo) {
  227 +
  228 + String url = "https://aip.baidubce.com/rest/2.0/face/v3/faceset/user/add";
  229 +
  230 +
  231 + try {
  232 + Map<String, Object> map = new HashMap<>();
  233 + map.put("image", Base64Util.encode(InputStream2ByteArray(img.getAbsolutePath())));
  234 + map.put("group_id", group_id);
  235 + map.put("user_id", user_id);
  236 + map.put("user_info", userInfo);
  237 +// map.put("liveness_control", "NORMAL");
  238 + map.put("image_type", "BASE64");
  239 + map.put("quality_control", "NORMAL");
  240 +
  241 + String param = GsonUtils.toJson(map);
  242 +
  243 + // 注意这里仅为了简化编码每一次请求都去获取access_token,线上环境access_token有过期时间, 客户端可自行缓存,过期后重新获取。
  244 +
  245 + String result = HttpUtil.post(url, getAuth(), "application/json", param);
  246 + System.out.println(result);
  247 + com.alibaba.fastjson.JSONObject jsonObject = JSON.parseObject(result);
  248 + String error_msg = jsonObject.getString("error_msg");
  249 + if (error_msg.equals("SUCCESS")) {
  250 +
  251 +// com.alibaba.fastjson.JSONObject faceResult = jsonObject.getJSONObject("result");
  252 +
  253 +// FacerecordBean facerecordBean = new FacerecordBean();
  254 +//
  255 +// facerecordBean.setFace_token(faceResult.getString("face_token"));
  256 +// facerecordBean.setGroup_id(group_id);
  257 +// facerecordBean.setIntime(simpleDateFormat.format(new Date()));
  258 +// facerecordBean.setUser_id(user_id);
  259 +//
  260 +// facerecordService.addFacerecord(facerecordBean);
  261 + return "注册成功";
  262 + } else {
  263 + return error_msg;
  264 + }
  265 +
  266 + } catch (Exception e) {
  267 + e.printStackTrace();
  268 + }
  269 + return "";
  270 + }
  271 +
  272 + private byte[] InputStream2ByteArray(String filePath) throws IOException {
  273 +
  274 + InputStream in = new FileInputStream(filePath);
  275 + byte[] data = toByteArray(in);
  276 + in.close();
  277 +
  278 + return data;
  279 + }
  280 +
  281 + private byte[] toByteArray(InputStream in) throws IOException {
  282 +
  283 + ByteArrayOutputStream out = new ByteArrayOutputStream();
  284 + byte[] buffer = new byte[1024 * 4];
  285 + int n = 0;
  286 + while ((n = in.read(buffer)) != -1) {
  287 + out.write(buffer, 0, n);
  288 + }
  289 + return out.toByteArray();
  290 + }
211 } 291 }
cloud/dahua/src/main/resources/mapper/usermapper.xml
@@ -18,5 +18,6 @@ @@ -18,5 +18,6 @@
18 18
19 </select> 19 </select>
20 20
21 - 21 +
  22 +
22 </mapper> 23 </mapper>
23 \ No newline at end of file 24 \ No newline at end of file
cloud/haikang/src/main/java/com/sincere/haikang/SchduleTask.java
@@ -2,6 +2,7 @@ package com.sincere.haikang; @@ -2,6 +2,7 @@ package com.sincere.haikang;
2 2
3 import com.sincere.haikang.async.SendUserAsync; 3 import com.sincere.haikang.async.SendUserAsync;
4 import com.sincere.haikang.bean.AttendanceBean; 4 import com.sincere.haikang.bean.AttendanceBean;
  5 +import com.sincere.haikang.bean.SIngleCardBean;
5 import com.sincere.haikang.bean.StudentBean; 6 import com.sincere.haikang.bean.StudentBean;
6 import com.sincere.haikang.dao.DeviceDao; 7 import com.sincere.haikang.dao.DeviceDao;
7 import com.sincere.haikang.dao.UserDao; 8 import com.sincere.haikang.dao.UserDao;
@@ -22,7 +23,9 @@ import org.springframework.util.StringUtils; @@ -22,7 +23,9 @@ import org.springframework.util.StringUtils;
22 import org.springframework.web.client.RestTemplate; 23 import org.springframework.web.client.RestTemplate;
23 24
24 import java.io.*; 25 import java.io.*;
  26 +import java.text.SimpleDateFormat;
25 import java.util.ArrayList; 27 import java.util.ArrayList;
  28 +import java.util.Date;
26 import java.util.List; 29 import java.util.List;
27 30
28 @Component 31 @Component
@@ -129,10 +132,13 @@ public class SchduleTask { @@ -129,10 +132,13 @@ public class SchduleTask {
129 String clientIds = ""; 132 String clientIds = "";
130 for (int i = 0; i < attendanceBeans.size(); i++) { 133 for (int i = 0; i < attendanceBeans.size(); i++) {
131 if (i < attendanceBeans.size() - 1) { 134 if (i < attendanceBeans.size() - 1) {
132 - if (attendanceBeans.get(i).getClint_type().equals("22")) { 135 + AttendanceBean attendanceBean = attendanceBeans.get(i);
  136 + System.out.println("attendanceBean:"+attendanceBean.toString());
  137 + String clint_type = attendanceBean.getClint_type();
  138 + if (null!=clint_type&&clint_type.equals("22")) {
133 type = 22; 139 type = 22;
134 clientIds += attendanceBeans.get(i).getClint_id() + ","; 140 clientIds += attendanceBeans.get(i).getClint_id() + ",";
135 - } else if (attendanceBeans.get(i).getClint_type().equals("18")) { 141 + } else if (null!=clint_type&&clint_type.equals("18")) {
136 type = 18; 142 type = 18;
137 clientIds += attendanceBeans.get(i).getClint_id(); 143 clientIds += attendanceBeans.get(i).getClint_id();
138 } 144 }
@@ -167,13 +173,46 @@ public class SchduleTask { @@ -167,13 +173,46 @@ public class SchduleTask {
167 int SchoolId = studentBean.getSchoolId(); 173 int SchoolId = studentBean.getSchoolId();
168 String card = TextUtils.isEmpty(studentBean.getCard()) ? studentBean.getOldCard() : studentBean.getCard(); 174 String card = TextUtils.isEmpty(studentBean.getCard()) ? studentBean.getOldCard() : studentBean.getCard();
169 if (!TextUtils.isEmpty(card)) { 175 if (!TextUtils.isEmpty(card)) {
170 - RestTemplate restTemplate = new RestTemplate();  
171 - HttpHeaders headers = new HttpHeaders();  
172 - headers.setContentType(MediaType.APPLICATION_JSON_UTF8);  
173 - String url = "http://campus.myjxt.com/api/OneCard/SendSingle?SchoolId=" + SchoolId + "&Card=" + card + "&ClassId=" + studentBean.getClassId();  
174 - System.out.println("下发卡号url:" + url);  
175 - ResponseEntity<String> responseEntity = restTemplate.getForEntity(url, String.class);  
176 - System.out.println("下发卡号:" + responseEntity.getBody()); 176 +
  177 + List<AttendanceBean> attendanceBeans = deviceDao.getAttendancesWithSchoolId(SchoolId);
  178 +
  179 + for (int i = 0; i < attendanceBeans.size(); i++) {
  180 +
  181 + AttendanceBean attendanceBean = attendanceBeans.get(i);
  182 +
  183 + String clint_type = attendanceBean.getClint_type();
  184 +
  185 + if (null!=clint_type&&clint_type.equals("6")){
  186 +
  187 + SIngleCardBean sIngleCardBean = new SIngleCardBean();
  188 +
  189 + sIngleCardBean.setCardNo(card);
  190 + sIngleCardBean.setEndTime("2050-09-04T00:52:22.510Z");
  191 + sIngleCardBean.setId("5");
  192 + sIngleCardBean.setShiduan("2");
  193 + sIngleCardBean.setSn(attendanceBean.getClint_id());
  194 + sIngleCardBean.setStartTime(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'").format(new Date()));
  195 + sIngleCardBean.setType("1");
  196 +
  197 + RestTemplate restTemplate = new RestTemplate();
  198 + HttpHeaders headers = new HttpHeaders();
  199 + MediaType mediaType = MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE);
  200 + headers.setContentType(mediaType);
  201 +// String url = "http://campus.myjxt.com/api/OneCard/SendSingle?SchoolId=" + SchoolId + "&Card=" + card + "&ClassId=" + studentBean.getClassId();
  202 +// System.out.println("下发卡号url:" + url);
  203 +// ResponseEntity<String> responseEntity = restTemplate.getForEntity(url, String.class);
  204 +// System.out.println("下发卡号:" + responseEntity.getBody());
  205 + System.out.println("sIngleCardBean:"+sIngleCardBean.toString());
  206 + String url = "http://121.40.109.21:9000/setSignalCardInfo";
  207 + HttpEntity<SIngleCardBean> httpEntity = new HttpEntity<>(sIngleCardBean,headers);
  208 + ResponseEntity<String> responseEntity = restTemplate.postForEntity(url,httpEntity,String.class);
  209 + System.out.println("下发卡号:" + responseEntity.getBody());
  210 +
  211 +
  212 + }
  213 +
  214 + }
  215 +
177 } 216 }
178 217
179 218
cloud/haikang/src/main/java/com/sincere/haikang/Test.java 0 → 100644
@@ -0,0 +1,17 @@ @@ -0,0 +1,17 @@
  1 +package com.sincere.haikang;
  2 +
  3 +import java.text.SimpleDateFormat;
  4 +import java.util.Date;
  5 +
  6 +public class Test {
  7 + static int i ;
  8 +
  9 + public static void main(String[] args) {
  10 +
  11 + int num = 2147483647 ;
  12 + long temp = num + 2L ;
  13 + System.out.println(num) ;
  14 +
  15 + }
  16 +
  17 +}
cloud/haikang/src/main/java/com/sincere/haikang/bean/SIngleCardBean.java 0 → 100644
@@ -0,0 +1,89 @@ @@ -0,0 +1,89 @@
  1 +package com.sincere.haikang.bean;
  2 +
  3 +import java.io.Serializable;
  4 +
  5 +public class SIngleCardBean implements Serializable {
  6 +
  7 + private String cardNo;
  8 +
  9 + private String endTime;
  10 +
  11 + private String id;
  12 +
  13 + private String shiduan;
  14 +
  15 + private String sn;
  16 +
  17 + private String startTime;
  18 +
  19 + private String type;
  20 +
  21 + public String getCardNo() {
  22 + return cardNo;
  23 + }
  24 +
  25 + public void setCardNo(String cardNo) {
  26 + this.cardNo = cardNo;
  27 + }
  28 +
  29 + public String getEndTime() {
  30 + return endTime;
  31 + }
  32 +
  33 + public void setEndTime(String endTime) {
  34 + this.endTime = endTime;
  35 + }
  36 +
  37 + public String getId() {
  38 + return id;
  39 + }
  40 +
  41 + public void setId(String id) {
  42 + this.id = id;
  43 + }
  44 +
  45 + public String getShiduan() {
  46 + return shiduan;
  47 + }
  48 +
  49 + public void setShiduan(String shiduan) {
  50 + this.shiduan = shiduan;
  51 + }
  52 +
  53 + public String getSn() {
  54 + return sn;
  55 + }
  56 +
  57 + public void setSn(String sn) {
  58 + this.sn = sn;
  59 + }
  60 +
  61 + public String getStartTime() {
  62 + return startTime;
  63 + }
  64 +
  65 + public void setStartTime(String startTime) {
  66 + this.startTime = startTime;
  67 + }
  68 +
  69 + public String getType() {
  70 + return type;
  71 + }
  72 +
  73 + public void setType(String type) {
  74 + this.type = type;
  75 + }
  76 +
  77 + @Override
  78 + public String toString() {
  79 + return "SIngleCardBean{" +
  80 + "cardNo='" + cardNo + '\'' +
  81 + ", endTime='" + endTime + '\'' +
  82 + ", id='" + id + '\'' +
  83 + ", shiduan='" + shiduan + '\'' +
  84 + ", sn='" + sn + '\'' +
  85 + ", startTime='" + startTime + '\'' +
  86 + ", type='" + type + '\'' +
  87 + '}';
  88 + }
  89 +}
cloud/haikangface/src/main/java/com/sincere/haikangface/CMSServer.java
@@ -57,20 +57,24 @@ public class CMSServer implements ApplicationRunner { @@ -57,20 +57,24 @@ public class CMSServer implements ApplicationRunner {
57 @Autowired 57 @Autowired
58 UserDao userDao; 58 UserDao userDao;
59 59
60 -  
61 @Autowired 60 @Autowired
62 SendRecordDao sendRecordDao; 61 SendRecordDao sendRecordDao;
63 62
64 //114.55.30.100 63 //114.55.30.100
65 //120.26.116.253 64 //120.26.116.253
66 -// private String ip_cloud = "120.26.116.253";  
67 -// private String ip_cloud = "192.168.71.242";  
68 - private String ip_cloud = "114.55.30.100"; 65 + private String ip_cloud = "120.26.116.253";
  66 +// private String ip_cloud = "172.16.2.43";
  67 +// private String ip_cloudQJ = "120.27.221.31";//枪机的图片和报警监听地址
  68 +// private String ip_cloud = "114.55.30.100";
  69 +// private String ip_cloud = "120.27.221.31";
  70 +// private String ip_cloud = "121.40.109.21";
  71 +
69 private String ip; 72 private String ip;
70 73
71 { 74 {
72 try { 75 try {
73 ip = InetAddress.getLocalHost().getHostAddress(); 76 ip = InetAddress.getLocalHost().getHostAddress();
  77 +// ip=ip_cloud;
74 // ip_cloud = ip; 78 // ip_cloud = ip;
75 } catch (UnknownHostException e) { 79 } catch (UnknownHostException e) {
76 e.printStackTrace(); 80 e.printStackTrace();
@@ -91,6 +95,15 @@ public class CMSServer implements ApplicationRunner { @@ -91,6 +95,15 @@ public class CMSServer implements ApplicationRunner {
91 //初始化报警监听 95 //初始化报警监听
92 initAlarm(); 96 initAlarm();
93 97
  98 + /* String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
  99 + BaiduFaceRecorder baiduFaceRecorder = new BaiduFaceRecorder();
  100 + baiduFaceRecorder.setName("name");
  101 + baiduFaceRecorder.setScore("11");
  102 + baiduFaceRecorder.setTime(time);
  103 + baiduFaceRecorder.setUserImgUrl("22");
  104 + baiduFaceRecorder.setUploadImgUrl("22");
  105 + userDao.insertBaiduFaceRecorder(baiduFaceRecorder);*/
  106 +
94 } 107 }
95 108
96 static HCEHomeCMS hCEhomeCMS = HCEHomeCMS.INSTANCE; 109 static HCEHomeCMS hCEhomeCMS = HCEHomeCMS.INSTANCE;
@@ -112,8 +125,8 @@ public class CMSServer implements ApplicationRunner { @@ -112,8 +125,8 @@ public class CMSServer implements ApplicationRunner {
112 fRegisterCallBack = new FRegisterCallBack(); 125 fRegisterCallBack = new FRegisterCallBack();
113 } 126 }
114 hCEhomeCMS.NET_ECMS_SetLogToFile(3, "C:/Ehomejavademo/EHomeSDKLog", false); 127 hCEhomeCMS.NET_ECMS_SetLogToFile(3, "C:/Ehomejavademo/EHomeSDKLog", false);
115 -  
116 struCMSListenPara.struAddress.szIP = ip.getBytes(); 128 struCMSListenPara.struAddress.szIP = ip.getBytes();
  129 +// System.out.println("ip--------------------------------------------:"+ip);
117 struCMSListenPara.struAddress.wPort = 7660; 130 struCMSListenPara.struAddress.wPort = 7660;
118 struCMSListenPara.fnCB = fRegisterCallBack; 131 struCMSListenPara.fnCB = fRegisterCallBack;
119 132
@@ -182,6 +195,9 @@ public class CMSServer implements ApplicationRunner { @@ -182,6 +195,9 @@ public class CMSServer implements ApplicationRunner {
182 195
183 // byte[] byIP = ip.getBytes(); 196 // byte[] byIP = ip.getBytes();
184 byte[] byIP = ip_cloud.getBytes(); 197 byte[] byIP = ip_cloud.getBytes();
  198 +
  199 +// if (deviceId.startsWith("qj")) byIP = ip_cloudQJ.getBytes();
  200 +
185 System.arraycopy(byIP, 0, pInBuffer.struUDPAlarmSever.szIP, 0, byIP.length); 201 System.arraycopy(byIP, 0, pInBuffer.struUDPAlarmSever.szIP, 0, byIP.length);
186 // TODO: 2020/8/27 人脸机类型为0 202 // TODO: 2020/8/27 人脸机类型为0
187 pInBuffer.dwAlarmServerType = 0; //报警服务器类型:0- 只支持UDP协议上报,1- 支持UDP、TCP两种协议上报 203 pInBuffer.dwAlarmServerType = 0; //报警服务器类型:0- 只支持UDP协议上报,1- 支持UDP、TCP两种协议上报
@@ -302,9 +318,10 @@ public class CMSServer implements ApplicationRunner { @@ -302,9 +318,10 @@ public class CMSServer implements ApplicationRunner {
302 public class PSS_Storage_Callback implements HCEHomeSS.EHomeSSStorageCallBack { 318 public class PSS_Storage_Callback implements HCEHomeSS.EHomeSSStorageCallBack {
303 319
304 public boolean invoke(NativeLong iHandle, String pFileName, Pointer pFileBuf, int dwFileLen, Pointer pFilePath, Pointer pUser) { 320 public boolean invoke(NativeLong iHandle, String pFileName, Pointer pFileBuf, int dwFileLen, Pointer pFilePath, Pointer pUser) {
305 - log.error("图片进来:{}" , pFileName); 321 +// log.error("图片进来:{}", pFileName);
306 String strPath = "C://EhomePicServer/"; 322 String strPath = "C://EhomePicServer/";
307 // System.out.println("pFileName:" + pFileName); 323 // System.out.println("pFileName:" + pFileName);
  324 + FileUtils.getInstance().writeLogs("文件名:" + pFileName, FileUtils.fileName);
308 pFileName = pFileName.replace("_", ""); 325 pFileName = pFileName.replace("_", "");
309 boolean isZhuaPai = false; 326 boolean isZhuaPai = false;
310 if (pFileName.contains("-")) {//人脸抓拍机抓拍到的图片 327 if (pFileName.contains("-")) {//人脸抓拍机抓拍到的图片
@@ -315,7 +332,6 @@ public class CMSServer implements ApplicationRunner { @@ -315,7 +332,6 @@ public class CMSServer implements ApplicationRunner {
315 } 332 }
316 333
317 String strFilePath = strPath + pFileName; 334 String strFilePath = strPath + pFileName;
318 - FileUtils.getInstance().writeLogs("文件名:" + pFileName, FileUtils.fileName);  
319 //保存抓拍到的人脸图片,比对通过后的图片资源 335 //保存抓拍到的人脸图片,比对通过后的图片资源
320 336
321 // System.out.println("文件保存回调函数:" + strFilePath); 337 // System.out.println("文件保存回调函数:" + strFilePath);
@@ -348,6 +364,7 @@ public class CMSServer implements ApplicationRunner { @@ -348,6 +364,7 @@ public class CMSServer implements ApplicationRunner {
348 fout.write(bytes); 364 fout.write(bytes);
349 fout.close(); 365 fout.close();
350 366
  367 +// if (ip_cloud.equals(ip_cloudQJ))
351 sendToKB(strFilePathFile); 368 sendToKB(strFilePathFile);
352 369
353 } catch (FileNotFoundException e) { 370 } catch (FileNotFoundException e) {
@@ -369,6 +386,8 @@ public class CMSServer implements ApplicationRunner { @@ -369,6 +386,8 @@ public class CMSServer implements ApplicationRunner {
369 } 386 }
370 } 387 }
371 388
  389 + Map<String, Long> userMap = new HashMap<>();
  390 +
372 /** 391 /**
373 * 发送人脸到看板 392 * 发送人脸到看板
374 * 393 *
@@ -377,69 +396,109 @@ public class CMSServer implements ApplicationRunner { @@ -377,69 +396,109 @@ public class CMSServer implements ApplicationRunner {
377 public void sendToKB(File strFilePathFile) { 396 public void sendToKB(File strFilePathFile) {
378 try { 397 try {
379 398
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()); 399 + log.error("开始识别.....");
  400 + String url = "http://120.26.116.253:9214/baiduapi/search/16";
  401 +
  402 + RestTemplate restTemplate = new RestTemplate();
  403 +
  404 + HttpHeaders headers = new HttpHeaders();
  405 + MediaType mediaType = MediaType.parseMediaType(MediaType.MULTIPART_FORM_DATA_VALUE);
  406 + headers.setContentType(mediaType);
  407 + MultiValueMap<String, Object> multiValueMap = new LinkedMultiValueMap<>();
  408 + FileSystemResource fileSystemResource = new FileSystemResource(strFilePathFile);
  409 +
  410 + multiValueMap.add("file ", fileSystemResource);
  411 + HttpEntity<MultiValueMap<String, Object>> httpEntity = new HttpEntity<>(multiValueMap, headers);
  412 +
  413 + ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, httpEntity, String.class);
  414 +// log.error("识别结果:{}", responseEntity.getBody());
  415 + JSONObject jsonObject = JSON.parseObject(responseEntity.getBody());
  416 +
  417 + String face = jsonObject.getString("data");
  418 + if (face.startsWith("face")||face.startsWith("pic")) return;
  419 +
  420 + JSONObject data = jsonObject.getJSONObject("data");
  421 + String error_msg = data.getString("error_msg");
  422 +
  423 + if (error_msg.equals("SUCCESS")) {//识别成功
  424 + JSONObject result = data.getJSONObject("result");
  425 + JSONArray user_list = result.getJSONArray("user_list");
  426 +
  427 + if (user_list != null && user_list.size() > 0) {
  428 +
  429 + for (int i = 0; i < user_list.size(); i++) {
  430 + JSONObject user = user_list.getJSONObject(i);
  431 +
  432 + String user_id = user.getString("user_id");
  433 + String score = user.getString("score");
  434 + double sc = Double.valueOf(score.split("\\.")[0]);
  435 + if (sc >= 60) {
  436 + System.out.println("user_id:" + user_id);
  437 + TeacherBean teacherBean = userDao.getTeacherWithUserId1(user_id);
  438 +
  439 + if (null != teacherBean) {
  440 + String date = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
  441 + String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
  442 + BaiduFaceRecorder baiduFaceRecorder = new BaiduFaceRecorder();
  443 + baiduFaceRecorder.setName(teacherBean.getName());
  444 + baiduFaceRecorder.setScore(sc+"");
  445 + baiduFaceRecorder.setTime(time);
  446 + baiduFaceRecorder.setUserImgUrl(teacherBean.getFace());
  447 + baiduFaceRecorder.setUploadImgUrl(strFilePathFile.getAbsolutePath().contains(date)?
  448 + "http://" + ip_cloud + ":8081/kms/services/rest/dataInfoService/downloadFile?id="+strFilePathFile.getName().substring(0,strFilePathFile.getName().indexOf(date)):strFilePathFile.getAbsolutePath());
  449 + baiduFaceRecorder.setUserId(user_id);
  450 + userDao.insertBaiduFaceRecorder(baiduFaceRecorder);
  451 +
  452 + if (TextUtils.isEmpty(teacherBean.getTeacer_num())) teacherBean.setTeacer_num(user_id);
  453 + teacherBean.setTime(time);
  454 +
  455 + if (userMap.containsKey(user_id)) {
  456 +
  457 + long value = userMap.get(user_id);
  458 + if ((System.currentTimeMillis() - value) / 1000 > 6) {
  459 + userMap.put(user_id, System.currentTimeMillis());
  460 + MqtUtils.getInstance().sendMsg("09EA8EB5142F2964", 1, teacherBean.toString());
  461 + log.error("发送成功.....");
  462 + }
  463 +
  464 + } else {
  465 + userMap.put(user_id, System.currentTimeMillis());
  466 + MqtUtils.getInstance().sendMsg("09EA8EB5142F2964", 1, teacherBean.toString());
  467 + log.error("发送成功.....");
  468 + }
  469 +
  470 +// strFilePathFile.deleteOnExit();
  471 + } else {
  472 + System.out.println("用户身份信息不存在");
  473 + sendNoPersonImg(strFilePathFile);
  474 + }
422 } else { 475 } else {
423 - System.out.println("用户身份信息不存在"); 476 + System.out.println("用户身份信息不存在" + score);
  477 + sendNoPersonImg(strFilePathFile);
424 } 478 }
425 - }else {  
426 - System.out.println("用户身份信息不存在"+score); 479 +
427 } 480 }
428 481
429 } 482 }
430 - 483 + } else {
  484 + System.out.println("识别失败:" + error_msg);
431 } 485 }
432 - } else {  
433 - System.out.println("识别失败:" + error_msg);  
434 - }  
435 - log.error("发送成功.....");  
436 // System.out.println("responseEntity:"+responseEntity.getBody()); 486 // System.out.println("responseEntity:"+responseEntity.getBody());
437 - }catch (Exception e){ 487 + } catch (Exception e) {
438 e.printStackTrace(); 488 e.printStackTrace();
439 } 489 }
440 490
441 } 491 }
442 492
  493 + private void sendNoPersonImg(File strFilePathFile) {
  494 + String imgName = strFilePathFile.getName();
  495 + String date = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
  496 + if (imgName.contains(date)) {
  497 + String imgId = imgName.substring(0, imgName.indexOf(date));
  498 + MqtUtils.getInstance().sendMsg("09EA8EB5142F2964", 2, "http://" + ip_cloud + ":8081/kms/services/rest/dataInfoService/downloadFile?id=" + imgId);
  499 + }
  500 + }
  501 +
443 HCEHomeAlarm.NET_EHOME_ALARM_LISTEN_PARAM net_ehome_alarm_listen_param = new HCEHomeAlarm.NET_EHOME_ALARM_LISTEN_PARAM(); 502 HCEHomeAlarm.NET_EHOME_ALARM_LISTEN_PARAM net_ehome_alarm_listen_param = new HCEHomeAlarm.NET_EHOME_ALARM_LISTEN_PARAM();
444 EHomeMsgCallBack cbEHomeMsgCallBack; 503 EHomeMsgCallBack cbEHomeMsgCallBack;
445 ;//报警监听回调函数实现 504 ;//报警监听回调函数实现
@@ -507,9 +566,9 @@ public class CMSServer implements ApplicationRunner { @@ -507,9 +566,9 @@ public class CMSServer implements ApplicationRunner {
507 566
508 String strXML = new String(strXMLData.byValue); 567 String strXML = new String(strXMLData.byValue);
509 // System.out.println(strXML); 568 // System.out.println(strXML);
510 -// log.error("报警监听:{}",strXML); 569 +// log.error("报警监听:{}", strXML);
511 if (null == alarmUtils) { 570 if (null == alarmUtils) {
512 - alarmUtils = new AlarmUtils(deviceDao); 571 + alarmUtils = new AlarmUtils(deviceDao,userDao);
513 alarmUtils.setCallBack(new AlarmUtils.AlarmCallBack() { 572 alarmUtils.setCallBack(new AlarmUtils.AlarmCallBack() {
514 @Override 573 @Override
515 public void callBack(String minorType, String deviceID, String cardNo, String time, String picDataUrlId, String currTemperature) { 574 public void callBack(String minorType, String deviceID, String cardNo, String time, String picDataUrlId, String currTemperature) {
@@ -563,7 +622,7 @@ public class CMSServer implements ApplicationRunner { @@ -563,7 +622,7 @@ public class CMSServer implements ApplicationRunner {
563 cardNo = sendRecoderUtils.getCard(card); 622 cardNo = sendRecoderUtils.getCard(card);
564 623
565 StudentBean studentBean = userDao.getStudentWithCard(cardNo); 624 StudentBean studentBean = userDao.getStudentWithCard(cardNo);
566 - log.error("studentBean:{}",studentBean); 625 + log.error("studentBean:{}", studentBean);
567 if (null != studentBean) { 626 if (null != studentBean) {
568 FileUtils.getInstance().writeLogs(studentBean.getName() + " " + cardNo, FileUtils.facerecoder); 627 FileUtils.getInstance().writeLogs(studentBean.getName() + " " + cardNo, FileUtils.facerecoder);
569 628
@@ -589,9 +648,9 @@ public class CMSServer implements ApplicationRunner { @@ -589,9 +648,9 @@ public class CMSServer implements ApplicationRunner {
589 isTeacher(cardNo, deviceID); 648 isTeacher(cardNo, deviceID);
590 } 649 }
591 650
592 - if (deviceID.startsWith("qj")) {//枪击 用来抓拍人脸考勤用  
593 - initQJ(deviceID, cardNo, studentBean == null);  
594 - } 651 +// if (deviceID.startsWith("qj")) {//枪击 用来抓拍人脸考勤用
  652 +// initQJ(deviceID, cardNo, studentBean == null);
  653 +// }
595 654
596 } 655 }
597 656
@@ -614,12 +673,12 @@ public class CMSServer implements ApplicationRunner { @@ -614,12 +673,12 @@ public class CMSServer implements ApplicationRunner {
614 public void isTeacher(String cardNo, String deviceID) { 673 public void isTeacher(String cardNo, String deviceID) {
615 674
616 List<String> devLists = userDao.getDeviceRoomRelation(deviceID); 675 List<String> devLists = userDao.getDeviceRoomRelation(deviceID);
617 - log.error("cardNo:{},devLists{}",cardNo,devLists); 676 + log.error("cardNo:{},devLists{}", cardNo, devLists);
618 677
619 if (null != devLists && devLists.size() > 0) { 678 if (null != devLists && devLists.size() > 0) {
620 679
621 StudentBean teacher = userDao.getTeacherWithCard(cardNo); 680 StudentBean teacher = userDao.getTeacherWithCard(cardNo);
622 - FileUtils.getInstance().writeLogs("teacher:" + teacher+"----"+cardNo, "教师点名.txt"); 681 + FileUtils.getInstance().writeLogs("teacher:" + teacher + "----" + cardNo, "教师点名.txt");
623 if (null != teacher) { 682 if (null != teacher) {
624 String url = String.format("http://campus.myjxt.com/api/RollCall/AddRollCallPersonnelRecord?userId=%s&deviceId=%s", teacher.getUser_id(), deviceID); 683 String url = String.format("http://campus.myjxt.com/api/RollCall/AddRollCallPersonnelRecord?userId=%s&deviceId=%s", teacher.getUser_id(), deviceID);
625 684
cloud/haikangface/src/main/java/com/sincere/haikangface/QieTuClass.java
1 package com.sincere.haikangface; 1 package com.sincere.haikangface;
2 2
  3 +import com.sincere.haikangface.mqtt.MqtUtils;
3 import com.sincere.haikangface.utils.ApiUtil; 4 import com.sincere.haikangface.utils.ApiUtil;
4 import com.sun.imageio.plugins.common.ImageUtil; 5 import com.sun.imageio.plugins.common.ImageUtil;
5 import org.json.JSONArray; 6 import org.json.JSONArray;
@@ -11,13 +12,21 @@ import java.awt.image.FilteredImageSource; @@ -11,13 +12,21 @@ import java.awt.image.FilteredImageSource;
11 import java.awt.image.ImageFilter; 12 import java.awt.image.ImageFilter;
12 import java.io.File; 13 import java.io.File;
13 import java.io.IOException; 14 import java.io.IOException;
  15 +import java.text.SimpleDateFormat;
  16 +import java.util.Date;
14 17
15 public class QieTuClass extends JFrame { 18 public class QieTuClass extends JFrame {
16 19
17 20
18 public static void main(String[] args) { 21 public static void main(String[] args) {
  22 + String imgName = "43539917634D4EED364DEC87D8DEC2462020-09-01.jpg";
  23 + String date = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
  24 + if (imgName.contains(date)) {
  25 + String imgId = imgName.substring(0, imgName.indexOf(date));
  26 + System.out.println("imgId:"+imgId);
  27 + }
19 28
20 - new QieTuClass(); 29 +// new QieTuClass();
21 30
22 } 31 }
23 32
cloud/haikangface/src/main/java/com/sincere/haikangface/async/SendUserAsync.java
@@ -48,6 +48,7 @@ public class SendUserAsync { @@ -48,6 +48,7 @@ public class SendUserAsync {
48 if (check) {//合格 48 if (check) {//合格
49 //根据设备是5603 还是新设备 49 //根据设备是5603 还是新设备
50 String employeeNo = ""; 50 String employeeNo = "";
  51 + boolean result = cmsServer.createImgPath(srcFile, picUrl, card, startTime, endTime, validTimeEnabled, name, deviceId, userType, employeeNo);
51 if (deviceId.contains("ymzx") || deviceId.contains("5607") || deviceId.contains("5671") || deviceId.contains("5604")) { 52 if (deviceId.contains("ymzx") || deviceId.contains("5607") || deviceId.contains("5671") || deviceId.contains("5604")) {
52 long lon = Long.parseLong(card); 53 long lon = Long.parseLong(card);
53 //十六进制卡号 54 //十六进制卡号
@@ -67,15 +68,14 @@ public class SendUserAsync { @@ -67,15 +68,14 @@ public class SendUserAsync {
67 } else 68 } else
68 employeeNo = studentBean.getStudent_id(); 69 employeeNo = studentBean.getStudent_id();
69 } 70 }
70 -// cmsServer.SetCardWeekPlan(deviceId, card, userType, HKXmlUtils.getInstance().SetCardTemplate(), "设置卡权限计划模板");  
71 -// cmsServer.SetCardWeekPlan(deviceId, card, userType, HKXmlUtils.getInstance().SetCardWeekPlan(), "卡权限周计划");  
72 -// for (int i = 0; i < 7; i++) {  
73 -// cmsServer.SetCardWeekPlan(deviceId, card, userType, HKXmlUtils.getInstance().SetCardWeekPlanTime(HKXmlUtils.getInstance().SetCardWeekPlanTimes("00:00:00", "23:00:00"), "" + i), "设置卡权限周计划时间");  
74 -// }  
75 -// cmsServer.SetCardWeekPlan(deviceId, card, userType, HKXmlUtils.getInstance().SetCardRightCfg(card), "设置卡权限"); 71 + cmsServer.SetCardWeekPlan(deviceId, card, userType, HKXmlUtils.getInstance().SetCardTemplate(), "设置卡权限计划模板");
  72 + cmsServer.SetCardWeekPlan(deviceId, card, userType, HKXmlUtils.getInstance().SetCardWeekPlan(), "卡权限周计划");
  73 + for (int i = 0; i < 7; i++) {
  74 + cmsServer.SetCardWeekPlan(deviceId, card, userType, HKXmlUtils.getInstance().SetCardWeekPlanTime(HKXmlUtils.getInstance().SetCardWeekPlanTimes("00:00:00", "23:00:00"), "" + i), "设置卡权限周计划时间");
  75 + }
  76 + cmsServer.SetCardWeekPlan(deviceId, card, userType, HKXmlUtils.getInstance().SetCardRightCfg(card), "设置卡权限");
76 } 77 }
77 78
78 - boolean result = cmsServer.createImgPath(srcFile, picUrl, card, startTime, endTime, validTimeEnabled, name, deviceId, userType, employeeNo);  
79 } else {//不合格 79 } else {//不合格
80 sendRecoderUtils.sendFail(sendRecordDao, card, srcFile, deviceId, userDao, "人脸照片不合格", userType); 80 sendRecoderUtils.sendFail(sendRecordDao, card, srcFile, deviceId, userDao, "人脸照片不合格", userType);
81 } 81 }
cloud/haikangface/src/main/java/com/sincere/haikangface/bean/BaiduFaceRecorder.java 0 → 100644
@@ -0,0 +1,78 @@ @@ -0,0 +1,78 @@
  1 +package com.sincere.haikangface.bean;
  2 +
  3 +import java.io.Serializable;
  4 +
  5 +public class BaiduFaceRecorder implements Serializable {
  6 +
  7 + private String name;
  8 +
  9 + private String userId;
  10 +
  11 + private String score;
  12 +
  13 + private String time;
  14 +
  15 + private String uploadImgUrl;
  16 +
  17 + private String userImgUrl;
  18 +
  19 + public String getName() {
  20 + return name;
  21 + }
  22 +
  23 + public void setName(String name) {
  24 + this.name = name;
  25 + }
  26 +
  27 + public String getUserId() {
  28 + return userId;
  29 + }
  30 +
  31 + public void setUserId(String userId) {
  32 + this.userId = userId;
  33 + }
  34 +
  35 + public String getScore() {
  36 + return score;
  37 + }
  38 +
  39 + public void setScore(String score) {
  40 + this.score = score;
  41 + }
  42 +
  43 + public String getTime() {
  44 + return time;
  45 + }
  46 +
  47 + public void setTime(String time) {
  48 + this.time = time;
  49 + }
  50 +
  51 + public String getUploadImgUrl() {
  52 + return uploadImgUrl;
  53 + }
  54 +
  55 + public void setUploadImgUrl(String uploadImgUrl) {
  56 + this.uploadImgUrl = uploadImgUrl;
  57 + }
  58 +
  59 + public String getUserImgUrl() {
  60 + return userImgUrl;
  61 + }
  62 +
  63 + public void setUserImgUrl(String userImgUrl) {
  64 + this.userImgUrl = userImgUrl;
  65 + }
  66 +
  67 + @Override
  68 + public String toString() {
  69 + return "BaiduFaceRecorder{" +
  70 + "name='" + name + '\'' +
  71 + ", userId='" + userId + '\'' +
  72 + ", score='" + score + '\'' +
  73 + ", time='" + time + '\'' +
  74 + ", uploadImgUrl='" + uploadImgUrl + '\'' +
  75 + ", userImgUrl='" + userImgUrl + '\'' +
  76 + '}';
  77 + }
  78 +}
cloud/haikangface/src/main/java/com/sincere/haikangface/bean/TeacherBean.java
@@ -12,6 +12,16 @@ public class TeacherBean implements Serializable { @@ -12,6 +12,16 @@ public class TeacherBean implements Serializable {
12 12
13 private String face; 13 private String face;
14 14
  15 + private String time;
  16 +
  17 + public String getTime() {
  18 + return time;
  19 + }
  20 +
  21 + public void setTime(String time) {
  22 + this.time = time;
  23 + }
  24 +
15 public String getTeacher_num() { 25 public String getTeacher_num() {
16 return teacher_num; 26 return teacher_num;
17 } 27 }
@@ -57,6 +67,7 @@ public class TeacherBean implements Serializable { @@ -57,6 +67,7 @@ public class TeacherBean implements Serializable {
57 return "{\"name\":\"" + name + '\"' + 67 return "{\"name\":\"" + name + '\"' +
58 ", \"teacher_num\":\"" + teacher_num + '\"' + 68 ", \"teacher_num\":\"" + teacher_num + '\"' +
59 ", \"num\":\"" + num + '\"' + 69 ", \"num\":\"" + num + '\"' +
  70 + ",\"time\":\""+time+'\"'+
60 ", \"face\":\"" + face + '\"' +"}"; 71 ", \"face\":\"" + face + '\"' +"}";
61 } 72 }
62 } 73 }
cloud/haikangface/src/main/java/com/sincere/haikangface/control/UserControl.java
@@ -348,9 +348,8 @@ public class UserControl { @@ -348,9 +348,8 @@ public class UserControl {
348 @RequestMapping(value = "getCard", method = RequestMethod.GET) 348 @RequestMapping(value = "getCard", method = RequestMethod.GET)
349 @ApiOperation("获取设备人脸是否存在") 349 @ApiOperation("获取设备人脸是否存在")
350 public boolean getCard(@RequestParam("deviceId") String deviceId, @RequestParam("card") String card) { 350 public boolean getCard(@RequestParam("deviceId") String deviceId, @RequestParam("card") String card) {
351 - cmsServer.getFace(deviceId, Long.parseLong(getCard(card), 16) + "");  
352 // HttpUtil.getCard(deviceId,card); 351 // HttpUtil.getCard(deviceId,card);
353 - return true; 352 + return cmsServer.getFace(deviceId, Long.parseLong(getCard(card), 16) + "");
354 } 353 }
355 354
356 @RequestMapping(value = "IsDeviceOnline", method = RequestMethod.GET) 355 @RequestMapping(value = "IsDeviceOnline", method = RequestMethod.GET)
cloud/haikangface/src/main/java/com/sincere/haikangface/dao/UserDao.java
@@ -248,5 +248,6 @@ public interface UserDao { @@ -248,5 +248,6 @@ public interface UserDao {
248 248
249 List<String> getDeviceRoomRelation(@Param("clint_id") String clint_id); 249 List<String> getDeviceRoomRelation(@Param("clint_id") String clint_id);
250 250
  251 + void insertBaiduFaceRecorder(BaiduFaceRecorder baiduFaceRecorder);
251 252
252 } 253 }
cloud/haikangface/src/main/java/com/sincere/haikangface/mqtt/MqttManager.java
@@ -3,6 +3,7 @@ package com.sincere.haikangface.mqtt; @@ -3,6 +3,7 @@ package com.sincere.haikangface.mqtt;
3 import org.eclipse.paho.client.mqttv3.*; 3 import org.eclipse.paho.client.mqttv3.*;
4 import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence; 4 import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
5 5
  6 +import java.io.UnsupportedEncodingException;
6 import java.security.InvalidKeyException; 7 import java.security.InvalidKeyException;
7 import java.security.NoSuchAlgorithmException; 8 import java.security.NoSuchAlgorithmException;
8 9
@@ -112,7 +113,12 @@ public class MqttManager { @@ -112,7 +113,12 @@ public class MqttManager {
112 String recvClientId = groupId + "@@@" + deviceId; 113 String recvClientId = groupId + "@@@" + deviceId;
113 final String p2pSendTopic = topic + "/p2p/" + recvClientId; 114 final String p2pSendTopic = topic + "/p2p/" + recvClientId;
114 String content = "{\"cmd\":\"" + cmd + "\",\"clientId\":\"\",\"data\": " + msg + "}"; 115 String content = "{\"cmd\":\"" + cmd + "\",\"clientId\":\"\",\"data\": " + msg + "}";
115 - MqttMessage message = new MqttMessage(content.getBytes()); 116 + MqttMessage message = null;
  117 + try {
  118 + message = new MqttMessage(content.getBytes("GB2312"));
  119 + } catch (UnsupportedEncodingException e) {
  120 + e.printStackTrace();
  121 + }
116 message.setQos(qosLevel); 122 message.setQos(qosLevel);
117 System.out.println("发送内容:" + p2pSendTopic + " msg:---------" + msg); 123 System.out.println("发送内容:" + p2pSendTopic + " msg:---------" + msg);
118 if (null != mqttClient) { 124 if (null != mqttClient) {
cloud/haikangface/src/main/java/com/sincere/haikangface/utils/AlarmUtils.java
1 package com.sincere.haikangface.utils; 1 package com.sincere.haikangface.utils;
2 2
  3 +import com.sincere.haikangface.bean.BaiduFaceRecorder;
3 import com.sincere.haikangface.bean.FaceWaterRecoder; 4 import com.sincere.haikangface.bean.FaceWaterRecoder;
4 import com.sincere.haikangface.dao.DeviceDao; 5 import com.sincere.haikangface.dao.DeviceDao;
  6 +import com.sincere.haikangface.dao.UserDao;
5 import org.springframework.stereotype.Component; 7 import org.springframework.stereotype.Component;
6 import org.springframework.util.StringUtils; 8 import org.springframework.util.StringUtils;
7 9
@@ -17,6 +19,8 @@ public class AlarmUtils { @@ -17,6 +19,8 @@ public class AlarmUtils {
17 19
18 private DeviceDao deviceDao; 20 private DeviceDao deviceDao;
19 21
  22 + private UserDao userDao;
  23 +
20 private AlarmCallBack alarmCallBack; 24 private AlarmCallBack alarmCallBack;
21 25
22 // public static AlarmUtils getInstance(DeviceDao deviceDao) { 26 // public static AlarmUtils getInstance(DeviceDao deviceDao) {
@@ -28,8 +32,9 @@ public class AlarmUtils { @@ -28,8 +32,9 @@ public class AlarmUtils {
28 // return alarmUtils; 32 // return alarmUtils;
29 // } 33 // }
30 34
31 - public AlarmUtils(DeviceDao deviceDao) { 35 + public AlarmUtils(DeviceDao deviceDao, UserDao userDao) {
32 this.deviceDao = deviceDao; 36 this.deviceDao = deviceDao;
  37 + this.userDao = userDao;
33 } 38 }
34 39
35 public void setCallBack(AlarmCallBack alarmCallBack) { 40 public void setCallBack(AlarmCallBack alarmCallBack) {
@@ -41,9 +46,22 @@ public class AlarmUtils { @@ -41,9 +46,22 @@ public class AlarmUtils {
41 } 46 }
42 47
43 public void deleAlarm(String strXML) { 48 public void deleAlarm(String strXML) {
44 - 49 + System.out.println("人脸抓拍机:" + strXML);
45 if (strXML.contains("FACESNAPREPORT")) {//人脸抓拍机器 50 if (strXML.contains("FACESNAPREPORT")) {//人脸抓拍机器
46 51
  52 +// System.out.println("人脸抓拍机:" + strXML);
  53 + BaiduFaceRecorder baiduFaceRecorder = new BaiduFaceRecorder();
  54 + baiduFaceRecorder.setUploadImgUrl(strXML);
  55 + baiduFaceRecorder.setTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
  56 + userDao.insertBaiduFaceRecorder(baiduFaceRecorder);
  57 +
  58 + String deviceId = strXML.substring(strXML.indexOf("DeviceID"),strXML.lastIndexOf("DeviceID")).trim();
  59 + deviceId = deviceId.replace("DeviceID>","");
  60 + deviceId = deviceId.replace("</","");
  61 +
  62 +// if (null != alarmCallBack)
  63 +// alarmCallBack.callBack(minorType, deviceID, cardNo, time, picDataUrlId, currTemperature);
  64 +
47 } else {//人脸识别 65 } else {//人脸识别
48 66
49 //主类型 67 //主类型
cloud/haikangface/src/main/resources/mapper/usermapper.xml
@@ -22,4 +22,9 @@ @@ -22,4 +22,9 @@
22 select clint_id from SZ_DeviceRoomRelation where clint_id = #{clint_id} and state = 1; 22 select clint_id from SZ_DeviceRoomRelation where clint_id = #{clint_id} and state = 1;
23 </select> 23 </select>
24 24
  25 + <insert id="insertBaiduFaceRecorder" parameterType="com.sincere.haikangface.bean.BaiduFaceRecorder">
  26 +
  27 + insert into BaiduFaceRecorder values (#{name},#{userId},#{score},#{time},#{uploadImgUrl},#{userImgUrl})
  28 +
  29 + </insert>
25 </mapper> 30 </mapper>