Commit 2cbbb1644bd6bb3b5c9aec6b383c37a08e80924c
1 parent
1232df0d
Exists in
master
智能校卫:海康、大华人脸机代码提交
Showing
48 changed files
with
2404 additions
and
1411 deletions
 
Show diff stats
cloud/dahua/src/main/java/com/example/dahua/MyTask.java
| @@ -72,6 +72,8 @@ public class MyTask implements ApplicationRunner { | @@ -72,6 +72,8 @@ public class MyTask implements ApplicationRunner { | ||
| 72 | //设备断线 | 72 | //设备断线 | 
| 73 | public static boolean isFirstAutoRegister = false; | 73 | public static boolean isFirstAutoRegister = false; | 
| 74 | 74 | ||
| 75 | + public static String inTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); | ||
| 76 | + | ||
| 75 | @Override | 77 | @Override | 
| 76 | public void run(ApplicationArguments args) throws Exception { | 78 | public void run(ApplicationArguments args) throws Exception { | 
| 77 | 79 | ||
| @@ -141,7 +143,7 @@ public class MyTask implements ApplicationRunner { | @@ -141,7 +143,7 @@ public class MyTask implements ApplicationRunner { | ||
| 141 | String deviceId = getDeviceId(pchDVRIP, nDVRPort); | 143 | String deviceId = getDeviceId(pchDVRIP, nDVRPort); | 
| 142 | log.info("DisConnect Device: {}, IP: {}, Port: {}",deviceId,pchDVRIP,nDVRPort); | 144 | log.info("DisConnect Device: {}, IP: {}, Port: {}",deviceId,pchDVRIP,nDVRPort); | 
| 143 | if (!StringUtils.isEmpty(deviceId)) { | 145 | if (!StringUtils.isEmpty(deviceId)) { | 
| 144 | - myTaskUtil.attendanceService.updateConnectStateWithDevid(0, deviceId); | 146 | + myTaskUtil.attendanceService.updateConnectStateWithDevid(0,inTime,deviceId); | 
| 145 | GateModule.stopRealLoadPic(attachLongMap.get(deviceId)); | 147 | GateModule.stopRealLoadPic(attachLongMap.get(deviceId)); | 
| 146 | //移除在线 | 148 | //移除在线 | 
| 147 | removeDevice(deviceId); | 149 | removeDevice(deviceId); | 
| @@ -167,7 +169,7 @@ public class MyTask implements ApplicationRunner { | @@ -167,7 +169,7 @@ public class MyTask implements ApplicationRunner { | ||
| 167 | String deviceId = getDeviceId(pchDVRIP, nDVRPort); | 169 | String deviceId = getDeviceId(pchDVRIP, nDVRPort); | 
| 168 | log.info("ReConnect Device: {},IP: {},Port: {}", deviceId,pchDVRIP, nDVRPort); | 170 | log.info("ReConnect Device: {},IP: {},Port: {}", deviceId,pchDVRIP, nDVRPort); | 
| 169 | if (!StringUtils.isEmpty(deviceId)) { | 171 | if (!StringUtils.isEmpty(deviceId)) { | 
| 170 | - myTaskUtil.attendanceService.updateConnectStateWithDevid(1, deviceId); | 172 | + myTaskUtil.attendanceService.updateConnectStateWithDevid(1,inTime,deviceId); | 
| 171 | DeviceInfoBean deviceInfoBean = new DeviceInfoBean(); | 173 | DeviceInfoBean deviceInfoBean = new DeviceInfoBean(); | 
| 172 | deviceInfoBean.setDevcieId(deviceId); | 174 | deviceInfoBean.setDevcieId(deviceId); | 
| 173 | deviceInfoBean.setDeviceIp(pchDVRIP); | 175 | deviceInfoBean.setDeviceIp(pchDVRIP); | 
| @@ -223,6 +225,8 @@ public class MyTask implements ApplicationRunner { | @@ -223,6 +225,8 @@ public class MyTask implements ApplicationRunner { | ||
| 223 | case NetSDKLib.EM_LISTEN_TYPE.NET_DVR_SERIAL_RETURN: { // 设备注册携带序列号 | 225 | case NetSDKLib.EM_LISTEN_TYPE.NET_DVR_SERIAL_RETURN: { // 设备注册携带序列号 | 
| 224 | log.info("Register Device Info Device address: {},port: {},DeviceID: {}", pIp, wPort, deviceId); | 226 | log.info("Register Device Info Device address: {},port: {},DeviceID: {}", pIp, wPort, deviceId); | 
| 225 | log.info("EM_LISTEN_TYPE:设备注册携带序列号"); | 227 | log.info("EM_LISTEN_TYPE:设备注册携带序列号"); | 
| 228 | + //保存设备 | ||
| 229 | + saveAttendanceService(deviceId,pIp,wPort); | ||
| 226 | CDevInfo dev = new CDevInfo(); | 230 | CDevInfo dev = new CDevInfo(); | 
| 227 | System.arraycopy(pIp.getBytes(),0,dev.address,0,pIp.getBytes().length); | 231 | System.arraycopy(pIp.getBytes(),0,dev.address,0,pIp.getBytes().length); | 
| 228 | dev.port=wPort; | 232 | dev.port=wPort; | 
| @@ -352,8 +356,6 @@ public class MyTask implements ApplicationRunner { | @@ -352,8 +356,6 @@ public class MyTask implements ApplicationRunner { | ||
| 352 | //下发句柄 | 356 | //下发句柄 | 
| 353 | lLongSendMap.put(deviceId, m_hLoginHandle); | 357 | lLongSendMap.put(deviceId, m_hLoginHandle); | 
| 354 | addDeviceInfo(deviceId,address,port,m_hLoginHandle); | 358 | addDeviceInfo(deviceId,address,port,m_hLoginHandle); | 
| 355 | - //保存设备 | ||
| 356 | - saveAttendanceService(deviceId,address,port); | ||
| 357 | } | 359 | } | 
| 358 | 360 | ||
| 359 | 361 | ||
| @@ -568,7 +570,6 @@ public class MyTask implements ApplicationRunner { | @@ -568,7 +570,6 @@ public class MyTask implements ApplicationRunner { | ||
| 568 | * @param port | 570 | * @param port | 
| 569 | */ | 571 | */ | 
| 570 | private static void saveAttendanceService(String deviceId, String ip, int port){ | 572 | private static void saveAttendanceService(String deviceId, String ip, int port){ | 
| 571 | - String inTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); | ||
| 572 | String clintType = String.valueOf(EnumDeviceType.DH_FACE.deviceType); | 573 | String clintType = String.valueOf(EnumDeviceType.DH_FACE.deviceType); | 
| 573 | if(deviceId.startsWith("ytj")){ | 574 | if(deviceId.startsWith("ytj")){ | 
| 574 | clintType = String.valueOf(EnumDeviceType.DH_FACE_YTJ.deviceType); | 575 | clintType = String.valueOf(EnumDeviceType.DH_FACE_YTJ.deviceType); | 
cloud/dahua/src/main/java/com/example/dahua/async/SendUserInfoTask2.java
| @@ -3,32 +3,31 @@ package com.example.dahua.async; | @@ -3,32 +3,31 @@ package com.example.dahua.async; | ||
| 3 | import com.alibaba.fastjson.JSON; | 3 | import com.alibaba.fastjson.JSON; | 
| 4 | import com.example.dahua.MyTask; | 4 | import com.example.dahua.MyTask; | 
| 5 | import com.example.dahua.bean.*; | 5 | import com.example.dahua.bean.*; | 
| 6 | -import com.example.dahua.common.Res; | 6 | +import com.example.dahua.control.FileControl; | 
| 7 | import com.example.dahua.dao.UserDao; | 7 | import com.example.dahua.dao.UserDao; | 
| 8 | -import com.example.dahua.enums.*; | 8 | +import com.example.dahua.enums.EnumDeviceType; | 
| 9 | +import com.example.dahua.enums.EnumSendFaceType; | ||
| 10 | +import com.example.dahua.enums.EnumSzBusinessType; | ||
| 9 | import com.example.dahua.lib.CompressPic; | 11 | import com.example.dahua.lib.CompressPic; | 
| 10 | import com.example.dahua.lib.FilePath; | 12 | import com.example.dahua.lib.FilePath; | 
| 11 | import com.example.dahua.lib.NetSDKLib; | 13 | import com.example.dahua.lib.NetSDKLib; | 
| 12 | -import com.example.dahua.lib.ToolKits; | ||
| 13 | -import com.example.dahua.module.GateModule; | ||
| 14 | import com.example.dahua.module.GateModule2; | 14 | import com.example.dahua.module.GateModule2; | 
| 15 | import com.example.dahua.service.PermissFaceService; | 15 | import com.example.dahua.service.PermissFaceService; | 
| 16 | +import com.example.dahua.service.imp.BaseService; | ||
| 16 | import com.example.dahua.utils.FileUtils; | 17 | import com.example.dahua.utils.FileUtils; | 
| 17 | import com.example.dahua.utils.HttpUtils; | 18 | import com.example.dahua.utils.HttpUtils; | 
| 18 | import com.example.dahua.utils.JsonUtils; | 19 | import com.example.dahua.utils.JsonUtils; | 
| 19 | import com.example.dahua.xiananDao.SendRecordDao; | 20 | import com.example.dahua.xiananDao.SendRecordDao; | 
| 20 | -import com.sun.jna.Memory; | ||
| 21 | import lombok.extern.slf4j.Slf4j; | 21 | import lombok.extern.slf4j.Slf4j; | 
| 22 | import org.springframework.beans.factory.annotation.Autowired; | 22 | import org.springframework.beans.factory.annotation.Autowired; | 
| 23 | -import org.springframework.http.ResponseEntity; | ||
| 24 | -import org.springframework.scheduling.annotation.Async; | ||
| 25 | import org.springframework.stereotype.Component; | 23 | import org.springframework.stereotype.Component; | 
| 26 | import org.springframework.util.StringUtils; | 24 | import org.springframework.util.StringUtils; | 
| 27 | -import org.springframework.web.client.RestTemplate; | ||
| 28 | 25 | ||
| 29 | -import java.io.*; | 26 | +import java.io.File; | 
| 30 | import java.text.SimpleDateFormat; | 27 | import java.text.SimpleDateFormat; | 
| 31 | -import java.util.*; | 28 | +import java.util.Calendar; | 
| 29 | +import java.util.Date; | ||
| 30 | +import java.util.List; | ||
| 32 | 31 | ||
| 33 | /** | 32 | /** | 
| 34 | * 下发卡号的异步操作 | 33 | * 下发卡号的异步操作 | 
| @@ -46,6 +45,8 @@ public class SendUserInfoTask2 { | @@ -46,6 +45,8 @@ public class SendUserInfoTask2 { | ||
| 46 | SendRecordDao sendRecordDao; | 45 | SendRecordDao sendRecordDao; | 
| 47 | @Autowired | 46 | @Autowired | 
| 48 | PermissFaceService permissFaceService; | 47 | PermissFaceService permissFaceService; | 
| 48 | + @Autowired | ||
| 49 | + BaseService baseService; | ||
| 49 | 50 | ||
| 50 | /** | 51 | /** | 
| 51 | * 下发单个用户人脸任务 | 52 | * 下发单个用户人脸任务 | 
| @@ -129,7 +130,7 @@ public class SendUserInfoTask2 { | @@ -129,7 +130,7 @@ public class SendUserInfoTask2 { | ||
| 129 | */ | 130 | */ | 
| 130 | pushCardAndFace(file, userInfoBean, attendanceBeans, sendRecordBean.getUserType()+"",sendRecordBean.getFailType()); | 131 | pushCardAndFace(file, userInfoBean, attendanceBeans, sendRecordBean.getUserType()+"",sendRecordBean.getFailType()); | 
| 131 | } catch (Exception e) { | 132 | } catch (Exception e) { | 
| 132 | - e.printStackTrace(); | 133 | + log.error("下发失败"); | 
| 133 | return false; | 134 | return false; | 
| 134 | } | 135 | } | 
| 135 | return false; | 136 | return false; | 
| @@ -192,6 +193,7 @@ public class SendUserInfoTask2 { | @@ -192,6 +193,7 @@ public class SendUserInfoTask2 { | ||
| 192 | SendRecordBean sendRecordBean = new SendRecordBean(); | 193 | SendRecordBean sendRecordBean = new SendRecordBean(); | 
| 193 | sendRecordBean.setImgPath(picSrc); | 194 | sendRecordBean.setImgPath(picSrc); | 
| 194 | sendRecordBean.setCustomerid(studentId); | 195 | sendRecordBean.setCustomerid(studentId); | 
| 196 | + sendRecordBean.setUserId(userId); | ||
| 195 | sendRecordBean.setName(userName); | 197 | sendRecordBean.setName(userName); | 
| 196 | sendRecordBean.setUserType(Integer.parseInt(userType)); | 198 | sendRecordBean.setUserType(Integer.parseInt(userType)); | 
| 197 | sendRecordBean.setNum(studentNum); | 199 | sendRecordBean.setNum(studentNum); | 
| @@ -205,12 +207,14 @@ public class SendUserInfoTask2 { | @@ -205,12 +207,14 @@ public class SendUserInfoTask2 { | ||
| 205 | Calendar calendar = Calendar.getInstance(); | 207 | Calendar calendar = Calendar.getInstance(); | 
| 206 | calendar.add(Calendar.YEAR, 4); | 208 | calendar.add(Calendar.YEAR, 4); | 
| 207 | String endTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(calendar.getTime()); | 209 | String endTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(calendar.getTime()); | 
| 208 | - //根据学生ID\学校ID获取学生类型 | ||
| 209 | - String studentType = userDao.getStudentType(schoolId,studentId); | ||
| 210 | - //通道号 | ||
| 211 | - String channel = analysisPermission(Integer.parseInt(schoolId),studentType); | ||
| 212 | - log.info("通道号: "+channel); | ||
| 213 | - | 210 | + String channel=""; | 
| 211 | + if(userType2 ==2){ | ||
| 212 | + //根据学生ID\学校ID获取学生类型 | ||
| 213 | + String studentType = userDao.getStudentType(schoolId,studentId); | ||
| 214 | + //通道号 | ||
| 215 | +// String channel = analysisPermission(Integer.parseInt(schoolId),studentType); | ||
| 216 | + channel = analysisAuthChannel(Integer.parseInt(schoolId),Integer.parseInt(studentType),deviceId); | ||
| 217 | + } | ||
| 214 | /** | 218 | /** | 
| 215 | * 下发升级二代接口,动态库libs下win64,更新为官方最新版sdk add by xuquan 2020-11-23 | 219 | * 下发升级二代接口,动态库libs下win64,更新为官方最新版sdk add by xuquan 2020-11-23 | 
| 216 | * 注:用户下发逻辑: | 220 | * 注:用户下发逻辑: | 
| @@ -241,10 +245,9 @@ public class SendUserInfoTask2 { | @@ -241,10 +245,9 @@ public class SendUserInfoTask2 { | ||
| 241 | //判断该学校设备ID对应失败记录是否存在:Face_SendFail | 245 | //判断该学校设备ID对应失败记录是否存在:Face_SendFail | 
| 242 | deviceId = sendRecordDao.getFailIsExit(deviceId, attendanceBean.getSchool_id()); | 246 | deviceId = sendRecordDao.getFailIsExit(deviceId, attendanceBean.getSchool_id()); | 
| 243 | if (!StringUtils.isEmpty(deviceId)) { | 247 | if (!StringUtils.isEmpty(deviceId)) { | 
| 244 | - //更新下发失败状态 | ||
| 245 | - sendRecordDao.updateFace(sendRecordBean.getNum(), sendRecordBean.getDeviceID(), sendRecordBean.getFailType(), EnumSendFaceType.NOT_ONLINE_DEVICE.code); | ||
| 246 | - //添加下发失败记录 | ||
| 247 | - addFailDace(sendRecordBean); | 248 | + sendRecordBean.setFailType(EnumSendFaceType.FACE_AND_CARD_FAIL.code); | 
| 249 | + sendRecordBean.setFailContent(EnumSendFaceType.NOT_ONLINE_DEVICE.message); | ||
| 250 | + baseService.sendFailRecord(sendRecordBean); | ||
| 248 | } | 251 | } | 
| 249 | } else { | 252 | } else { | 
| 250 | log.info("=================开始执行下发人脸及卡号任务================="); | 253 | log.info("=================开始执行下发人脸及卡号任务================="); | 
| @@ -253,10 +256,13 @@ public class SendUserInfoTask2 { | @@ -253,10 +256,13 @@ public class SendUserInfoTask2 { | ||
| 253 | if(attendanceBean.getClint_id().startsWith("ytj")&&Integer.parseInt(attendanceBean.getSchool_id())!=126 | 256 | if(attendanceBean.getClint_id().startsWith("ytj")&&Integer.parseInt(attendanceBean.getSchool_id())!=126 | 
| 254 | &&Integer.parseInt(attendanceBean.getSchool_id())!=393) { | 257 | &&Integer.parseInt(attendanceBean.getSchool_id())!=393) { | 
| 255 | cardNum = studentNum; | 258 | cardNum = studentNum; | 
| 256 | - deviceType= EnumDeviceType.DH_FACE_YTJ.deviceType; | ||
| 257 | } else { | 259 | } else { | 
| 258 | cardNum = cardNo(studentNum); | 260 | cardNum = cardNo(studentNum); | 
| 259 | } | 261 | } | 
| 262 | + if(attendanceBean.getClint_id().startsWith("ytj")){ | ||
| 263 | + deviceType= EnumDeviceType.DH_FACE_YTJ.deviceType; | ||
| 264 | + sendRecordBean.setDeviceType(deviceType); | ||
| 265 | + } | ||
| 260 | try{ | 266 | try{ | 
| 261 | /** | 267 | /** | 
| 262 | * recordNo 不为空存在下发记录集编号,直接修改执行人脸信息(二代升级接口,此处不需要修改用户信息) | 268 | * recordNo 不为空存在下发记录集编号,直接修改执行人脸信息(二代升级接口,此处不需要修改用户信息) | 
| @@ -294,9 +300,9 @@ public class SendUserInfoTask2 { | @@ -294,9 +300,9 @@ public class SendUserInfoTask2 { | ||
| 294 | userDao.saveRecordNo(userId,1, userName, attendanceBean.getClint_id()); | 300 | userDao.saveRecordNo(userId,1, userName, attendanceBean.getClint_id()); | 
| 295 | } | 301 | } | 
| 296 | } | 302 | } | 
| 297 | - } catch (Exception e) { | ||
| 298 | - log.error("下发异常:异常错误信息msg: {}",e.getMessage()); | ||
| 299 | - return; | 303 | + } catch (RuntimeException e) { | 
| 304 | + log.error("下发异常:异常错误信息msg: {}",e); | ||
| 305 | + continue; | ||
| 300 | } | 306 | } | 
| 301 | /** | 307 | /** | 
| 302 | * 人脸和卡都下发成功 | 308 | * 人脸和卡都下发成功 | 
| @@ -304,21 +310,8 @@ public class SendUserInfoTask2 { | @@ -304,21 +310,8 @@ public class SendUserInfoTask2 { | ||
| 304 | if (bUserFlags ==0 && bCardFlags ==0 && bFaceFalgs==0) { | 310 | if (bUserFlags ==0 && bCardFlags ==0 && bFaceFalgs==0) { | 
| 305 | FileUtils.getInstance().writeLogs("下发人脸和卡号成功:" + cardNum + " " + attendanceBean.getClint_id(), FileUtils.sendUserSucTxt); | 311 | FileUtils.getInstance().writeLogs("下发人脸和卡号成功:" + cardNum + " " + attendanceBean.getClint_id(), FileUtils.sendUserSucTxt); | 
| 306 | log.info("下发人脸和卡号成功, sendRecordBean: "+ JSON.toJSONString(sendRecordBean)); | 312 | log.info("下发人脸和卡号成功, sendRecordBean: "+ JSON.toJSONString(sendRecordBean)); | 
| 307 | - | ||
| 308 | - //人脸下发成功记录, 先判断是否已经存在了 | ||
| 309 | - List<SendRecordBean> sendRecordBeanList = sendRecordDao.getFaceSucceIsexit(sendRecordBean.getDeviceID(), String.valueOf(sendRecordBean.getSchoolId()), sendRecordBean.getNum()); | ||
| 310 | - if (sendRecordBeanList.size() > 0) { | ||
| 311 | - //删除重复数据 | ||
| 312 | - for (int i = 0; i < sendRecordBeanList.size(); i++) { | ||
| 313 | - sendRecordDao.deleteFaceSuccess(sendRecordBeanList.get(i).getDeviceID(), sendRecordBeanList.get(i).getNum()); | ||
| 314 | - } | ||
| 315 | - } | ||
| 316 | - //重新添加人脸下发记录 | ||
| 317 | - sendRecordDao.addFaceSuccess(sendRecordBean.getCustomerid(), sendRecordBean.getDeviceID(), sendRecordBean.getNum(), sendRecordBean.getName(), sendRecordBean.getTime(), | ||
| 318 | - sendRecordBean.getSchoolName(), sendRecordBean.getImgPath(), sendRecordBean.getSchoolId(), sendRecordBean.getUserType(), deviceType); | ||
| 319 | - | ||
| 320 | - //删除之前失败记录 | ||
| 321 | - sendRecordDao.deleteFaceFail(sendRecordBean.getNum(), sendRecordBean.getDeviceID()); | 313 | + //保存成功记录 | 
| 314 | + baseService.sendSuccessRecord(sendRecordBean); | ||
| 322 | } | 315 | } | 
| 323 | /** | 316 | /** | 
| 324 | * 人脸和卡都下发失败 | 317 | * 人脸和卡都下发失败 | 
| @@ -330,8 +323,7 @@ public class SendUserInfoTask2 { | @@ -330,8 +323,7 @@ public class SendUserInfoTask2 { | ||
| 330 | String failContent = analysisErrorMsg(bUserFlags,bFaceFalgs,bCardFlags); | 323 | String failContent = analysisErrorMsg(bUserFlags,bFaceFalgs,bCardFlags); | 
| 331 | sendRecordBean.setFailType(EnumSendFaceType.FACE_AND_CARD_FAIL.code); | 324 | sendRecordBean.setFailType(EnumSendFaceType.FACE_AND_CARD_FAIL.code); | 
| 332 | sendRecordBean.setFailContent(failContent); | 325 | sendRecordBean.setFailContent(failContent); | 
| 333 | - sendRecordDao.updateFace(sendRecordBean.getNum(), sendRecordBean.getDeviceID(), sendRecordBean.getFailType(), EnumSendFaceType.FACE_AND_CARD_FAIL.code); | ||
| 334 | - addFailDace(sendRecordBean); | 326 | + baseService.sendFailRecord(sendRecordBean); | 
| 335 | } | 327 | } | 
| 336 | /** | 328 | /** | 
| 337 | * 下发卡号成功,下发人脸失败, | 329 | * 下发卡号成功,下发人脸失败, | 
| @@ -343,8 +335,7 @@ public class SendUserInfoTask2 { | @@ -343,8 +335,7 @@ public class SendUserInfoTask2 { | ||
| 343 | String failContent = analysisErrorMsg(bUserFlags,bFaceFalgs,bCardFlags); | 335 | String failContent = analysisErrorMsg(bUserFlags,bFaceFalgs,bCardFlags); | 
| 344 | sendRecordBean.setFailType(EnumSendFaceType.FACE_FAIL_CARD_SUCCESS.code); | 336 | sendRecordBean.setFailType(EnumSendFaceType.FACE_FAIL_CARD_SUCCESS.code); | 
| 345 | sendRecordBean.setFailContent(failContent); | 337 | sendRecordBean.setFailContent(failContent); | 
| 346 | - sendRecordDao.updateFace(sendRecordBean.getNum(), sendRecordBean.getDeviceID(), sendRecordBean.getFailType(), EnumSendFaceType.FACE_FAIL_CARD_SUCCESS.code); | ||
| 347 | - addFailDace(sendRecordBean); | 338 | + baseService.sendFailRecord(sendRecordBean); | 
| 348 | } | 339 | } | 
| 349 | /** | 340 | /** | 
| 350 | * 下发卡号失败,下发人脸成功, | 341 | * 下发卡号失败,下发人脸成功, | 
| @@ -355,8 +346,7 @@ public class SendUserInfoTask2 { | @@ -355,8 +346,7 @@ public class SendUserInfoTask2 { | ||
| 355 | String failContent = analysisErrorMsg(bUserFlags,bFaceFalgs,bCardFlags); | 346 | String failContent = analysisErrorMsg(bUserFlags,bFaceFalgs,bCardFlags); | 
| 356 | sendRecordBean.setFailType(EnumSendFaceType.FACE_SUCCESS_CARD_FAIl.code); | 347 | sendRecordBean.setFailType(EnumSendFaceType.FACE_SUCCESS_CARD_FAIl.code); | 
| 357 | sendRecordBean.setFailContent(failContent); | 348 | sendRecordBean.setFailContent(failContent); | 
| 358 | - sendRecordDao.updateFace(sendRecordBean.getNum(), sendRecordBean.getDeviceID(), sendRecordBean.getFailType(), EnumSendFaceType.FACE_SUCCESS_CARD_FAIl.code); | ||
| 359 | - addFailDace(sendRecordBean); | 349 | + baseService.sendFailRecord(sendRecordBean); | 
| 360 | } | 350 | } | 
| 361 | } | 351 | } | 
| 362 | } | 352 | } | 
| @@ -398,6 +388,40 @@ public class SendUserInfoTask2 { | @@ -398,6 +388,40 @@ public class SendUserInfoTask2 { | ||
| 398 | } | 388 | } | 
| 399 | 389 | ||
| 400 | /** | 390 | /** | 
| 391 | + * 获取学生时段类型2.0 | ||
| 392 | + * @param schoolId | ||
| 393 | + * @param studentType | ||
| 394 | + * @param deviceId | ||
| 395 | + * @return | ||
| 396 | + */ | ||
| 397 | + private String analysisAuthChannel(Integer schoolId,Integer studentType,String deviceId){ | ||
| 398 | + if(StringUtils.isEmpty(studentType) || StringUtils.isEmpty(schoolId)){ | ||
| 399 | + return ""; | ||
| 400 | + } | ||
| 401 | + List<DeviceAuthRecord> authRecords = userDao.getAuthRecord(schoolId,studentType); | ||
| 402 | + log.info("权限信息:"+ JsonUtils.nonDefaultMapper().toJson(authRecords)); | ||
| 403 | + String channel =""; | ||
| 404 | + if(authRecords.size()>0){ | ||
| 405 | + for(DeviceAuthRecord authRecord : authRecords){ | ||
| 406 | + String deviceIds = authRecord.getSno(); | ||
| 407 | + //学生考勤类型 1:通校生,2:住校生,3:全部 | ||
| 408 | + Integer sType = authRecord.getStudentType(); | ||
| 409 | + log.info("学生类型:{},设备ID:{}",sType,deviceId); | ||
| 410 | + if(deviceIds.indexOf(deviceId)!=-1 && (studentType.intValue() == sType.intValue() || sType.intValue() == 3)){ | ||
| 411 | + channel= authRecord.getShiduan(); | ||
| 412 | + log.info("通道号:"+channel); | ||
| 413 | + } | ||
| 414 | + } | ||
| 415 | + if(StringUtils.isEmpty(channel)){ | ||
| 416 | + log.warn("未获取到学校权限通道号!"); | ||
| 417 | + return ""; | ||
| 418 | + } | ||
| 419 | + return channel; | ||
| 420 | + } | ||
| 421 | + return channel; | ||
| 422 | + } | ||
| 423 | + | ||
| 424 | + /** | ||
| 401 | * 解析下发异常信息 | 425 | * 解析下发异常信息 | 
| 402 | * @param userErrNum | 426 | * @param userErrNum | 
| 403 | * @param faceErrNum | 427 | * @param faceErrNum | 
| @@ -479,9 +503,157 @@ public class SendUserInfoTask2 { | @@ -479,9 +503,157 @@ public class SendUserInfoTask2 { | ||
| 479 | length -= 2; | 503 | length -= 2; | 
| 480 | cardR += cardDex.substring(length, length + 2); | 504 | cardR += cardDex.substring(length, length + 2); | 
| 481 | } | 505 | } | 
| 482 | - | ||
| 483 | return cardR; | 506 | return cardR; | 
| 507 | + } | ||
| 508 | + | ||
| 484 | 509 | ||
| 510 | + /** | ||
| 511 | + * 清空人脸 | ||
| 512 | + * @param deviceId | ||
| 513 | + */ | ||
| 514 | + public boolean clearAllFace(Integer schoolId, String deviceId) { | ||
| 515 | + if(StringUtils.isEmpty(schoolId)){ | ||
| 516 | + log.error("清空人脸时,学校ID不能为空"); | ||
| 517 | + return false; | ||
| 518 | + } | ||
| 519 | + List<AttendanceBean> attendanceBeanList = userDao.queryClintList(schoolId,deviceId); | ||
| 520 | + if(attendanceBeanList.size()>0){ | ||
| 521 | + for(AttendanceBean bean : attendanceBeanList){ | ||
| 522 | + deviceId = bean.getClint_id(); | ||
| 523 | + GateModule2.clearUser(MyTask.lLongSendMap.get(deviceId)); | ||
| 524 | + } | ||
| 525 | + return true; | ||
| 526 | + } | ||
| 527 | + return false; | ||
| 485 | } | 528 | } | 
| 486 | 529 | ||
| 530 | + /** | ||
| 531 | + * 删除失败人脸 | ||
| 532 | + * @param schoolId | ||
| 533 | + * @return | ||
| 534 | + */ | ||
| 535 | + public boolean deleteFailFace(Integer schoolId) { | ||
| 536 | + if(StringUtils.isEmpty(schoolId)){ | ||
| 537 | + log.error("删除人脸时,学校ID不能为空"); | ||
| 538 | + return false; | ||
| 539 | + } | ||
| 540 | + List<SendRecordBean> recordBeanList = sendRecordDao.getFailRecord(schoolId); | ||
| 541 | + if(recordBeanList.size()>0){ | ||
| 542 | + for(SendRecordBean recordBean : recordBeanList){ | ||
| 543 | + String deviceId = recordBean.getDeviceID(); | ||
| 544 | + //下操作记录集 | ||
| 545 | + String recordNo = userDao.getRecordNo(recordBean.getUserId(), deviceId); | ||
| 546 | + if(StringUtils.isEmpty(recordNo)){ | ||
| 547 | + log.info("删除人脸时,该用户卡号未添加过人脸"); | ||
| 548 | + } | ||
| 549 | + if(GateModule2.deleteUser(recordBean.getUserId(),MyTask.lLongSendMap.get(deviceId)) ==0){ | ||
| 550 | + userDao.deleteRecordNoTest(recordBean.getUserId(),deviceId); | ||
| 551 | + } | ||
| 552 | + } | ||
| 553 | + return true; | ||
| 554 | + } | ||
| 555 | + return false; | ||
| 556 | + } | ||
| 557 | + | ||
| 558 | + /** | ||
| 559 | + * 下发失败人脸 | ||
| 560 | + * @param schoolId | ||
| 561 | + * @return | ||
| 562 | + */ | ||
| 563 | + public boolean sendFailFace(Integer schoolId) { | ||
| 564 | + if(StringUtils.isEmpty(schoolId)){ | ||
| 565 | + log.error("下发人脸时,学校ID不能为空"); | ||
| 566 | + return false; | ||
| 567 | + } | ||
| 568 | + List<SendRecordBean> recordBeanList = sendRecordDao.getFailRecord(schoolId); | ||
| 569 | + if(recordBeanList.size()>0){ | ||
| 570 | + for(SendRecordBean recordBean : recordBeanList){ | ||
| 571 | + int userType = recordBean.getUserType(); | ||
| 572 | + String deviceId = recordBean.getDeviceID(); | ||
| 573 | + String clintType = userDao.getClintType(deviceId); | ||
| 574 | + StudentBean studentBean= null; | ||
| 575 | + String typeName =""; | ||
| 576 | + if(userType ==1){ | ||
| 577 | + typeName= "Teacher"; | ||
| 578 | + studentBean = userDao.getTeacherWithCard(recordBean.getNum()); | ||
| 579 | + }else{ | ||
| 580 | + typeName= "Student"; | ||
| 581 | + studentBean= userDao.getStudentWithCard(recordBean.getNum()); | ||
| 582 | + } | ||
| 583 | + if(studentBean==null){ | ||
| 584 | + continue; | ||
| 585 | + } | ||
| 586 | + //100服务器文件目录绝对路径 | ||
| 587 | + String path = "E:\\wwwhtdocs\\SmartCampus\\face17e50\\School" + schoolId + "\\" + typeName; | ||
| 588 | + String photo= userType==1?studentBean.getFace():studentBean.getPhoto(); | ||
| 589 | + //学籍号 | ||
| 590 | + String studentCode=userType==1?studentBean.getNum():studentBean.getStudentcode(); | ||
| 591 | + if (StringUtils.isEmpty(photo) || StringUtils.isEmpty(studentCode)){ | ||
| 592 | + continue; | ||
| 593 | + } | ||
| 594 | + String filePath=""; | ||
| 595 | + if(photo.indexOf("f0i5l7e5")!=-1){ | ||
| 596 | + String afterStr = photo.split("f0i5l7e5/")[1].replace("/","\\"); | ||
| 597 | + filePath="E:\\wwwhtdocs\\SmartCampus\\f0i5l7e5\\" + afterStr; | ||
| 598 | + } else{ | ||
| 599 | + //以学籍号为名的文件名 | ||
| 600 | + String fileName = photo.split(typeName +"/")[1]; | ||
| 601 | + //100服务器上人脸照绝对路径 | ||
| 602 | + filePath = path+ "\\" + fileName; | ||
| 603 | + } | ||
| 604 | + try{ | ||
| 605 | + HttpUtils.uploadImgs(new File(filePath), String.valueOf(schoolId),studentCode, clintType, userType,deviceId); | ||
| 606 | + }catch (Exception e){ | ||
| 607 | + e.printStackTrace(); | ||
| 608 | + continue; | ||
| 609 | + } | ||
| 610 | + } | ||
| 611 | + return true; | ||
| 612 | + } | ||
| 613 | + return false; | ||
| 614 | + } | ||
| 615 | + | ||
| 616 | + /** | ||
| 617 | + * 根据卡号下发失败人脸 | ||
| 618 | + * @param schoolId | ||
| 619 | + * @param cardNum | ||
| 620 | + * @param deviceId | ||
| 621 | + * @return | ||
| 622 | + */ | ||
| 623 | + public boolean deleteFaceByCard(Integer schoolId,String cardNum,String deviceId) { | ||
| 624 | + if(StringUtils.isEmpty(schoolId) && StringUtils.isEmpty(cardNum) && StringUtils.isEmpty(deviceId)){ | ||
| 625 | + log.error("删除人脸时,学校ID、卡号、设备ID不能为空."); | ||
| 626 | + return false; | ||
| 627 | + } | ||
| 628 | + if(MyTask.lLongSendMap.get(deviceId) ==null){ | ||
| 629 | + log.error("设备不在线"); | ||
| 630 | + return false; | ||
| 631 | + } | ||
| 632 | + StudentBean studentBean = userDao.getStudentWithCard(cardNum); | ||
| 633 | + if(studentBean == null){ | ||
| 634 | + log.error("此卡号:{},未查询到相应学生信息。",cardNum); | ||
| 635 | + return false; | ||
| 636 | + } | ||
| 637 | + String userId = userDao.getUerIdWithNumTest(cardNum,schoolId); | ||
| 638 | + if(StringUtils.isEmpty(userId)){ | ||
| 639 | + log.error("删除人脸时,用户卡号不存在。"); | ||
| 640 | + return false; | ||
| 641 | + } | ||
| 642 | + List<AttendanceBean> attendanceBeanList = userDao.queryClintList(schoolId,deviceId); | ||
| 643 | + if(attendanceBeanList.size()>0){ | ||
| 644 | + for(AttendanceBean bean : attendanceBeanList){ | ||
| 645 | + deviceId = bean.getClint_id(); | ||
| 646 | + //下操作记录集 | ||
| 647 | + String recordNo = userDao.getRecordNo(userId, deviceId); | ||
| 648 | + if(StringUtils.isEmpty(recordNo)){ | ||
| 649 | + log.info("删除人脸时,该用户卡号未添加过人脸"); | ||
| 650 | + } | ||
| 651 | + if(GateModule2.deleteUser(userId,MyTask.lLongSendMap.get(deviceId)) ==0){ | ||
| 652 | + userDao.deleteRecordNoTest(userId,deviceId); | ||
| 653 | + } | ||
| 654 | + } | ||
| 655 | + return true; | ||
| 656 | + } | ||
| 657 | + return false; | ||
| 658 | + } | ||
| 487 | } | 659 | } | 
cloud/dahua/src/main/java/com/example/dahua/bean/DeviceAuthRecord.java
0 → 100644
| @@ -0,0 +1,140 @@ | @@ -0,0 +1,140 @@ | ||
| 1 | +package com.example.dahua.bean; | ||
| 2 | + | ||
| 3 | +import java.util.Date; | ||
| 4 | + | ||
| 5 | +/** | ||
| 6 | + * 下发权限时段实体类 | ||
| 7 | + * @author xuquan | ||
| 8 | + * @date 2020/12/17 12:40 | ||
| 9 | + */ | ||
| 10 | +public class DeviceAuthRecord { | ||
| 11 | + | ||
| 12 | + private int id; | ||
| 13 | + //时段 | ||
| 14 | + private String shiduan ; | ||
| 15 | + //学生组 就是powerGroupId 学生类型就是 studentType | ||
| 16 | + private int studentType ; | ||
| 17 | + //性别 | ||
| 18 | + private String sex ; | ||
| 19 | + //学校ID | ||
| 20 | + private int schoolId ; | ||
| 21 | + //开始时间 | ||
| 22 | + private Date startTime ; | ||
| 23 | + //结束时间 | ||
| 24 | + private Date endTime ; | ||
| 25 | + //设备ID | ||
| 26 | + private String sno ; | ||
| 27 | + //周计划json | ||
| 28 | + private String weekDays; | ||
| 29 | + //状态 | ||
| 30 | + private int state; | ||
| 31 | + //下发状态 | ||
| 32 | + private int grantState; | ||
| 33 | + //权限类型 | ||
| 34 | + private int authType; | ||
| 35 | + //计划类型 | ||
| 36 | + private int aType; | ||
| 37 | + | ||
| 38 | + public int getId() { | ||
| 39 | + return id; | ||
| 40 | + } | ||
| 41 | + public void setId(int 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 int getAuthType() { | ||
| 54 | + return authType; | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + public void setAuthType(int authType) { | ||
| 58 | + this.authType = authType; | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + public String getSno() { | ||
| 62 | + return sno; | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + public void setSno(String sno) { | ||
| 66 | + this.sno = sno; | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + public int getStudentType() { | ||
| 70 | + return studentType; | ||
| 71 | + } | ||
| 72 | + | ||
| 73 | + public void setStudentType(int studentType) { | ||
| 74 | + this.studentType = studentType; | ||
| 75 | + } | ||
| 76 | + | ||
| 77 | + public String getSex() { | ||
| 78 | + return sex; | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + public void setSex(String sex) { | ||
| 82 | + this.sex = sex; | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + public int getSchoolId() { | ||
| 86 | + return schoolId; | ||
| 87 | + } | ||
| 88 | + | ||
| 89 | + public void setSchoolId(int schoolId) { | ||
| 90 | + this.schoolId = schoolId; | ||
| 91 | + } | ||
| 92 | + | ||
| 93 | + public Date getStartTime() { | ||
| 94 | + return startTime; | ||
| 95 | + } | ||
| 96 | + | ||
| 97 | + public void setStartTime(Date startTime) { | ||
| 98 | + this.startTime = startTime; | ||
| 99 | + } | ||
| 100 | + | ||
| 101 | + public Date getEndTime() { | ||
| 102 | + return endTime; | ||
| 103 | + } | ||
| 104 | + | ||
| 105 | + public void setEndTime(Date endTime) { | ||
| 106 | + this.endTime = endTime; | ||
| 107 | + } | ||
| 108 | + | ||
| 109 | + public String getWeekDays() { | ||
| 110 | + return weekDays; | ||
| 111 | + } | ||
| 112 | + | ||
| 113 | + public void setWeekDays(String weekDays) { | ||
| 114 | + this.weekDays = weekDays; | ||
| 115 | + } | ||
| 116 | + | ||
| 117 | + public int getState() { | ||
| 118 | + return state; | ||
| 119 | + } | ||
| 120 | + | ||
| 121 | + public void setState(int state) { | ||
| 122 | + this.state = state; | ||
| 123 | + } | ||
| 124 | + | ||
| 125 | + public int getGrantState() { | ||
| 126 | + return grantState; | ||
| 127 | + } | ||
| 128 | + | ||
| 129 | + public void setGrantState(int grantState) { | ||
| 130 | + this.grantState = grantState; | ||
| 131 | + } | ||
| 132 | + | ||
| 133 | + public int getaType() { | ||
| 134 | + return aType; | ||
| 135 | + } | ||
| 136 | + | ||
| 137 | + public void setaType(int aType) { | ||
| 138 | + this.aType = aType; | ||
| 139 | + } | ||
| 140 | +} | 
cloud/dahua/src/main/java/com/example/dahua/bean/SendFaceDto.java
0 → 100644
| @@ -0,0 +1,64 @@ | @@ -0,0 +1,64 @@ | ||
| 1 | +package com.example.dahua.bean; | ||
| 2 | + | ||
| 3 | +import io.swagger.annotations.ApiModel; | ||
| 4 | +import io.swagger.annotations.ApiModelProperty; | ||
| 5 | + | ||
| 6 | +/** | ||
| 7 | + * 照片下发人脸实体类 | ||
| 8 | + * @author xuquan | ||
| 9 | + * @date 2020/12/16 09:10 | ||
| 10 | + */ | ||
| 11 | +@ApiModel | ||
| 12 | +public class SendFaceDto { | ||
| 13 | + | ||
| 14 | + @ApiModelProperty("0主卡1教师卡2副卡") | ||
| 15 | + private Integer type ; | ||
| 16 | + @ApiModelProperty("学校ID") | ||
| 17 | + private Integer schoolId ; | ||
| 18 | + @ApiModelProperty("设备号,逗号隔开") | ||
| 19 | + private String sNos; | ||
| 20 | + @ApiModelProperty("学生类型,1通校2住校;群组时,为群组号") | ||
| 21 | + private Integer studentType; | ||
| 22 | + @ApiModelProperty("性别:1男2女,多个逗号隔开") | ||
| 23 | + private String sex; | ||
| 24 | + | ||
| 25 | + public Integer getType() { | ||
| 26 | + return type; | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + public void setType(Integer type) { | ||
| 30 | + this.type = type; | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + public Integer getSchoolId() { | ||
| 34 | + return schoolId; | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + public void setSchoolId(Integer schoolId) { | ||
| 38 | + this.schoolId = schoolId; | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + public String getsNos() { | ||
| 42 | + return sNos; | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + public void setsNos(String sNos) { | ||
| 46 | + this.sNos = sNos; | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + public Integer getStudentType() { | ||
| 50 | + return studentType; | ||
| 51 | + } | ||
| 52 | + | ||
| 53 | + public void setStudentType(Integer studentType) { | ||
| 54 | + this.studentType = studentType; | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + public String getSex() { | ||
| 58 | + return sex; | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + public void setSex(String sex) { | ||
| 62 | + this.sex = sex; | ||
| 63 | + } | ||
| 64 | +} | 
cloud/dahua/src/main/java/com/example/dahua/bean/SendRecordBean.java
| @@ -7,6 +7,7 @@ import java.io.Serializable; | @@ -7,6 +7,7 @@ import java.io.Serializable; | ||
| 7 | */ | 7 | */ | 
| 8 | public class SendRecordBean implements Serializable { | 8 | public class SendRecordBean implements Serializable { | 
| 9 | 9 | ||
| 10 | + private Integer id; | ||
| 10 | //用户编号:学生student_id;老师teacher_id | 11 | //用户编号:学生student_id;老师teacher_id | 
| 11 | private String customerid; | 12 | private String customerid; | 
| 12 | //卡号 | 13 | //卡号 | 
| @@ -29,7 +30,26 @@ public class SendRecordBean implements Serializable { | @@ -29,7 +30,26 @@ public class SendRecordBean implements Serializable { | ||
| 29 | private String failContent; | 30 | private String failContent; | 
| 30 | //下发失败类型:详情见枚举:EnumSendFaceType | 31 | //下发失败类型:详情见枚举:EnumSendFaceType | 
| 31 | private int failType; | 32 | private int failType; | 
| 33 | + //设备类型 | ||
| 34 | + private int deviceType; | ||
| 32 | 35 | ||
| 36 | + private String userId; | ||
| 37 | + | ||
| 38 | + public String getUserId() { | ||
| 39 | + return userId; | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | + public void setUserId(String userId) { | ||
| 43 | + this.userId = userId; | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + public Integer getId() { | ||
| 47 | + return id; | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + public void setId(Integer id) { | ||
| 51 | + this.id = id; | ||
| 52 | + } | ||
| 33 | 53 | ||
| 34 | public String getCustomerid() { | 54 | public String getCustomerid() { | 
| 35 | return customerid; | 55 | return customerid; | 
| @@ -119,6 +139,14 @@ public class SendRecordBean implements Serializable { | @@ -119,6 +139,14 @@ public class SendRecordBean implements Serializable { | ||
| 119 | this.failType = failType; | 139 | this.failType = failType; | 
| 120 | } | 140 | } | 
| 121 | 141 | ||
| 142 | + public int getDeviceType() { | ||
| 143 | + return deviceType; | ||
| 144 | + } | ||
| 145 | + | ||
| 146 | + public void setDeviceType(int deviceType) { | ||
| 147 | + this.deviceType = deviceType; | ||
| 148 | + } | ||
| 149 | + | ||
| 122 | @Override | 150 | @Override | 
| 123 | public String toString() { | 151 | public String toString() { | 
| 124 | return "SendRecordBean{" + | 152 | return "SendRecordBean{" + | 
cloud/dahua/src/main/java/com/example/dahua/bean/StudentBean.java
| @@ -47,6 +47,8 @@ public class StudentBean implements Serializable { | @@ -47,6 +47,8 @@ public class StudentBean implements Serializable { | ||
| 47 | 47 | ||
| 48 | private String Face; | 48 | private String Face; | 
| 49 | 49 | ||
| 50 | + private String photo; | ||
| 51 | + | ||
| 50 | // private String StudentCode; | 52 | // private String StudentCode; | 
| 51 | 53 | ||
| 52 | private String student_num; | 54 | private String student_num; | 
| @@ -227,7 +229,14 @@ public class StudentBean implements Serializable { | @@ -227,7 +229,14 @@ public class StudentBean implements Serializable { | ||
| 227 | Face = face; | 229 | Face = face; | 
| 228 | } | 230 | } | 
| 229 | 231 | ||
| 230 | -// public String getStudentCode() { | 232 | + public String getPhoto() { | 
| 233 | + return photo; | ||
| 234 | + } | ||
| 235 | + | ||
| 236 | + public void setPhoto(String photo) { | ||
| 237 | + this.photo = photo; | ||
| 238 | + } | ||
| 239 | + // public String getStudentCode() { | ||
| 231 | // return StudentCode; | 240 | // return StudentCode; | 
| 232 | // } | 241 | // } | 
| 233 | // | 242 | // | 
cloud/dahua/src/main/java/com/example/dahua/control/UserOperateController.java
| 1 | -//package com.example.dahua.control; | ||
| 2 | -// | ||
| 3 | -//import com.example.dahua.MyTask; | ||
| 4 | -//import com.example.dahua.async.SendUserInfoTask; | ||
| 5 | -//import com.example.dahua.bean.PermissionBean; | ||
| 6 | -//import com.example.dahua.bean.SendRecordBean; | ||
| 7 | -//import com.example.dahua.bean.StudentBean; | ||
| 8 | -//import com.example.dahua.dao.UserDao; | ||
| 9 | -//import com.example.dahua.enums.EnumSzBusinessType; | ||
| 10 | -//import com.example.dahua.lib.CompressPic; | ||
| 11 | -//import com.example.dahua.service.UserOperateService; | ||
| 12 | -//import com.example.dahua.service.UserService; | ||
| 13 | -//import com.example.dahua.utils.BaiduUtils; | ||
| 14 | -//import com.example.dahua.utils.FileUtils; | ||
| 15 | -//import com.example.dahua.utils.HttpUtils; | ||
| 16 | -//import com.example.dahua.xiananDao.SendRecordDao; | ||
| 17 | -//import io.swagger.annotations.Api; | ||
| 18 | -//import io.swagger.annotations.ApiImplicitParam; | ||
| 19 | -//import io.swagger.annotations.ApiImplicitParams; | ||
| 20 | -//import io.swagger.annotations.ApiOperation; | ||
| 21 | -//import lombok.extern.slf4j.Slf4j; | ||
| 22 | -//import org.json.JSONException; | ||
| 23 | -//import org.json.JSONObject; | ||
| 24 | -//import org.springframework.beans.factory.annotation.Autowired; | ||
| 25 | -//import org.springframework.http.MediaType; | ||
| 26 | -//import org.springframework.util.StringUtils; | ||
| 27 | -//import org.springframework.web.bind.annotation.*; | ||
| 28 | -//import org.springframework.web.client.RestTemplate; | ||
| 29 | -//import org.springframework.web.multipart.MultipartFile; | ||
| 30 | -// | ||
| 31 | -//import java.io.File; | ||
| 32 | -//import java.io.FileNotFoundException; | ||
| 33 | -//import java.io.FileOutputStream; | ||
| 34 | -//import java.io.IOException; | ||
| 35 | -//import java.util.List; | ||
| 36 | -// | ||
| 37 | -///** | ||
| 38 | -// * 用户信息、人脸、卡信息、权限下发控制类 | ||
| 39 | -// * @author xuquan | ||
| 40 | -// * @date 2020/12/01 15:16 | ||
| 41 | -// */ | ||
| 42 | -//@Slf4j | ||
| 43 | -//@RestController("/operate/") | ||
| 44 | -//@Api(tags = "下发用户信息、人脸、卡、权限信息") | ||
| 45 | -//@RequestMapping(value = "/operate/*", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) | ||
| 46 | -//public class UserOperateController { | ||
| 47 | -// | ||
| 48 | -// @Autowired | ||
| 49 | -// UserOperateService operateService; | ||
| 50 | -// | ||
| 51 | -// @Autowired | ||
| 52 | -// SendUserInfoTask sendUserInfoTask; | ||
| 53 | -// | ||
| 54 | -// | ||
| 55 | -// /** | ||
| 56 | -// * 单个用户下发至设备 | ||
| 57 | -// * @param schoolId | ||
| 58 | -// * @param userId | ||
| 59 | -// * @param clintType | ||
| 60 | -// * @return | ||
| 61 | -// */ | ||
| 62 | -// @RequestMapping(value = "sendUser", method = RequestMethod.GET) | ||
| 63 | -// @ApiOperation(value = "上传用户信息") | ||
| 64 | -// public String sendUser(@RequestParam("file") MultipartFile file, @RequestParam("schoolId") String schoolId, @RequestParam("userId") String userId, | ||
| 65 | -// @RequestParam("clintType") String clintType, @RequestParam("userType") int userType,@RequestParam("flag") int flag, | ||
| 66 | -// @RequestParam(required = false) String deviceId) { | ||
| 67 | -// //文件名 | ||
| 68 | -// String fileName = file.getOriginalFilename(); | ||
| 69 | -// //21服务器临时文件存储路径 | ||
| 70 | -// File outFile = new File("C://imgCom"); | ||
| 71 | -// if (!outFile.exists()) outFile.mkdirs(); | ||
| 72 | -// try { | ||
| 73 | -// File dest = new File(outFile, fileName); | ||
| 74 | -// | ||
| 75 | -// FileOutputStream fileOutputStream = new FileOutputStream(dest); | ||
| 76 | -// fileOutputStream.write(file.getBytes()); | ||
| 77 | -// fileOutputStream.close(); | ||
| 78 | -// String filePath = dest.getAbsolutePath(); | ||
| 79 | -// deviceId = StringUtils.isEmpty(deviceId)?"":deviceId; | ||
| 80 | -// operateService.sendUserInfo(filePath, userType,schoolId,userId,deviceId, clintType,flag); | ||
| 81 | -// return "1"; | ||
| 82 | -// } catch (FileNotFoundException e) { | ||
| 83 | -// e.printStackTrace(); | ||
| 84 | -// } catch (IOException e) { | ||
| 85 | -// e.printStackTrace(); | ||
| 86 | -// } | ||
| 87 | -// return "0"; | ||
| 88 | -// } | ||
| 89 | -// | ||
| 90 | -// | ||
| 91 | -// /** | ||
| 92 | -// * 大华枪机人脸库添加 | ||
| 93 | -// * @param schoolId | ||
| 94 | -// * @param userId | ||
| 95 | -// * @param clintType | ||
| 96 | -// * @return | ||
| 97 | -// */ | ||
| 98 | -// @RequestMapping(value = "addFaceData", method = RequestMethod.GET) | ||
| 99 | -// @ApiOperation(value = "上传用户信息") | ||
| 100 | -// public String sendUser(@RequestParam("file") MultipartFile file, @RequestParam("schoolId") String schoolId, @RequestParam("userId") String userId, | ||
| 101 | -// @RequestParam("clintType") String clintType, @RequestParam("userType") int userType, @RequestParam(required = false) String deviceId) { | ||
| 102 | -// //文件名 | ||
| 103 | -// String fileName = file.getOriginalFilename(); | ||
| 104 | -// //21服务器临时文件存储路径 | ||
| 105 | -// File outFile = new File("C://imgCom"); | ||
| 106 | -// if (!outFile.exists()) outFile.mkdirs(); | ||
| 107 | -// try { | ||
| 108 | -// File dest = new File(outFile, fileName); | ||
| 109 | -// | ||
| 110 | -// FileOutputStream fileOutputStream = new FileOutputStream(dest); | ||
| 111 | -// fileOutputStream.write(file.getBytes()); | ||
| 112 | -// fileOutputStream.close(); | ||
| 113 | -// String filePath = dest.getAbsolutePath(); | ||
| 114 | -// deviceId = StringUtils.isEmpty(deviceId)?"":deviceId; | ||
| 115 | -// operateService.addFaceGroup(filePath, userType,schoolId,userId,deviceId, clintType); | ||
| 116 | -// return "1"; | ||
| 117 | -// } catch (FileNotFoundException e) { | ||
| 118 | -// e.printStackTrace(); | ||
| 119 | -// } catch (IOException e) { | ||
| 120 | -// e.printStackTrace(); | ||
| 121 | -// } | ||
| 122 | -// return "0"; | ||
| 123 | -// } | ||
| 124 | -// | ||
| 125 | -//} | 1 | +package com.example.dahua.control; | 
| 2 | + | ||
| 3 | +import com.example.dahua.async.SendUserInfoTask2; | ||
| 4 | +import com.example.dahua.bean.SendFaceDto; | ||
| 5 | +import com.example.dahua.dao.UserDao; | ||
| 6 | +import com.example.dahua.service.UserOperateService; | ||
| 7 | +import com.example.dahua.utils.HttpUtils; | ||
| 8 | +import io.swagger.annotations.Api; | ||
| 9 | +import io.swagger.annotations.ApiOperation; | ||
| 10 | +import lombok.extern.slf4j.Slf4j; | ||
| 11 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 12 | +import org.springframework.http.MediaType; | ||
| 13 | +import org.springframework.web.bind.annotation.*; | ||
| 14 | + | ||
| 15 | +/** | ||
| 16 | + * 用户信息、人脸、卡信息、权限下发控制类 | ||
| 17 | + * @author xuquan | ||
| 18 | + * @date 2020/12/01 15:16 | ||
| 19 | + */ | ||
| 20 | +@Slf4j | ||
| 21 | +@RestController("/operate/") | ||
| 22 | +@Api(tags = "大华设备操作接口") | ||
| 23 | +@RequestMapping(value = "/operate/*", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) | ||
| 24 | +public class UserOperateController { | ||
| 25 | + | ||
| 26 | + @Autowired | ||
| 27 | + SendUserInfoTask2 sendUserInfoTask; | ||
| 28 | + | ||
| 29 | + @Autowired | ||
| 30 | + UserDao userDao; | ||
| 31 | + | ||
| 32 | + @Autowired | ||
| 33 | + UserOperateService userOperateService; | ||
| 34 | + | ||
| 35 | + @RequestMapping(value = "clearAllFace", method = RequestMethod.POST) | ||
| 36 | + @ApiOperation(value = "21服务器清空指定学校,指定设备下所有人脸2.0") | ||
| 37 | + public boolean clearAllFace(@RequestParam("schoolId") Integer schoolId, @RequestParam("deviceId") String deviceId) { | ||
| 38 | + return sendUserInfoTask.clearAllFace(schoolId,deviceId); | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + @RequestMapping(value = "sendUserFaces", method = RequestMethod.POST) | ||
| 42 | + @ApiOperation(value = "100服务器下发学校下所有人脸给指定设备2.0") | ||
| 43 | + public void sendUserFaces(@RequestBody SendFaceDto sendFaceDto) { | ||
| 44 | + userOperateService.sendUserFaces(sendFaceDto); | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + @RequestMapping(value = "deleteFailFace100", method = RequestMethod.POST) | ||
| 48 | + @ApiOperation(value = "100服务器删除失败人脸2.0") | ||
| 49 | + public boolean deleteFailFace100(@RequestParam("schoolId") Integer schoolId) { | ||
| 50 | + HttpUtils.deleteFace(schoolId); | ||
| 51 | + return true; | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + @RequestMapping(value = "sendFailFace", method = RequestMethod.POST) | ||
| 55 | + @ApiOperation(value = "100服务器下发失败人脸2.0") | ||
| 56 | + public boolean sendFailFace(@RequestParam("schoolId") Integer schoolId) { | ||
| 57 | + return sendUserInfoTask.sendFailFace(schoolId); | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + @RequestMapping(value = "deleteFailFace", method = RequestMethod.GET) | ||
| 61 | + @ApiOperation(value = "21服务器删除失败人脸2.0") | ||
| 62 | + public boolean deleteFailFace(Integer schoolId) { | ||
| 63 | + return sendUserInfoTask.deleteFailFace(schoolId); | ||
| 64 | + } | ||
| 65 | + | ||
| 66 | + @RequestMapping(value = "deleteFaceByCard", method = RequestMethod.GET) | ||
| 67 | + @ApiOperation(value = "21服务器根据卡号删除人脸") | ||
| 68 | + public boolean deleteFaceByCard(Integer schoolId,String cardNum,String deviceId) { | ||
| 69 | + return sendUserInfoTask.deleteFaceByCard(schoolId,cardNum,deviceId); | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | +} | 
cloud/dahua/src/main/java/com/example/dahua/dao/UserDao.java
| @@ -5,6 +5,7 @@ import org.apache.ibatis.annotations.*; | @@ -5,6 +5,7 @@ import org.apache.ibatis.annotations.*; | ||
| 5 | import org.springframework.stereotype.Repository; | 5 | import org.springframework.stereotype.Repository; | 
| 6 | 6 | ||
| 7 | import java.util.List; | 7 | import java.util.List; | 
| 8 | +import java.util.Map; | ||
| 8 | 9 | ||
| 9 | @Repository | 10 | @Repository | 
| 10 | @Mapper | 11 | @Mapper | 
| @@ -240,7 +241,7 @@ public interface UserDao { | @@ -240,7 +241,7 @@ public interface UserDao { | ||
| 240 | List<String> getRecordNoTest(@Param("student_name") String name,@Param("user_id") String user_id,@Param("deviceId") String deviceId); | 241 | List<String> getRecordNoTest(@Param("student_name") String name,@Param("user_id") String user_id,@Param("deviceId") String deviceId); | 
| 241 | 242 | ||
| 242 | @Select("select Top(1) user_id from SZ_V_School_Student where student_num = #{student_num} and school_id = #{school_id}") | 243 | @Select("select Top(1) user_id from SZ_V_School_Student where student_num = #{student_num} and school_id = #{school_id}") | 
| 243 | - String getUerIdWithNumTest(@Param("student_num") String student_num,@Param("school_id") String schoolId); | 244 | + String getUerIdWithNumTest(@Param("student_num") String student_num,@Param("school_id") Integer schoolId); | 
| 244 | 245 | ||
| 245 | @Select("select * from SZ_V_School_Student where school_id = #{school_id}") | 246 | @Select("select * from SZ_V_School_Student where school_id = #{school_id}") | 
| 246 | List<UserInfoBean> getUserIdTest(@Param("school_id") String schoolId); | 247 | List<UserInfoBean> getUserIdTest(@Param("school_id") String schoolId); | 
| @@ -250,4 +251,19 @@ public interface UserDao { | @@ -250,4 +251,19 @@ public interface UserDao { | ||
| 250 | 251 | ||
| 251 | /*************************************** 仅供测试,下发失败使用接口 end ************************************/ | 252 | /*************************************** 仅供测试,下发失败使用接口 end ************************************/ | 
| 252 | 253 | ||
| 254 | + | ||
| 255 | + @Select("select Top(1)* from SZ_V_School_Teacher where teacher_num = #{teacher_num}") | ||
| 256 | + StudentBean getTeacherWithCard(@Param("teacher_num") String teacher_num); | ||
| 257 | + | ||
| 258 | + @Select("select Top(1)* from SZ_V_School_Student where student_num = #{card}") | ||
| 259 | + StudentBean getStudentWithCard(@Param("card") String card); | ||
| 260 | + | ||
| 261 | + List<StudentBean> getStudentList(@Param("schoolId") Integer schoolId,@Param("studentType")Integer studentType,@Param("sex") List<Integer> sex); | ||
| 262 | + | ||
| 263 | + List<StudentBean> getTeacherList(@Param("schoolId") Integer schoolId); | ||
| 264 | + | ||
| 265 | + List<DeviceAuthRecord> getAuthRecord(@Param("schoolId") Integer schoolId,@Param("studentType")Integer studentType); | ||
| 266 | + | ||
| 267 | + List<AttendanceBean> queryClintList(@Param("schoolId") Integer schoolId,@Param("deviceId")String deviceId); | ||
| 268 | + | ||
| 253 | } | 269 | } | 
cloud/dahua/src/main/java/com/example/dahua/filter/AllowOriginFilter.java
| @@ -9,9 +9,6 @@ import java.io.IOException; | @@ -9,9 +9,6 @@ import java.io.IOException; | ||
| 9 | 9 | ||
| 10 | /** | 10 | /** | 
| 11 | * 用于解决跨域问题 | 11 | * 用于解决跨域问题 | 
| 12 | - * @author chen | ||
| 13 | - * @version 1.0 | ||
| 14 | - * @date 2019/10/11 0011 10:17 | ||
| 15 | */ | 12 | */ | 
| 16 | @Component | 13 | @Component | 
| 17 | @WebFilter(urlPatterns = "/*", filterName = "authFilter") | 14 | @WebFilter(urlPatterns = "/*", filterName = "authFilter") | 
cloud/dahua/src/main/java/com/example/dahua/module/GateModule.java
| @@ -409,7 +409,6 @@ public class GateModule { | @@ -409,7 +409,6 @@ public class GateModule { | ||
| 409 | */ | 409 | */ | 
| 410 | public static void setAccessTimeSchedule(LLong lLong, PermissionBean permissionBean) { | 410 | public static void setAccessTimeSchedule(LLong lLong, PermissionBean permissionBean) { | 
| 411 | try { | 411 | try { | 
| 412 | - | ||
| 413 | CFG_ACCESS_TIMESCHEDULE_INFO msg = new CFG_ACCESS_TIMESCHEDULE_INFO(); | 412 | CFG_ACCESS_TIMESCHEDULE_INFO msg = new CFG_ACCESS_TIMESCHEDULE_INFO(); | 
| 414 | String strCmd = NetSDKLib.CFG_CMD_ACCESSTIMESCHEDULE; | 413 | String strCmd = NetSDKLib.CFG_CMD_ACCESSTIMESCHEDULE; | 
| 415 | // 通道号 | 414 | // 通道号 | 
| @@ -450,52 +449,13 @@ public class GateModule { | @@ -450,52 +449,13 @@ public class GateModule { | ||
| 450 | 449 | ||
| 451 | } | 450 | } | 
| 452 | } | 451 | } | 
| 453 | - | ||
| 454 | - | ||
| 455 | - /* for (WeekDay weekDay : | ||
| 456 | - weekDays) { | ||
| 457 | - List<WeekTime> weekTimes = weekDay.getWeekTimes(); | ||
| 458 | - for (int i = 0; i < weekTimes.size(); i++) { | ||
| 459 | - WeekTime weekTime = weekTimes.get(i); | ||
| 460 | - String startTime = weekTime.getStartTime(); | ||
| 461 | - String endTime = weekTime.getEndTime(); | ||
| 462 | - msg.stuTimeWeekDay[weekDay.getWeekDay()].stuTimeSection[i].nBeginHour = Integer.parseInt(startTime.split(":")[0]); | ||
| 463 | - msg.stuTimeWeekDay[weekDay.getWeekDay()].stuTimeSection[i].nBeginMin = Integer.parseInt(startTime.split(":")[1]); | ||
| 464 | - msg.stuTimeWeekDay[weekDay.getWeekDay()].stuTimeSection[i].nBeginSec = 0; | ||
| 465 | - | ||
| 466 | - msg.stuTimeWeekDay[weekDay.getWeekDay()].stuTimeSection[i].nEndHour = Integer.parseInt(endTime.split(":")[0]); | ||
| 467 | - msg.stuTimeWeekDay[weekDay.getWeekDay()].stuTimeSection[i].nEndMin = Integer.parseInt(endTime.split(":")[1]); | ||
| 468 | - msg.stuTimeWeekDay[weekDay.getWeekDay()].stuTimeSection[i].nEndSec = 0; | ||
| 469 | - | ||
| 470 | - } | ||
| 471 | - }*/ | ||
| 472 | - | ||
| 473 | -// 获取 | ||
| 474 | -// if (ToolKits.GetDevConfig(lLong, nChannel, strCmd, msg)) { | ||
| 475 | -// System.out.println("Enable:" + msg.bEnable); | ||
| 476 | -// try { | ||
| 477 | -// System.out.println("自定义名称:" + new String(msg.szName, "UTF-8").trim()); | ||
| 478 | -// } catch (UnsupportedEncodingException e) { | ||
| 479 | -// e.printStackTrace(); | ||
| 480 | -// } | ||
| 481 | -// for (int i = 0; i < 7; i++) { | ||
| 482 | -// for (int j = 0; j < 4; j++) { | ||
| 483 | -// System.out.println("dwRecordMask:" + msg.stuTimeWeekDay[i].stuTimeSection[j].dwRecordMask); | ||
| 484 | -// System.out.println(msg.stuTimeWeekDay[i].stuTimeSection[j].startTime() + "-" + msg.stuTimeWeekDay[i].stuTimeSection[j].endTime() + "\n"); | ||
| 485 | -// } | ||
| 486 | -// } | ||
| 487 | -// msg.write(); | ||
| 488 | boolean set = ToolKits.SetDevConfig(lLong, nChannel, strCmd, msg); | 452 | boolean set = ToolKits.SetDevConfig(lLong, nChannel, strCmd, msg); | 
| 489 | -// msg.read(); | ||
| 490 | // 设置 | 453 | // 设置 | 
| 491 | if (set) { | 454 | if (set) { | 
| 492 | System.out.println("Set AccessTimeSchedule Succeed!"); | 455 | System.out.println("Set AccessTimeSchedule Succeed!"); | 
| 493 | } else { | 456 | } else { | 
| 494 | System.err.println("Set AccessTimeSchedule Failed!" + ToolKits.getErrorCodePrint()); | 457 | System.err.println("Set AccessTimeSchedule Failed!" + ToolKits.getErrorCodePrint()); | 
| 495 | } | 458 | } | 
| 496 | -// } else { | ||
| 497 | -// System.err.println("Get AccessTimeSchedule Failed!" + ToolKits.getErrorCodePrint()); | ||
| 498 | -// } | ||
| 499 | } catch (Exception e) { | 459 | } catch (Exception e) { | 
| 500 | e.printStackTrace(); | 460 | e.printStackTrace(); | 
| 501 | } | 461 | } | 
cloud/dahua/src/main/java/com/example/dahua/module/GateModule2.java
| @@ -267,11 +267,10 @@ public class GateModule2 { | @@ -267,11 +267,10 @@ public class GateModule2 { | ||
| 267 | /** | 267 | /** | 
| 268 | * 清空所有用户 | 268 | * 清空所有用户 | 
| 269 | */ | 269 | */ | 
| 270 | - public static void clearUser(LLong lLong) { | 270 | + public static boolean clearUser(LLong lLong) { | 
| 271 | // 用户操作类型 | 271 | // 用户操作类型 | 
| 272 | // 清空用户 | 272 | // 清空用户 | 
| 273 | int emtype = NET_EM_ACCESS_CTL_USER_SERVICE.NET_EM_ACCESS_CTL_USER_SERVICE_CLEAR; | 273 | int emtype = NET_EM_ACCESS_CTL_USER_SERVICE.NET_EM_ACCESS_CTL_USER_SERVICE_CLEAR; | 
| 274 | - | ||
| 275 | /** | 274 | /** | 
| 276 | * 入参 | 275 | * 入参 | 
| 277 | */ | 276 | */ | 
| @@ -289,8 +288,10 @@ public class GateModule2 { | @@ -289,8 +288,10 @@ public class GateModule2 { | ||
| 289 | boolean result = netsdk.CLIENT_OperateAccessUserService(lLong, emtype, stIn.getPointer(), stOut.getPointer(), TIME_OUT); | 288 | boolean result = netsdk.CLIENT_OperateAccessUserService(lLong, emtype, stIn.getPointer(), stOut.getPointer(), TIME_OUT); | 
| 290 | if (result) { | 289 | if (result) { | 
| 291 | log.info("清空用户成功!"); | 290 | log.info("清空用户成功!"); | 
| 291 | + return true; | ||
| 292 | } else { | 292 | } else { | 
| 293 | log.error("清空用户失败!"); | 293 | log.error("清空用户失败!"); | 
| 294 | + return false; | ||
| 294 | } | 295 | } | 
| 295 | } | 296 | } | 
| 296 | 297 | 
cloud/dahua/src/main/java/com/example/dahua/service/AttendanceService.java
| @@ -19,6 +19,6 @@ public interface AttendanceService { | @@ -19,6 +19,6 @@ public interface AttendanceService { | ||
| 19 | */ | 19 | */ | 
| 20 | int updateConnectState(int isConnection, String ip, String port); | 20 | int updateConnectState(int isConnection, String ip, String port); | 
| 21 | 21 | ||
| 22 | - int updateConnectStateWithDevid(int isConnection, String clint_id); | 22 | + int updateConnectStateWithDevid(int isConnection, String inTime, String clint_id); | 
| 23 | 23 | ||
| 24 | } | 24 | } | 
cloud/dahua/src/main/java/com/example/dahua/service/DeleteBatchTest.java
| @@ -12,4 +12,7 @@ public interface DeleteBatchTest { | @@ -12,4 +12,7 @@ public interface DeleteBatchTest { | ||
| 12 | void test(String schoolId); | 12 | void test(String schoolId); | 
| 13 | void test2(String schoolId); | 13 | void test2(String schoolId); | 
| 14 | void test3(String schoolId); | 14 | void test3(String schoolId); | 
| 15 | + | ||
| 16 | + void test4(Integer schoolId,Integer studentType,String sex); | ||
| 17 | + | ||
| 15 | } | 18 | } | 
cloud/dahua/src/main/java/com/example/dahua/service/UserOperateService.java
| 1 | -//package com.example.dahua.service; | ||
| 2 | -// | ||
| 3 | -///** | ||
| 4 | -// * 下发用户信息、人脸、卡、权限接口 | ||
| 5 | -// * @author xuquan | ||
| 6 | -// * @date 2020/12/1 11:08 | ||
| 7 | -// */ | ||
| 8 | -//public interface UserOperateService { | ||
| 9 | -// | ||
| 10 | -// void sendUserInfo(String file,int userType,String schoolId,String userId,String deviceId,String deviceType,int flag); | ||
| 11 | -// | ||
| 12 | -// void addFaceGroup(String file,int userType,String schoolId,String userId,String deviceId,String deviceType); | ||
| 13 | -//} | 1 | +package com.example.dahua.service; | 
| 2 | + | ||
| 3 | +import com.example.dahua.bean.SendFaceDto; | ||
| 4 | + | ||
| 5 | +/** | ||
| 6 | + * 下发用户信息、人脸、卡、权限接口 | ||
| 7 | + * @author xuquan | ||
| 8 | + * @date 2020/12/1 11:08 | ||
| 9 | + */ | ||
| 10 | +public interface UserOperateService { | ||
| 11 | + | ||
| 12 | + /** | ||
| 13 | + * 照片下发 | ||
| 14 | + * @param sendFaceDto | ||
| 15 | + */ | ||
| 16 | + void sendUserFaces(SendFaceDto sendFaceDto); | ||
| 17 | + | ||
| 18 | +} | 
cloud/dahua/src/main/java/com/example/dahua/service/imp/AttendanceImp.java
| @@ -24,7 +24,7 @@ public class AttendanceImp implements AttendanceService { | @@ -24,7 +24,7 @@ public class AttendanceImp implements AttendanceService { | ||
| 24 | String insertSql = String.format("insert into SZ_Attendance(clint_id, clint_type, ip, port, intime, school_id, state,isConnection) values ('%s','%s','%s','%s','%s','%s','%s','%s')", clint_id, clint_type, ip, port, intime, school_id, state, 1); | 24 | String insertSql = String.format("insert into SZ_Attendance(clint_id, clint_type, ip, port, intime, school_id, state,isConnection) values ('%s','%s','%s','%s','%s','%s','%s','%s')", clint_id, clint_type, ip, port, intime, school_id, state, 1); | 
| 25 | return jdbcTemplate.update(insertSql); | 25 | return jdbcTemplate.update(insertSql); | 
| 26 | } else {//设备 已经存在,更新在线状态 | 26 | } else {//设备 已经存在,更新在线状态 | 
| 27 | - updateConnectStateWithDevid(1, clint_id); | 27 | + updateConnectStateWithDevid(1,intime, clint_id); | 
| 28 | } | 28 | } | 
| 29 | } catch (Exception e) { | 29 | } catch (Exception e) { | 
| 30 | e.printStackTrace(); | 30 | e.printStackTrace(); | 
| @@ -54,10 +54,10 @@ public class AttendanceImp implements AttendanceService { | @@ -54,10 +54,10 @@ public class AttendanceImp implements AttendanceService { | ||
| 54 | } | 54 | } | 
| 55 | 55 | ||
| 56 | @Override | 56 | @Override | 
| 57 | - public int updateConnectStateWithDevid(int isConnection, String clint_id) { | 57 | + public int updateConnectStateWithDevid(int isConnection,String inTime, String clint_id) { | 
| 58 | int index = 0; | 58 | int index = 0; | 
| 59 | try { | 59 | try { | 
| 60 | - String updateSql = String.format(" update SZ_Attendance set isConnection = %d where clint_id = '%s' ", isConnection, clint_id); | 60 | + String updateSql = String.format(" update SZ_Attendance set isConnection = %d,inTime='%s' where clint_id = '%s' ", isConnection,inTime,clint_id); | 
| 61 | index = jdbcTemplate.update(updateSql); | 61 | index = jdbcTemplate.update(updateSql); | 
| 62 | // System.out.println("updateIndex:"+index+" isConnection:"+isConnection+"updateSql:"+updateSql); | 62 | // System.out.println("updateIndex:"+index+" isConnection:"+isConnection+"updateSql:"+updateSql); | 
| 63 | } catch (Exception e) { | 63 | } catch (Exception e) { | 
cloud/dahua/src/main/java/com/example/dahua/service/imp/BaseService.java
0 → 100644
| @@ -0,0 +1,133 @@ | @@ -0,0 +1,133 @@ | ||
| 1 | +package com.example.dahua.service.imp; | ||
| 2 | + | ||
| 3 | + | ||
| 4 | +import com.example.dahua.bean.SendRecordBean; | ||
| 5 | +import com.example.dahua.bean.StudentBean; | ||
| 6 | +import com.example.dahua.dao.UserDao; | ||
| 7 | +import com.example.dahua.xiananDao.SendRecordDao; | ||
| 8 | +import lombok.extern.slf4j.Slf4j; | ||
| 9 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 10 | +import org.springframework.stereotype.Service; | ||
| 11 | +import org.springframework.util.StringUtils; | ||
| 12 | + | ||
| 13 | +import java.text.SimpleDateFormat; | ||
| 14 | +import java.util.*; | ||
| 15 | +import java.util.stream.Collectors; | ||
| 16 | + | ||
| 17 | +/** | ||
| 18 | + * 业务基础类 | ||
| 19 | + * @author xuquan | ||
| 20 | + * @date 2020/12/23 10:16 | ||
| 21 | + */ | ||
| 22 | +@Slf4j | ||
| 23 | +@Service | ||
| 24 | +public class BaseService { | ||
| 25 | + | ||
| 26 | + @Autowired | ||
| 27 | + private SendRecordDao sendRecordDao; | ||
| 28 | + | ||
| 29 | + @Autowired | ||
| 30 | + private UserDao userDao; | ||
| 31 | + | ||
| 32 | + /** | ||
| 33 | + * 获取学校下学生数据 | ||
| 34 | + * @param schoolId | ||
| 35 | + * @param studentType | ||
| 36 | + * @param sex | ||
| 37 | + * @return | ||
| 38 | + */ | ||
| 39 | + public List<StudentBean> getStudentList(Integer schoolId, Integer studentType, String sex) { | ||
| 40 | + List<Integer> list = new ArrayList<>(); | ||
| 41 | + if(!StringUtils.isEmpty(sex)){ | ||
| 42 | + String[] msg = sex.split(","); | ||
| 43 | + for(String s : msg){ | ||
| 44 | + list.add(Integer.valueOf(s)); | ||
| 45 | + } | ||
| 46 | + } | ||
| 47 | + List<StudentBean> students = userDao.getStudentList(schoolId,studentType, list); | ||
| 48 | + //去重重复数据 | ||
| 49 | + List<StudentBean> studentList = students.stream().collect(Collectors.collectingAndThen( | ||
| 50 | + Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(StudentBean::getStudent_num))), ArrayList::new)); | ||
| 51 | + return studentList; | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + /** | ||
| 55 | + * 获取学校下老师数据 | ||
| 56 | + * @param schoolId | ||
| 57 | + * @return | ||
| 58 | + */ | ||
| 59 | + public List<StudentBean> getTeacherList(Integer schoolId) { | ||
| 60 | + List<StudentBean> teachers = userDao.getTeacherList(schoolId); | ||
| 61 | + //去重重复数据 | ||
| 62 | + List<StudentBean> teacherist = teachers.stream().collect(Collectors.collectingAndThen( | ||
| 63 | + Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(StudentBean::getTeacher_num))), ArrayList::new)); | ||
| 64 | + return teacherist; | ||
| 65 | + } | ||
| 66 | + | ||
| 67 | + /** | ||
| 68 | + * 保存成功下发记录 | ||
| 69 | + */ | ||
| 70 | + public synchronized void sendSuccessRecord(SendRecordBean recordBean) { | ||
| 71 | + try{ | ||
| 72 | + String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); | ||
| 73 | + Integer schoolId = recordBean.getSchoolId(); | ||
| 74 | + String deviceId = recordBean.getDeviceID(); | ||
| 75 | + String resultCard = recordBean.getNum(); | ||
| 76 | + String userId= recordBean.getUserId(); | ||
| 77 | + String schoolName = recordBean.getSchoolName(); | ||
| 78 | + String userName = recordBean.getName(); | ||
| 79 | + String faceUrl = recordBean.getImgPath(); | ||
| 80 | + Integer userType = recordBean.getUserType(); | ||
| 81 | + Integer deviceType = recordBean.getDeviceType(); | ||
| 82 | + List<SendRecordBean> sendRecordBeans = sendRecordDao.getRecordIsExit(schoolId,deviceId,resultCard,userId); | ||
| 83 | + SendRecordBean sendRecordBean =null; | ||
| 84 | + if(sendRecordBeans.size()>0){ | ||
| 85 | + sendRecordBean = sendRecordBeans.get(0); | ||
| 86 | + } | ||
| 87 | + if (null == sendRecordBean) { | ||
| 88 | + sendRecordDao.saveFaceRecord(userId, deviceId, resultCard, userName, time, schoolName, | ||
| 89 | + faceUrl, schoolId,null,null, userType,deviceType,1); | ||
| 90 | + } else { | ||
| 91 | + sendRecordDao.updateFaceSuccessRecord(deviceId, resultCard, time, faceUrl, userName, userId); | ||
| 92 | + } | ||
| 93 | + }catch (Exception e){ | ||
| 94 | + log.error("保存成功记录失败。"); | ||
| 95 | + return; | ||
| 96 | + } | ||
| 97 | + } | ||
| 98 | + | ||
| 99 | + | ||
| 100 | + /** | ||
| 101 | + * 保存下发失败记录 | ||
| 102 | + */ | ||
| 103 | + public synchronized void sendFailRecord(SendRecordBean recordBean) { | ||
| 104 | + try{ | ||
| 105 | + String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); | ||
| 106 | + Integer schoolId = recordBean.getSchoolId(); | ||
| 107 | + String deviceId = recordBean.getDeviceID(); | ||
| 108 | + String resultCard = recordBean.getNum(); | ||
| 109 | + String userId= recordBean.getUserId(); | ||
| 110 | + String schoolName = recordBean.getSchoolName(); | ||
| 111 | + String userName = recordBean.getName(); | ||
| 112 | + String faceUrl = recordBean.getImgPath(); | ||
| 113 | + Integer userType = recordBean.getUserType(); | ||
| 114 | + Integer failType = recordBean.getFailType(); | ||
| 115 | + String failContent = recordBean.getFailContent(); | ||
| 116 | + Integer deviceType = recordBean.getDeviceType(); | ||
| 117 | + List<SendRecordBean> sendRecordBeans = sendRecordDao.getRecordIsExit(schoolId,deviceId,resultCard,userId); | ||
| 118 | + SendRecordBean sendRecordBean =null; | ||
| 119 | + if(sendRecordBeans.size()>0){ | ||
| 120 | + sendRecordBean = sendRecordBeans.get(0); | ||
| 121 | + } | ||
| 122 | + if (null == sendRecordBean) { | ||
| 123 | + sendRecordDao.saveFaceRecord(userId, deviceId, resultCard, userName, time, schoolName, | ||
| 124 | + faceUrl, schoolId,failContent,failType, userType,deviceType,2); | ||
| 125 | + }else { | ||
| 126 | + sendRecordDao.updateFaceFailRecord(deviceId,faceUrl,resultCard,time,failContent,userId); | ||
| 127 | + } | ||
| 128 | + }catch (Exception e){ | ||
| 129 | + log.error("保存失败记录失败。"); | ||
| 130 | + return; | ||
| 131 | + } | ||
| 132 | + } | ||
| 133 | +} | 
cloud/dahua/src/main/java/com/example/dahua/service/imp/DeleteBatchTestImpl.java
| 1 | package com.example.dahua.service.imp; | 1 | package com.example.dahua.service.imp; | 
| 2 | 2 | ||
| 3 | import com.example.dahua.bean.SendRecordBean; | 3 | import com.example.dahua.bean.SendRecordBean; | 
| 4 | +import com.example.dahua.bean.StudentBean; | ||
| 4 | import com.example.dahua.bean.UserInfoBean; | 5 | import com.example.dahua.bean.UserInfoBean; | 
| 5 | import com.example.dahua.dao.UserDao; | 6 | import com.example.dahua.dao.UserDao; | 
| 6 | import com.example.dahua.service.DeleteBatchTest; | 7 | import com.example.dahua.service.DeleteBatchTest; | 
| @@ -8,8 +9,10 @@ import com.example.dahua.xiananDao.SendRecordDao; | @@ -8,8 +9,10 @@ import com.example.dahua.xiananDao.SendRecordDao; | ||
| 8 | import org.springframework.beans.factory.annotation.Autowired; | 9 | import org.springframework.beans.factory.annotation.Autowired; | 
| 9 | import org.springframework.stereotype.Repository; | 10 | import org.springframework.stereotype.Repository; | 
| 10 | import org.springframework.stereotype.Service; | 11 | import org.springframework.stereotype.Service; | 
| 12 | +import org.springframework.util.StringUtils; | ||
| 11 | 13 | ||
| 12 | -import java.util.List; | 14 | +import java.util.*; | 
| 15 | +import java.util.stream.Collectors; | ||
| 13 | 16 | ||
| 14 | /** | 17 | /** | 
| 15 | * TODO | 18 | * TODO | 
| @@ -25,6 +28,9 @@ public class DeleteBatchTestImpl implements DeleteBatchTest { | @@ -25,6 +28,9 @@ public class DeleteBatchTestImpl implements DeleteBatchTest { | ||
| 25 | private UserDao userDao; | 28 | private UserDao userDao; | 
| 26 | @Autowired | 29 | @Autowired | 
| 27 | private SendRecordDao sendRecordDao; | 30 | private SendRecordDao sendRecordDao; | 
| 31 | + @Autowired | ||
| 32 | + private BaseService baseService; | ||
| 33 | + | ||
| 28 | 34 | ||
| 29 | @Override | 35 | @Override | 
| 30 | public void test(String schoolId) { | 36 | public void test(String schoolId) { | 
| @@ -39,7 +45,7 @@ public class DeleteBatchTestImpl implements DeleteBatchTest { | @@ -39,7 +45,7 @@ public class DeleteBatchTestImpl implements DeleteBatchTest { | ||
| 39 | if(sendRecords.size()>0){ | 45 | if(sendRecords.size()>0){ | 
| 40 | sendRecordDao.deleteFaceFailTest(s.getDeviceID(),s.getNum(),String.valueOf(s.getSchoolId())); | 46 | sendRecordDao.deleteFaceFailTest(s.getDeviceID(),s.getNum(),String.valueOf(s.getSchoolId())); | 
| 41 | //获取用户iD | 47 | //获取用户iD | 
| 42 | - String userId = userDao.getUerIdWithNumTest(s.getNum(),String.valueOf(s.getSchoolId())); | 48 | + String userId = userDao.getUerIdWithNumTest(s.getNum(),s.getSchoolId()); | 
| 43 | //获取记录集编号 | 49 | //获取记录集编号 | 
| 44 | List<String> recordNos = userDao.getRecordNoTest(s.getName(),userId,s.getDeviceID()); | 50 | List<String> recordNos = userDao.getRecordNoTest(s.getName(),userId,s.getDeviceID()); | 
| 45 | if(recordNos.size()>0){ | 51 | if(recordNos.size()>0){ | 
| @@ -62,7 +68,7 @@ public class DeleteBatchTestImpl implements DeleteBatchTest { | @@ -62,7 +68,7 @@ public class DeleteBatchTestImpl implements DeleteBatchTest { | ||
| 62 | int i = 0; | 68 | int i = 0; | 
| 63 | for(SendRecordBean s : sendRecordBeanList){ | 69 | for(SendRecordBean s : sendRecordBeanList){ | 
| 64 | //获取用户iD | 70 | //获取用户iD | 
| 65 | - String userId = userDao.getUerIdWithNumTest(s.getNum(),String.valueOf(s.getSchoolId())); | 71 | + String userId = userDao.getUerIdWithNumTest(s.getNum(),s.getSchoolId()); | 
| 66 | //获取记录集编号 | 72 | //获取记录集编号 | 
| 67 | List<String> recordNos = userDao.getRecordNoTest(s.getName(),userId,s.getDeviceID()); | 73 | List<String> recordNos = userDao.getRecordNoTest(s.getName(),userId,s.getDeviceID()); | 
| 68 | if(recordNos.size()>0){ | 74 | if(recordNos.size()>0){ | 
| @@ -92,4 +98,31 @@ public class DeleteBatchTestImpl implements DeleteBatchTest { | @@ -92,4 +98,31 @@ public class DeleteBatchTestImpl implements DeleteBatchTest { | ||
| 92 | } | 98 | } | 
| 93 | } | 99 | } | 
| 94 | 100 | ||
| 101 | + @Override | ||
| 102 | + public void test4(Integer schoolId,Integer studentType,String sex) { | ||
| 103 | + String str = "949252605603,949252365603,949251825603,949252545603,949252345603,949252245603,949252185603,949252085603,949252285603,949252725603,949252305603,949252065603,949251885603,949252525603,949251945603,949252625603,949251985603,949252505603"; | ||
| 104 | + String[] deviceArr = str.split(","); | ||
| 105 | + List<String> deviceList= new ArrayList<>(Arrays.asList(deviceArr)); | ||
| 106 | + List<StudentBean> lists = baseService.getStudentList(schoolId, studentType, sex); | ||
| 107 | + if(lists.size() >0){ | ||
| 108 | + System.out.println("总数 :"+lists.size()); | ||
| 109 | +// int i = 0; | ||
| 110 | +// for(StudentBean studentBean : lists){ | ||
| 111 | +// String cardNum = studentBean.getStudent_num(); | ||
| 112 | +// String userId = studentBean.getUser_id(); | ||
| 113 | +// for (String sno : deviceList){ | ||
| 114 | +// List<SendRecordBean> sendRecordBeans = sendRecordDao.getRecordIsExit(schoolId,sno,cardNum,userId); | ||
| 115 | +// SendRecordBean sendRecordBean =null; | ||
| 116 | +// if(sendRecordBeans.size()>0){ | ||
| 117 | +// System.out.println("进行删除:"+i); | ||
| 118 | +// sendRecordBean = sendRecordBeans.get(0); | ||
| 119 | +// sendRecordDao.deleteRecord(sendRecordBean.getId()); | ||
| 120 | +// } | ||
| 121 | +// } | ||
| 122 | +// i++; | ||
| 123 | +// } | ||
| 124 | + System.out.println("完成"); | ||
| 125 | + } | ||
| 126 | + } | ||
| 127 | + | ||
| 95 | } | 128 | } | 
cloud/dahua/src/main/java/com/example/dahua/service/imp/UserOperateServiceImpl.java
| 1 | -//package com.example.dahua.service.imp; | ||
| 2 | -// | ||
| 3 | -//import com.example.dahua.MyTask; | ||
| 4 | -//import com.example.dahua.bean.*; | ||
| 5 | -//import com.example.dahua.dao.UserDao; | ||
| 6 | -//import com.example.dahua.enums.EnumDeviceType; | ||
| 7 | -//import com.example.dahua.enums.EnumSendFaceType; | ||
| 8 | -//import com.example.dahua.enums.EnumSzBusinessType; | ||
| 9 | -//import com.example.dahua.lib.CompressPic; | ||
| 10 | -//import com.example.dahua.lib.FilePath; | ||
| 11 | -//import com.example.dahua.lib.NetSDKLib; | ||
| 12 | -//import com.example.dahua.module.GateModule2; | ||
| 13 | -//import com.example.dahua.service.PermissFaceService; | ||
| 14 | -//import com.example.dahua.service.UserOperateService; | ||
| 15 | -//import com.example.dahua.service.UserService; | ||
| 16 | -//import com.example.dahua.utils.DateFormatUtil; | ||
| 17 | -//import com.example.dahua.utils.FileUtils; | ||
| 18 | -//import com.example.dahua.utils.JsonUtils; | ||
| 19 | -//import com.example.dahua.xiananDao.SendRecordDao; | ||
| 20 | -//import lombok.extern.slf4j.Slf4j; | ||
| 21 | -//import org.springframework.beans.factory.annotation.Autowired; | ||
| 22 | -//import org.springframework.stereotype.Service; | ||
| 23 | -//import org.springframework.util.StringUtils; | ||
| 24 | -// | ||
| 25 | -//import java.util.Date; | ||
| 26 | -//import java.util.List; | ||
| 27 | -// | ||
| 28 | -///** | ||
| 29 | -// * 下发用户信息、人脸、卡、权限接口实现类 | ||
| 30 | -// * @author xuquan | ||
| 31 | -// * @date 2020/12/1 11:12 | ||
| 32 | -// */ | ||
| 33 | -//@Slf4j | ||
| 34 | -//@Service | ||
| 35 | -//public class UserOperateServiceImpl implements UserOperateService { | ||
| 36 | -// | ||
| 37 | -// @Autowired | ||
| 38 | -// private UserDao userDao; | ||
| 39 | -// @Autowired | ||
| 40 | -// private SendRecordDao sendRecordDao; | ||
| 41 | -// @Autowired | ||
| 42 | -// private UserService userService; | ||
| 43 | -// @Autowired | ||
| 44 | -// PermissFaceService permissFaceService; | ||
| 45 | -// | ||
| 46 | -// private static JsonUtils objectMapper = JsonUtils.nonEmptyMapper(); | ||
| 47 | -// | ||
| 48 | -// @Override | ||
| 49 | -// public void sendUserInfo(String filePath,int userType,String schoolId,String userId,String deviceId,String deviceType,int flag) { | ||
| 50 | -// String schoolName= userDao.getSchoolName(schoolId); | ||
| 51 | -// if(StringUtils.isEmpty(schoolName)){ | ||
| 52 | -// log.info("下发用户失败,学校ID: {},未查询到对应学校.",schoolId); | ||
| 53 | -// return; | ||
| 54 | -// } | ||
| 55 | -// //获取学生信息 | ||
| 56 | -// UserInfoBean userInfoBean = null; | ||
| 57 | -// if (userType == EnumSzBusinessType.EnumUserType.STUDENT.code) { | ||
| 58 | -// userInfoBean = userDao.getUserInfoByUserId(schoolId,userId); | ||
| 59 | -// if(null == userInfoBean){ | ||
| 60 | -// log.info("下发学生信息失败,学校ID: {},用户ID: {},未查询到对应学生.",schoolId,userId); | ||
| 61 | -// return; | ||
| 62 | -// } | ||
| 63 | -// } | ||
| 64 | -// //获取老师信息 | ||
| 65 | -// if (userType == EnumSzBusinessType.EnumUserType.TEACHER.code){ | ||
| 66 | -// TeacherBean teacher = userDao.getTeacherByUserId(schoolId,userId); | ||
| 67 | -// if (null == teacher) { | ||
| 68 | -// log.info("下发教师信息失败,学校ID: {},用户ID: {},未查询到对应教师.",schoolId,userId); | ||
| 69 | -// return; | ||
| 70 | -// } | ||
| 71 | -// userInfoBean.setStudent_num(teacher.getTeacher_num()); | ||
| 72 | -// userInfoBean.setName(teacher.getName()); | ||
| 73 | -// userInfoBean.setUser_id(teacher.getUser_id()); | ||
| 74 | -// userInfoBean.setStudentcode(teacher.getNum()); | ||
| 75 | -// userInfoBean.setStudent_id(teacher.getTeacher_id()); | ||
| 76 | -// userInfoBean.setSchool_id(teacher.getSchool_id()); | ||
| 77 | -// } | ||
| 78 | -// //如果未传指定设备ID,则获取学校下所有设备进行下发 | ||
| 79 | -// List<AttendanceBean> attendanceBeans = userService.getAttendanceBeans(schoolId, String.valueOf(deviceType), deviceId); | ||
| 80 | -// if(attendanceBeans.size()<1){ | ||
| 81 | -// log.info("下发用户信息失败,学校ID: {},设备类型:{},未查询到对应设备.",schoolId,deviceType); | ||
| 82 | -// return; | ||
| 83 | -// } | ||
| 84 | -// //下发用户 | ||
| 85 | -// sendUser(filePath,attendanceBeans,userInfoBean,userType,Integer.parseInt(deviceType),flag); | ||
| 86 | -// } | ||
| 87 | -// | ||
| 88 | -// | ||
| 89 | -// /** | ||
| 90 | -// * 下发用户 | ||
| 91 | -// * @param filePath | ||
| 92 | -// * @param attendanceBeans | ||
| 93 | -// * @param userInfoBean | ||
| 94 | -// * @param userType | ||
| 95 | -// * @param deviceType | ||
| 96 | -// * @param flag | ||
| 97 | -// */ | ||
| 98 | -// private void sendUser(String filePath,List<AttendanceBean> attendanceBeans,UserInfoBean userInfoBean,int userType,int deviceType,int flag){ | ||
| 99 | -// String facePath = compressPic(filePath,userInfoBean.getStudentcode()); | ||
| 100 | -// if(StringUtils.isEmpty(facePath)){ | ||
| 101 | -// log.warn("压缩后图片路径为空!"); | ||
| 102 | -// return; | ||
| 103 | -// } | ||
| 104 | -// //下发至所有设备 | ||
| 105 | -// for (AttendanceBean attendanceBean : attendanceBeans) { | ||
| 106 | -// //下发用户有效期 | ||
| 107 | -// String startTime = DateFormatUtil.dateFormatString(new Date(), "yyyy-MM-dd HH:mm:ss"); | ||
| 108 | -// Date endDate = DateFormatUtil.getDateByYearLength(4, new Date()); | ||
| 109 | -// String endTime = DateFormatUtil.dateFormatString(endDate, "yyyy-MM-dd HH:mm:ss"); | ||
| 110 | -// //学校 | ||
| 111 | -// String schoolId = attendanceBean.getSchool_id(); | ||
| 112 | -// String schoolName = userDao.getSchoolName(schoolId); | ||
| 113 | -// //用户ID | ||
| 114 | -// String userId = userInfoBean.getUser_id(); | ||
| 115 | -// //学生ID,老师ID | ||
| 116 | -// String studentId = userInfoBean.getStudent_id(); | ||
| 117 | -// //设备ID | ||
| 118 | -// String deviceId = attendanceBean.getClint_id(); | ||
| 119 | -// //学生姓名 | ||
| 120 | -// String userName = userInfoBean.getName(); | ||
| 121 | -// //卡号 | ||
| 122 | -// String studentNum = userInfoBean.getStudent_num(); | ||
| 123 | -// if(flag == EnumSzBusinessType.EnumSendType.TWO.code || flag == EnumSzBusinessType.EnumSendType.THREE.code){ | ||
| 124 | -// if(StringUtils.isEmpty(studentNum)){ | ||
| 125 | -// log.error("下发失败, 用户卡号不存在。"); | ||
| 126 | -// return; | ||
| 127 | -// } | ||
| 128 | -// } | ||
| 129 | -// //通道号 | ||
| 130 | -// String channel =""; | ||
| 131 | -// if (userType == EnumSzBusinessType.EnumUserType.STUDENT.code){ | ||
| 132 | -// //根据学生ID\学校ID获取学生类型 | ||
| 133 | -// String studentType = userDao.getStudentType(schoolId, studentId); | ||
| 134 | -// channel = analysisPermission(Integer.parseInt(schoolId), studentType); | ||
| 135 | -// } | ||
| 136 | -// | ||
| 137 | -// //登录设备 | ||
| 138 | -// NetSDKLib.LLong loginHandleLong = MyTask.lLongMap.get(attendanceBean.getClint_id()); | ||
| 139 | -// //若设备不在线时,且人脸下发失败表中存在记录,则执行修改下发失败状态为:设备不在线 | ||
| 140 | -// if (loginHandleLong == null) { | ||
| 141 | -// log.info(", 设备ID: {},设备不在线", attendanceBean.getClint_id()); | ||
| 142 | -// FileUtils.getInstance().writeLogs("设备不在线:" + attendanceBean.getClint_id(), FileUtils.devices); | ||
| 143 | -// //设备不在线 | ||
| 144 | -// int failType = EnumSendFaceType.NOT_ONLINE_DEVICE.code; | ||
| 145 | -// String failContent = EnumSendFaceType.NOT_ONLINE_DEVICE.message; | ||
| 146 | -// saveSendFailRecord(Integer.parseInt(schoolId),schoolName,userType,userName,filePath,studentId,studentNum,failType,failContent,deviceId,deviceType); | ||
| 147 | -// } else { | ||
| 148 | -// log.info("=================开始执行下发人脸及卡号任务================="); | ||
| 149 | -// /** | ||
| 150 | -// * 下发升级二代接口,动态库libs下win64,更新为官方最新版sdk | ||
| 151 | -// * 注:用户下发方案: | ||
| 152 | -// * flag=1:用户+人脸 flag=2:用户+卡号;flag=3:用户+人脸+卡号 | ||
| 153 | -// * 新增: 用户信息和卡信息,一同下发, 人脸单独下发;返回信息 0 为成功,其他为相应错误码 参考:NET_EM_FAILCODE | ||
| 154 | -// * 修改: 同上 | ||
| 155 | -// * 复用一代接口字段recordNo,新增时为默认添加,修改时,查询表字段不为空,则表示此用户以存在设备中。则进行修改 | ||
| 156 | -// */ | ||
| 157 | -// //人脸操作错误号:0为成功,其他为相应错误号 | ||
| 158 | -// int bFaceFalgs = -1; | ||
| 159 | -// //用户操作错误号:0为成功,其他为相应错误号 | ||
| 160 | -// int bUserFlags = -1; | ||
| 161 | -// //卡操作错误号 :0为成功,其他为相应错误号 | ||
| 162 | -// int bCardFlags = -1; | ||
| 163 | -// //获取记录集编号 | ||
| 164 | -// String recordNo = userDao.getRecordNo(userId, deviceId); | ||
| 165 | -// String cardNum =""; | ||
| 166 | -// if (attendanceBean.getClint_id().startsWith("ytj") && Integer.parseInt(attendanceBean.getSchool_id()) != 126 | ||
| 167 | -// && Integer.parseInt(attendanceBean.getSchool_id()) != 393) { | ||
| 168 | -// cardNum = studentNum; | ||
| 169 | -// deviceType = EnumDeviceType.DH_FACE_YTJ.deviceType; | ||
| 170 | -// } else { | ||
| 171 | -// //卡号取反 | ||
| 172 | -// cardNum = cardNo(studentNum); | ||
| 173 | -// } | ||
| 174 | -// try { | ||
| 175 | -// /** | ||
| 176 | -// * recordNo 不为空存在下发记录集编号,直接修改执行人脸信息(二代升级接口,此处不需要修改用户信息) | ||
| 177 | -// */ | ||
| 178 | -// if (!StringUtils.isEmpty(recordNo)) { | ||
| 179 | -// //修改用户信息 | ||
| 180 | -// bUserFlags = GateModule2.addUser(userId,userName,userType,"123456",channel,startTime,endTime,loginHandleLong); | ||
| 181 | -// if(flag == EnumSzBusinessType.EnumSendType.TWO.code || flag == EnumSzBusinessType.EnumSendType.THREE.code){ | ||
| 182 | -// //修改卡 | ||
| 183 | -// bCardFlags = GateModule2.modifyCard(userId,cardNum,loginHandleLong); | ||
| 184 | -// } | ||
| 185 | -// if(flag == EnumSzBusinessType.EnumSendType.ONE.code || flag == EnumSzBusinessType.EnumSendType.THREE.code){ | ||
| 186 | -// //修改人脸 | ||
| 187 | -// bFaceFalgs = GateModule2.modifyFace(userId,facePath,loginHandleLong); | ||
| 188 | -// } | ||
| 189 | -// if(bFaceFalgs != 0 ){ | ||
| 190 | -// //未知错误、对返回数据校验出错,执行删除用户,重新下发 | ||
| 191 | -// if(bFaceFalgs == EnumSzBusinessType.EnumOperateErrorType.ONE.code || bFaceFalgs == EnumSzBusinessType.EnumOperateErrorType.ERR_21.code){ | ||
| 192 | -// if(GateModule2.deleteUser(userId,loginHandleLong) == 0){ | ||
| 193 | -// bUserFlags = GateModule2.addUser(userId,userName,userType,"123456",channel,startTime,endTime,loginHandleLong); | ||
| 194 | -// if(flag == EnumSzBusinessType.EnumSendType.TWO.code || flag == EnumSzBusinessType.EnumSendType.THREE.code){ | ||
| 195 | -// //新增卡 | ||
| 196 | -// bCardFlags = GateModule2.addCard(userId,cardNum,loginHandleLong); | ||
| 197 | -// } | ||
| 198 | -// if(flag == EnumSzBusinessType.EnumSendType.ONE.code || flag == EnumSzBusinessType.EnumSendType.THREE.code){ | ||
| 199 | -// //新增人脸 | ||
| 200 | -// bFaceFalgs = GateModule2.addFace(userId,facePath,loginHandleLong); | ||
| 201 | -// } | ||
| 202 | -// | ||
| 203 | -// } | ||
| 204 | -// } | ||
| 205 | -// } | ||
| 206 | -// } else { | ||
| 207 | -// if(flag == EnumSzBusinessType.EnumSendType.TWO.code || flag == EnumSzBusinessType.EnumSendType.THREE.code){ | ||
| 208 | -// //新增卡 | ||
| 209 | -// bCardFlags = GateModule2.addCard(userId,cardNum,loginHandleLong); | ||
| 210 | -// } | ||
| 211 | -// if(flag == EnumSzBusinessType.EnumSendType.ONE.code || flag == EnumSzBusinessType.EnumSendType.THREE.code){ | ||
| 212 | -// //新增人脸 | ||
| 213 | -// bFaceFalgs = GateModule2.addFace(userId,facePath,loginHandleLong); | ||
| 214 | -// } | ||
| 215 | -// //三种方式都下发成功,则新增记录集信息,默认为1 | ||
| 216 | -// if ((bFaceFalgs ==0 && bUserFlags ==0)||(bCardFlags ==0 && bUserFlags ==0)||(bFaceFalgs ==0 && bUserFlags ==0 && bCardFlags ==0)) { | ||
| 217 | -// userDao.saveRecordNo(userId,1, userName, deviceId); | ||
| 218 | -// } | ||
| 219 | -// } | ||
| 220 | -// } catch (Exception e) { | ||
| 221 | -// log.error("下发异常:异常错误信息msg: {}", e.getMessage()); | ||
| 222 | -// continue; | ||
| 223 | -// } | ||
| 224 | -// /** | ||
| 225 | -// * 人脸和卡都下发成功 | ||
| 226 | -// */ | ||
| 227 | -// if (bUserFlags ==0 && bFaceFalgs ==0) { | ||
| 228 | -// FileUtils.getInstance().writeLogs("下发用户和人脸成功: userName: " + userName + ",设备ID: " + deviceId, FileUtils.sendUserSucTxt); | ||
| 229 | -// log.info("下发用户和人脸成功: userName: " + userName + ",设备ID: " + deviceId); | ||
| 230 | -// saveSendSuccessRecord(Integer.parseInt(schoolId),schoolName,userType,userName,filePath,studentId,studentNum,deviceId,deviceType); | ||
| 231 | -// } | ||
| 232 | -// if (bUserFlags ==0 && bCardFlags ==0) { | ||
| 233 | -// FileUtils.getInstance().writeLogs("下发用户和卡号成功: userName: " + userName +",卡号: "+ cardNum + ",设备ID: " + deviceId, FileUtils.sendUserSucTxt); | ||
| 234 | -// log.info("下发用户和卡号成功: userName: " + userName +",卡号: "+ cardNum + ",设备ID: " + deviceId); | ||
| 235 | -// saveSendSuccessRecord(Integer.parseInt(schoolId),schoolName,userType,userName,filePath,studentId,studentNum,deviceId,deviceType); | ||
| 236 | -// } | ||
| 237 | -// if (bFaceFalgs ==0 && bUserFlags ==0 && bCardFlags ==0) { | ||
| 238 | -// FileUtils.getInstance().writeLogs("下发用户和人脸、卡号成功: userName: " + userName +",卡号: "+ cardNum + ",设备ID: " + deviceId, FileUtils.sendUserSucTxt); | ||
| 239 | -// log.info("下发用户和人脸、卡号成功: userName: " + userName +",卡号: "+ cardNum + ",设备ID: " + deviceId); | ||
| 240 | -// saveSendSuccessRecord(Integer.parseInt(schoolId),schoolName,userType,userName,filePath,studentId,studentNum,deviceId,deviceType); | ||
| 241 | -// } | ||
| 242 | -// /** | ||
| 243 | -// * 人脸和人脸都下发失败 | ||
| 244 | -// */ | ||
| 245 | -// if (bUserFlags < 0 && bFaceFalgs < 0 ) { | ||
| 246 | -// FileUtils.getInstance().writeLogs("下发用户和人脸和失败: userName: " + userName + ",设备ID: " + deviceId, FileUtils.sendUserErrTxt); | ||
| 247 | -// log.info("下发用户和人脸和失败: userName: " + userName + ",设备ID: " + deviceId); | ||
| 248 | -// //失败信息 | ||
| 249 | -// int failType = EnumSendFaceType.FACE_AND_CARD_FAIL.code; | ||
| 250 | -// String failContent = analysisErrorMsg(bUserFlags,bFaceFalgs,bCardFlags); | ||
| 251 | -// saveSendFailRecord(Integer.parseInt(schoolId),schoolName,userType,userName,filePath,studentId,studentNum,failType,failContent,deviceId,deviceType); | ||
| 252 | -// } | ||
| 253 | -// /** | ||
| 254 | -// * 人脸和卡都下发失败 | ||
| 255 | -// */ | ||
| 256 | -// if (bUserFlags < 0 && bCardFlags< 0) { | ||
| 257 | -// FileUtils.getInstance().writeLogs("下发用户和卡号失败: userName: " + userName + ",设备ID: " + deviceId, FileUtils.sendUserErrTxt); | ||
| 258 | -// log.info("下发用户和卡号失败: userName: " + userName + ",设备ID: " + deviceId); | ||
| 259 | -// //失败信息 | ||
| 260 | -// int failType = EnumSendFaceType.FACE_AND_CARD_FAIL.code; | ||
| 261 | -// String failContent = analysisErrorMsg(bUserFlags,bFaceFalgs,bCardFlags); | ||
| 262 | -// saveSendFailRecord(Integer.parseInt(schoolId),schoolName,userType,userName,filePath,studentId,studentNum,failType,failContent,deviceId,deviceType); | ||
| 263 | -// } | ||
| 264 | -// /** | ||
| 265 | -// * 下发卡号成功,下发人脸失败, | ||
| 266 | -// */ | ||
| 267 | -// if (bUserFlags < 0 && bCardFlags < 0 && bFaceFalgs < 0) { | ||
| 268 | -// FileUtils.getInstance().writeLogs("下发用户、人脸、卡号失败: userName: " + userName + ",设备ID: " + deviceId, FileUtils.sendUserErrTxt); | ||
| 269 | -// log.info("下发用户、人脸、卡号失败: userName: " + userName + ",设备ID: " + deviceId); | ||
| 270 | -// //失败信息 | ||
| 271 | -// int failType = EnumSendFaceType.FACE_AND_CARD_FAIL.code; | ||
| 272 | -// String failContent = analysisErrorMsg(bUserFlags,bFaceFalgs,bCardFlags); | ||
| 273 | -// saveSendFailRecord(Integer.parseInt(schoolId),schoolName,userType,userName,filePath,studentId,studentNum,failType,failContent,deviceId,deviceType); | ||
| 274 | -// } | ||
| 275 | -// /** | ||
| 276 | -//// * 下发卡号失败,下发人脸成功, | ||
| 277 | -//// */ | ||
| 278 | -//// if (bUserFlags ==0 && bCardFlags == 0 && bFaceFalgs !=0) { | ||
| 279 | -//// FileUtils.getInstance().writeLogs("卡信息已存在,下发人脸成功:" + cardNum + " " + attendanceBean.getClint_id(), FileUtils.sendUserSucTxt); | ||
| 280 | -//// //失败信息 | ||
| 281 | -//// String failContent = analysisErrorMsg(bUserFlags,bFaceFalgs,bCardFlags); | ||
| 282 | -//// sendRecordBean.setFailType(EnumSendFaceType.FACE_SUCCESS_CARD_FAIl.code); | ||
| 283 | -//// sendRecordBean.setFailContent(failContent); | ||
| 284 | -//// sendRecordDao.updateFace(sendRecordBean.getNum(), sendRecordBean.getDeviceID(), sendRecordBean.getFailType(), EnumSendFaceType.FACE_SUCCESS_CARD_FAIl.code); | ||
| 285 | -//// addFailDace(sendRecordBean); | ||
| 286 | -//// } | ||
| 287 | -// } | ||
| 288 | -// } | ||
| 289 | -// } | ||
| 290 | -// | ||
| 291 | -// /** | ||
| 292 | -// * 解析下发异常信息 | ||
| 293 | -// * @param userErrNum | ||
| 294 | -// * @param faceErrNum | ||
| 295 | -// * @return | ||
| 296 | -// */ | ||
| 297 | -// private String analysisErrorMsg(int userErrNum,int faceErrNum,int cardErrNum){ | ||
| 298 | -// StringBuffer sb = new StringBuffer(); | ||
| 299 | -// //用户信息 | ||
| 300 | -// if(!StringUtils.isEmpty(userErrNum)){ | ||
| 301 | -// EnumSzBusinessType.EnumOperateErrorType operateErrorType = EnumSzBusinessType.EnumOperateErrorType.getByCode(userErrNum); | ||
| 302 | -// String message = ""; | ||
| 303 | -// if(operateErrorType !=null){ | ||
| 304 | -// message= operateErrorType.getMessage(); | ||
| 305 | -// sb.append("下发用户信息:").append(message).append(";"); | ||
| 306 | -// } | ||
| 307 | -// log.info("下发用户失败,错误码:{},错误描述:{}",userErrNum,message); | ||
| 308 | -// } | ||
| 309 | -// //卡异常信息 | ||
| 310 | -// if(!StringUtils.isEmpty(cardErrNum)){ | ||
| 311 | -// EnumSzBusinessType.EnumOperateErrorType operateErrorType = EnumSzBusinessType.EnumOperateErrorType.getByCode(cardErrNum); | ||
| 312 | -// String message = ""; | ||
| 313 | -// if(operateErrorType !=null){ | ||
| 314 | -// message= operateErrorType.getMessage(); | ||
| 315 | -// sb.append("下发用户卡信息:").append(message).append(";"); | ||
| 316 | -// } | ||
| 317 | -// log.info("下发用户卡失败,错误码:{},错误描述:{}",cardErrNum,message); | ||
| 318 | -// } | ||
| 319 | -// //人脸异常信息 | ||
| 320 | -// if(!StringUtils.isEmpty(faceErrNum)){ | ||
| 321 | -// EnumSzBusinessType.EnumOperateErrorType operateErrorType = EnumSzBusinessType.EnumOperateErrorType.getByCode(faceErrNum); | ||
| 322 | -// String message = ""; | ||
| 323 | -// if(operateErrorType !=null){ | ||
| 324 | -// message= operateErrorType.getMessage(); | ||
| 325 | -// sb.append("下发用户人脸:").append(message); | ||
| 326 | -// } | ||
| 327 | -// log.info("下发用户人脸失败,错误码:{},错误描述:{}",faceErrNum,message); | ||
| 328 | -// } | ||
| 329 | -// return sb.toString(); | ||
| 330 | -// } | ||
| 331 | -// | ||
| 332 | -// /** | ||
| 333 | -// * 保存下发记录 | ||
| 334 | -// */ | ||
| 335 | -// private void saveSendFailRecord(int schoolId,String schoolName,int userType,String userName,String filePath,String customerId, | ||
| 336 | -// String cardNum,int failType,String failContent,String deviceId,int deviceType){ | ||
| 337 | -// //设置下发记录 | ||
| 338 | -// String time = DateFormatUtil.dateFormatString(new Date(),"yyyy-MM-dd HH:mm:ss"); | ||
| 339 | -// //获取指定设备指定用户的人脸失败记录 | ||
| 340 | -// List<SendRecordBean> sendRecordBeanList = sendRecordDao.getFaceFailIsExit(deviceId, customerId); | ||
| 341 | -// if(sendRecordBeanList.size() >0){ | ||
| 342 | -// //删除失败记录 | ||
| 343 | -// for (SendRecordBean recordBean : sendRecordBeanList) { | ||
| 344 | -// sendRecordDao.deleteFaceFail(recordBean.getNum(), recordBean.getDeviceID()); | ||
| 345 | -// } | ||
| 346 | -// } | ||
| 347 | -// String rootPath = userType == EnumSzBusinessType.EnumUserType.TEACHER.code ? "Teacher" : "Student" ; | ||
| 348 | -// //人脸路径 | ||
| 349 | -// String imagePath = filePath.replace("C:/imgCom", String.format("E:\\wwwhtdocs\\smartcampus\\face17e5\\School%s\\%s", schoolId, rootPath)); | ||
| 350 | -// //添加失败记录 | ||
| 351 | -// sendRecordDao.addFaceFail(customerId, deviceId, cardNum, userName,time,schoolName,imagePath,schoolId,failContent,failType,userType,deviceType); | ||
| 352 | -// } | ||
| 353 | -// | ||
| 354 | -// /** | ||
| 355 | -// * 保存成功记录 | ||
| 356 | -// */ | ||
| 357 | -// private void saveSendSuccessRecord(int schoolId,String schoolName,int userType,String userName,String filePath,String customerId, | ||
| 358 | -// String cardNum,String deviceId,int deviceType){ | ||
| 359 | -// //人脸下发成功记录, 先判断是否已经存在了 | ||
| 360 | -// List<SendRecordBean> sendRecordBeanList = sendRecordDao.getFaceSucceIsexit(deviceId, String.valueOf(schoolId),cardNum); | ||
| 361 | -// if (sendRecordBeanList.size() > 0) { | ||
| 362 | -// //删除重复数据 | ||
| 363 | -// for (SendRecordBean recordBean : sendRecordBeanList) { | ||
| 364 | -// sendRecordDao.deleteFaceSuccess(recordBean.getDeviceID(),recordBean.getNum()); | ||
| 365 | -// } | ||
| 366 | -// } | ||
| 367 | -// String time = DateFormatUtil.dateFormatString(new Date(),"yyyy-MM-dd HH:mm:ss"); | ||
| 368 | -// //重新添加人脸下发记录 | ||
| 369 | -// sendRecordDao.addFaceSuccess(customerId, deviceId, cardNum, userName, time, schoolName, filePath, schoolId, userType, deviceType); | ||
| 370 | -// | ||
| 371 | -// //删除之前失败记录 | ||
| 372 | -// sendRecordDao.deleteFaceFail(cardNum,deviceId); | ||
| 373 | -// } | ||
| 374 | -// | ||
| 375 | -// /** | ||
| 376 | -// * 解析权限模板、获取下发通道号 | ||
| 377 | -// * @param schoolId | ||
| 378 | -// * @param studentType | ||
| 379 | -// * @return | ||
| 380 | -// */ | ||
| 381 | -// private String analysisPermission(int schoolId, String studentType){ | ||
| 382 | -// List<PermissionFaceBean> permissionFaceBeans = permissFaceService.getPermissionList(schoolId); | ||
| 383 | -// String channel =""; | ||
| 384 | -// if(permissionFaceBeans.size()>0){ | ||
| 385 | -// for(PermissionFaceBean permissionFaceBean : permissionFaceBeans){ | ||
| 386 | -// String json = permissionFaceBean.getPermissionJson(); | ||
| 387 | -// PermissionBean permissionBean = objectMapper.fromJson(json,PermissionBean.class); | ||
| 388 | -// //学生考勤类型 1:通校生,2:住校生,3:全部 | ||
| 389 | -// String studentTypeStr = permissionBean.getStudentType(); | ||
| 390 | -// if(studentTypeStr.indexOf(studentType)!=-1){ | ||
| 391 | -// channel= permissionFaceBean.getChannel(); | ||
| 392 | -// } | ||
| 393 | -// } | ||
| 394 | -// if(StringUtils.isEmpty(channel)){ | ||
| 395 | -// log.warn("未获取到学校权限通道号!"); | ||
| 396 | -// return ""; | ||
| 397 | -// } | ||
| 398 | -// return channel; | ||
| 399 | -// } | ||
| 400 | -// return channel; | ||
| 401 | -// } | ||
| 402 | -// | ||
| 403 | -// /** | ||
| 404 | -// * 压缩图片 | ||
| 405 | -// * @param picSrc | ||
| 406 | -// * @param userId | ||
| 407 | -// * @return | ||
| 408 | -// */ | ||
| 409 | -// private String compressPic(String picSrc,String userId){ | ||
| 410 | -// //压缩后图片地址 | ||
| 411 | -// String targPath =""; | ||
| 412 | -// try{ | ||
| 413 | -// targPath = FilePath.picPathComp + userId + ".jpg"; | ||
| 414 | -// //压缩后的图片 | ||
| 415 | -// CompressPic.CompressPic(picSrc, targPath, userId); | ||
| 416 | -// return targPath; | ||
| 417 | -// } catch (Exception e) { | ||
| 418 | -// log.error("图片压缩失败,错误信息;{}",e); | ||
| 419 | -// } | ||
| 420 | -// return ""; | ||
| 421 | -// } | ||
| 422 | -// | ||
| 423 | -// public String cardNo(String cardDex) { | ||
| 424 | -// | ||
| 425 | -// String cardR = ""; | ||
| 426 | -// int length = cardDex.length(); | ||
| 427 | -// if (length != 8) { | ||
| 428 | -// System.out.println("卡号格式不正确:" + cardDex); | ||
| 429 | -// return cardDex; | ||
| 430 | -// } | ||
| 431 | -// while (length > 0) { | ||
| 432 | -// length -= 2; | ||
| 433 | -// cardR += cardDex.substring(length, length + 2); | ||
| 434 | -// } | ||
| 435 | -// | ||
| 436 | -// return cardR; | ||
| 437 | -// | ||
| 438 | -// } | ||
| 439 | -// | ||
| 440 | -// @Override | ||
| 441 | -// public void addFaceGroup(String file, int userType, String schoolId, String userId, String deviceId, String deviceType) { | ||
| 442 | -// String schoolName= userDao.getSchoolName(schoolId); | ||
| 443 | -// if(StringUtils.isEmpty(schoolName)){ | ||
| 444 | -// log.info("下发用户失败,学校ID: {},未查询到对应学校.",schoolId); | ||
| 445 | -// return; | ||
| 446 | -// } | ||
| 447 | -// //获取学生信息 | ||
| 448 | -// UserInfoBean userInfoBean = null; | ||
| 449 | -// if (userType == EnumSzBusinessType.EnumUserType.STUDENT.code) { | ||
| 450 | -// userInfoBean = userDao.getUserInfoByUserId(schoolId,userId); | ||
| 451 | -// if(null == userInfoBean){ | ||
| 452 | -// log.info("下发学生信息失败,学校ID: {},用户ID: {},未查询到对应学生.",schoolId,userId); | ||
| 453 | -// return; | ||
| 454 | -// } | ||
| 455 | -// } | ||
| 456 | -// //获取老师信息 | ||
| 457 | -// if (userType == EnumSzBusinessType.EnumUserType.TEACHER.code){ | ||
| 458 | -// TeacherBean teacher = userDao.getTeacherByUserId(schoolId,userId); | ||
| 459 | -// if (null == teacher) { | ||
| 460 | -// log.info("下发教师信息失败,学校ID: {},用户ID: {},未查询到对应教师.",schoolId,userId); | ||
| 461 | -// return; | ||
| 462 | -// } | ||
| 463 | -// userInfoBean.setStudent_num(teacher.getTeacher_num()); | ||
| 464 | -// userInfoBean.setName(teacher.getName()); | ||
| 465 | -// userInfoBean.setUser_id(teacher.getUser_id()); | ||
| 466 | -// userInfoBean.setStudentcode(teacher.getNum()); | ||
| 467 | -// userInfoBean.setStudent_id(teacher.getTeacher_id()); | ||
| 468 | -// userInfoBean.setSchool_id(teacher.getSchool_id()); | ||
| 469 | -// } | ||
| 470 | -// //如果未传指定设备ID,则获取学校下所有设备进行下发 | ||
| 471 | -// List<AttendanceBean> attendanceBeans = userService.getAttendanceBeans(schoolId, String.valueOf(deviceType), deviceId); | ||
| 472 | -// if(attendanceBeans.size()<1){ | ||
| 473 | -// log.info("下发用户信息失败,学校ID: {},设备类型:{},未查询到对应设备.",schoolId,deviceType); | ||
| 474 | -// return; | ||
| 475 | -// } | ||
| 476 | -// //下发用户 | ||
| 477 | -//// addUserFaceGroup(filePath,attendanceBeans,userInfoBean,userType,Integer.parseInt(deviceType),flag); | ||
| 478 | -// } | ||
| 479 | -// | ||
| 480 | -// | ||
| 481 | -//} | 1 | +package com.example.dahua.service.imp; | 
| 2 | + | ||
| 3 | +import com.example.dahua.bean.SendFaceDto; | ||
| 4 | +import com.example.dahua.bean.StudentBean; | ||
| 5 | +import com.example.dahua.dao.UserDao; | ||
| 6 | +import com.example.dahua.lib.CompressPic; | ||
| 7 | +import com.example.dahua.lib.FilePath; | ||
| 8 | +import com.example.dahua.service.UserOperateService; | ||
| 9 | +import com.example.dahua.utils.HttpUtils; | ||
| 10 | +import lombok.extern.slf4j.Slf4j; | ||
| 11 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 12 | +import org.springframework.stereotype.Service; | ||
| 13 | +import org.springframework.util.StringUtils; | ||
| 14 | + | ||
| 15 | +import java.io.File; | ||
| 16 | +import java.util.ArrayList; | ||
| 17 | +import java.util.Arrays; | ||
| 18 | +import java.util.List; | ||
| 19 | + | ||
| 20 | +/** | ||
| 21 | + * 下发用户信息、人脸、卡、权限接口实现类 | ||
| 22 | + * @author xuquan | ||
| 23 | + * @date 2020/12/1 11:12 | ||
| 24 | + */ | ||
| 25 | +@Slf4j | ||
| 26 | +@Service | ||
| 27 | +public class UserOperateServiceImpl implements UserOperateService { | ||
| 28 | + | ||
| 29 | + @Autowired | ||
| 30 | + private UserDao userDao; | ||
| 31 | + @Autowired | ||
| 32 | + private BaseService baseService; | ||
| 33 | + | ||
| 34 | + @Override | ||
| 35 | + public void sendUserFaces(SendFaceDto sendFaceDto) { | ||
| 36 | + Integer schoolId = sendFaceDto.getSchoolId(); | ||
| 37 | + Integer studentType = sendFaceDto.getStudentType(); | ||
| 38 | + Integer type = sendFaceDto.getType(); | ||
| 39 | + String sex = sendFaceDto.getSex(); | ||
| 40 | + //下发设备集合 | ||
| 41 | + String[] deviceArr = sendFaceDto.getsNos().split(","); | ||
| 42 | + List<String> deviceList= new ArrayList<>(Arrays.asList(deviceArr)); | ||
| 43 | + if(deviceList.size()<1){ | ||
| 44 | + log.error("未选择下发设备"); | ||
| 45 | + return; | ||
| 46 | + } | ||
| 47 | + Integer userType=null; | ||
| 48 | + //根据类型获取下发用户信息、文件名目录 | ||
| 49 | + String typeName=""; | ||
| 50 | + List<StudentBean> studentBeanList = null; | ||
| 51 | + if(type.intValue() == 0 || type.intValue()==1){ | ||
| 52 | + userType = 2; | ||
| 53 | + typeName= "Student"; | ||
| 54 | + studentBeanList = baseService.getStudentList(schoolId,studentType,sex); | ||
| 55 | + }else{ | ||
| 56 | + userType = 1; | ||
| 57 | + typeName= "Teacher"; | ||
| 58 | + studentBeanList = baseService.getTeacherList(schoolId); | ||
| 59 | + } | ||
| 60 | + for(StudentBean studentBean : studentBeanList){ | ||
| 61 | + try{ | ||
| 62 | + //100服务器文件目录绝对路径 | ||
| 63 | + String path = "E:\\wwwhtdocs\\SmartCampus\\face17e50\\School" + schoolId + "\\" + typeName; | ||
| 64 | + String photo= userType.intValue()==1?studentBean.getFace():studentBean.getPhoto(); | ||
| 65 | + //学籍号 | ||
| 66 | + String studentCode=userType.intValue()==1?studentBean.getNum():studentBean.getStudentcode(); | ||
| 67 | + if (StringUtils.isEmpty(photo) || StringUtils.isEmpty(studentCode)){ | ||
| 68 | + continue; | ||
| 69 | + } | ||
| 70 | + String filePath=""; | ||
| 71 | + if(photo.indexOf("f0i5l7e5")!=-1){ | ||
| 72 | + String afterStr = photo.split("f0i5l7e5/")[1].replace("/","\\"); | ||
| 73 | + filePath="E:\\wwwhtdocs\\SmartCampus\\f0i5l7e5\\" + afterStr; | ||
| 74 | + } else{ | ||
| 75 | + //以学籍号为名的文件名 | ||
| 76 | + String fileName = photo.split(typeName +"/")[1]; | ||
| 77 | + //100服务器上人脸照绝对路径 | ||
| 78 | + filePath = path+ "\\" + fileName; | ||
| 79 | + } | ||
| 80 | + log.info("学籍号:{},人脸路径:{}, ",studentCode,filePath); | ||
| 81 | + //100服务人脸照图片路径 | ||
| 82 | + File file = new File(filePath); | ||
| 83 | + if(file.exists()){ | ||
| 84 | + String targetPath = FilePath.picPathComp+ file.getName(); | ||
| 85 | + try { | ||
| 86 | + CompressPic.CompressPic(file.getAbsolutePath(), targetPath,""); | ||
| 87 | + } catch (Exception e) { | ||
| 88 | + log.error("压缩图片失败"); | ||
| 89 | + e.printStackTrace(); | ||
| 90 | + continue; | ||
| 91 | + } | ||
| 92 | + for(String sno : deviceList){ | ||
| 93 | + String clint_type = userDao.getClintType(sno); | ||
| 94 | + HttpUtils.uploadImgs(new File(targetPath), String.valueOf(schoolId), studentCode, clint_type, userType, sno); | ||
| 95 | + } | ||
| 96 | + } | ||
| 97 | + }catch (Exception e){ | ||
| 98 | + log.error("人脸下发失败"); | ||
| 99 | + e.printStackTrace(); | ||
| 100 | + continue; | ||
| 101 | + } | ||
| 102 | + } | ||
| 103 | + } | ||
| 104 | + | ||
| 105 | + public static void main(String[] args) { | ||
| 106 | + String photo = "http://campus.myjxt.com//f0i5l7e5/0/alluser/20210114/430f64e104ea4a7bb7f78f0e42b3fad8.jpg"; | ||
| 107 | + System.out.println(photo.indexOf("f0i5l7e5")!=-1); | ||
| 108 | + String path = photo.split("f0i5l7e5/")[1]; | ||
| 109 | + path= path.replace("/","\\"); | ||
| 110 | + System.out.println("E:\\wwwhtdocs\\SmartCampus\\f0i5l7e5\\"+path); | ||
| 111 | +// System.out.println(photo.split("f0i5l7e5/")[1]); | ||
| 112 | +// System.out.println(photo.split("f0i5l7e5/")[0]); | ||
| 113 | + } | ||
| 114 | + | ||
| 115 | +} | 
cloud/dahua/src/main/java/com/example/dahua/service/imp/UserServiceImp.java
| @@ -78,17 +78,15 @@ public class UserServiceImp implements UserService { | @@ -78,17 +78,15 @@ public class UserServiceImp implements UserService { | ||
| 78 | String[] studentInfo = studentCodes.split("_"); | 78 | String[] studentInfo = studentCodes.split("_"); | 
| 79 | 79 | ||
| 80 | if (studentInfo.length > 1) {//附属卡 | 80 | if (studentInfo.length > 1) {//附属卡 | 
| 81 | - | ||
| 82 | String studentCodeF = studentInfo[0]; | 81 | String studentCodeF = studentInfo[0]; | 
| 83 | String CardType = studentInfo[1]; | 82 | String CardType = studentInfo[1]; | 
| 84 | userInfoBean = getUserInfo(schoolId, studentCodeF); | 83 | userInfoBean = getUserInfo(schoolId, studentCodeF); | 
| 85 | - String cardNum = userDao.getCardNum(userInfoBean.getStudent_id(), CardType); | ||
| 86 | - userInfoBean.setStudent_num(cardNum); | ||
| 87 | - | 84 | + if(userInfoBean !=null){ | 
| 85 | + String cardNum = userDao.getCardNum(userInfoBean.getStudent_id(), CardType); | ||
| 86 | + userInfoBean.setStudent_num(cardNum); | ||
| 87 | + } | ||
| 88 | } else { | 88 | } else { | 
| 89 | - | ||
| 90 | userInfoBean = getUserInfo(schoolId, studentCode);//获取用户信息 | 89 | userInfoBean = getUserInfo(schoolId, studentCode);//获取用户信息 | 
| 91 | - | ||
| 92 | } | 90 | } | 
| 93 | } else if (userType == 1) { | 91 | } else if (userType == 1) { | 
| 94 | TeacherBean teacher = userDao.getTeacher(schoolId, studentCode); | 92 | TeacherBean teacher = userDao.getTeacher(schoolId, studentCode); | 
| @@ -104,10 +102,11 @@ public class UserServiceImp implements UserService { | @@ -104,10 +102,11 @@ public class UserServiceImp implements UserService { | ||
| 104 | //下发任务 | 102 | //下发任务 | 
| 105 | // myTask.doTaskOne(file, attendanceBeans, userInfoBean, schoolId, -1, userType); | 103 | // myTask.doTaskOne(file, attendanceBeans, userInfoBean, schoolId, -1, userType); | 
| 106 | sendUserInfoTask2.doTaskOne(file, attendanceBeans, userInfoBean, schoolId, -1, userType); | 104 | sendUserInfoTask2.doTaskOne(file, attendanceBeans, userInfoBean, schoolId, -1, userType); | 
| 105 | + return true; | ||
| 107 | } catch (Exception e) { | 106 | } catch (Exception e) { | 
| 108 | - e.printStackTrace(); | 107 | + log.info("方法:uploadImgAndUserInfo,执行时,发生异常",e); | 
| 109 | } | 108 | } | 
| 110 | - return true; | 109 | + return false; | 
| 111 | } | 110 | } | 
| 112 | 111 | ||
| 113 | /** | 112 | /** | 
cloud/dahua/src/main/java/com/example/dahua/utils/HttpUtils.java
| @@ -148,6 +148,13 @@ public class HttpUtils { | @@ -148,6 +148,13 @@ public class HttpUtils { | ||
| 148 | return result.getBody(); | 148 | return result.getBody(); | 
| 149 | } | 149 | } | 
| 150 | 150 | ||
| 151 | + public static void deleteFace(Integer schoolId) { | ||
| 152 | + String url = "http://121.40.109.21:8991/operate/deleteFailFace?schoolId=" + schoolId; | ||
| 153 | + RestTemplate restTemplate = new RestTemplate(); | ||
| 154 | + ResponseEntity<Boolean> result = restTemplate.getForEntity(url, Boolean.class); | ||
| 155 | + System.out.println("发生请求21服务删除人脸,请求地址: +" + url+ "返回信息: "+ result.getBody()); | ||
| 156 | + } | ||
| 157 | + | ||
| 151 | /** | 158 | /** | 
| 152 | * 权限下发至设备 | 159 | * 权限下发至设备 | 
| 153 | * @param permissionBean | 160 | * @param permissionBean | 
cloud/dahua/src/main/java/com/example/dahua/xiananDao/SendRecordDao.java
| @@ -99,5 +99,26 @@ public interface SendRecordDao { | @@ -99,5 +99,26 @@ public interface SendRecordDao { | ||
| 99 | @Select("select * from Face_SendSuccess where schoolId = #{schoolId} and userType = #{userType} and deviceId in ('G04F98PAJ164D7','6G04F8PAJ5CAA','6G04F98PAJ1E0DB','6G04F98PAJEE38C')") | 99 | @Select("select * from Face_SendSuccess where schoolId = #{schoolId} and userType = #{userType} and deviceId in ('G04F98PAJ164D7','6G04F8PAJ5CAA','6G04F98PAJ1E0DB','6G04F98PAJEE38C')") | 
| 100 | List<SendRecordBean> getFaceSuccessIsExitTest(@Param("schoolId") String schoolId,@Param("userType") int userType); | 100 | List<SendRecordBean> getFaceSuccessIsExitTest(@Param("schoolId") String schoolId,@Param("userType") int userType); | 
| 101 | 101 | ||
| 102 | + @Update("delete from Face_SendRecord where id = #{id}") | ||
| 103 | + void deleteRecord(@Param("id") Integer id); | ||
| 104 | + | ||
| 105 | + // ======================== 表 Face_SendRecord ======================== | ||
| 106 | + @Select("select * from Face_SendRecord where schoolId = #{schoolId} and deviceID = #{deviceID} and Num = #{Num} and userId = #{userId}") | ||
| 107 | + List<SendRecordBean> getRecordIsExit(@Param("schoolId") Integer schoolId,@Param("deviceID") String deviceId, @Param("Num") String card,@Param("userId") String userId); | ||
| 108 | + | ||
| 109 | + @Insert("insert into Face_SendRecord values(#{deviceID},#{userId},#{num},#{name},#{time},#{schoolName},#{imgPath},#{schoolId},#{failContent},#{failType},#{userType},#{deviceType},#{status})") | ||
| 110 | + void saveFaceRecord(@Param("userId") String userId, @Param("deviceID") String deviceID, @Param("num") String num, @Param("name") String name, | ||
| 111 | + @Param("time") String time, @Param("schoolName") String schoolName, @Param("imgPath") String imgPath, @Param("schoolId") Integer schoolId, @Param("failContent") String failContent, | ||
| 112 | + @Param("failType") Integer failType, @Param("userType") Integer userType, @Param("deviceType") Integer deviceType,Integer status); | ||
| 113 | + | ||
| 114 | + @Update("update Face_SendRecord set time = #{time},failContent = #{content},imgPath= #{faceUrl},status = 2 where deviceID = #{deviceID} and Num =#{Num} and userId = #{userId}") | ||
| 115 | + void updateFaceFailRecord(@Param("deviceID") String deviceId, @Param("faceUrl") String faceUrl,@Param("Num") String card, @Param("time") String time, @Param("content") String content,@Param("userId") String userId); | ||
| 116 | + | ||
| 117 | + @Update("update Face_SendRecord set time = #{time},imgPath= #{faceUrl},Name = #{Name},status = 1, failType=null, failContent = null where deviceID = #{deviceID} and Num = #{Num}") | ||
| 118 | + void updateFaceSuccessRecord(@Param("deviceID") String deviceId, @Param("Num") String card, @Param("time") String time, @Param("faceUrl") String faceUrl, @Param("Name") String name, @Param("userId") String userId); | ||
| 119 | + | ||
| 120 | + @Select("select * from Face_SendRecord where schoolId = #{schoolId} and status =2") | ||
| 121 | + List<SendRecordBean> getFailRecord(@Param("schoolId") Integer schoolId); | ||
| 122 | + | ||
| 102 | } | 123 | } | 
| 103 | 124 | 
cloud/dahua/src/main/resources/logback-spring.xml
| @@ -8,8 +8,8 @@ | @@ -8,8 +8,8 @@ | ||
| 8 | <!--<include resource="org/springframework/boot/logging/logback/defaults.xml" />--> | 8 | <!--<include resource="org/springframework/boot/logging/logback/defaults.xml" />--> | 
| 9 | 9 | ||
| 10 | <!--日志文件存储的基础路径: ${user.home} 为当前服务器用户主目录--> | 10 | <!--日志文件存储的基础路径: ${user.home} 为当前服务器用户主目录--> | 
| 11 | - <property name="LOG_PATH" value="E:/dahua-logs"/> | ||
| 12 | - | 11 | + <property name="LOG_PATH" value="D:/dahua-logs"/> | 
| 12 | + | ||
| 13 | <!--日志文件基础名称--> | 13 | <!--日志文件基础名称--> | 
| 14 | <property name="BASE_FILE_NAME" value="dahua"/> | 14 | <property name="BASE_FILE_NAME" value="dahua"/> | 
| 15 | <property name="LOG_FILE_MAX_SIZE" value="10MB"/> | 15 | <property name="LOG_FILE_MAX_SIZE" value="10MB"/> | 
cloud/dahua/src/main/resources/mapper/usermapper.xml
| @@ -9,15 +9,38 @@ | @@ -9,15 +9,38 @@ | ||
| 9 | <!--and studentcode = #{studentcode}--> | 9 | <!--and studentcode = #{studentcode}--> | 
| 10 | <!--</select>--> | 10 | <!--</select>--> | 
| 11 | 11 | ||
| 12 | - <select id="getStudentWiSidAndSex" resultType="java.lang.String"> | ||
| 13 | - | ||
| 14 | - select student_num from SZ_V_School_Student where school_id = #{schoolId} and sex in | ||
| 15 | - <foreach collection="sexs" item="sex" index="index" open="(" separator="," close=")"> | ||
| 16 | - #{sex} | ||
| 17 | - </foreach> | 12 | + <select id="getStudentList" resultType="com.example.dahua.bean.StudentBean"> | 
| 13 | + select * from SZ_V_School_Student where school_id = #{schoolId} | ||
| 14 | + <if test="studentType != null"> | ||
| 15 | + and student_type = #{studentType} | ||
| 16 | + </if> | ||
| 17 | + <if test="sex != null and sex.size() >0"> | ||
| 18 | + and sex in | ||
| 19 | + <foreach item="item" collection="sex" separator="," open="(" close=")" index=""> | ||
| 20 | + #{item} | ||
| 21 | + </foreach> | ||
| 22 | + </if> | ||
| 23 | + and (student_num is not null or student_num != '') and (photo is not null or photo !='') | ||
| 24 | + </select> | ||
| 18 | 25 | ||
| 26 | + <select id="getTeacherList" resultType="com.example.dahua.bean.StudentBean"> | ||
| 27 | + select * from SZ_V_School_Teacher where school_id = #{schoolId} | ||
| 28 | + and (teacher_num is not null or teacher_num !='') | ||
| 29 | + and (face is not null or face !='') | ||
| 19 | </select> | 30 | </select> | 
| 20 | 31 | ||
| 32 | + <select id="getAuthRecord" resultType="com.example.dahua.bean.DeviceAuthRecord"> | ||
| 33 | + select * from AC_DeviceAuthRecord where State = 1 and GrantState = 1 and SchoolId = #{schoolId} | ||
| 34 | + <if test="studentType != null"> | ||
| 35 | + and (StudentType = #{studentType} or StudentType =3) | ||
| 36 | + </if> | ||
| 37 | + </select> | ||
| 21 | 38 | ||
| 39 | + <select id="queryClintList" resultType="com.example.dahua.bean.AttendanceBean"> | ||
| 40 | + select * from SZ_Attendance where school_id = #{schoolId} and clint_type in(22,29) | ||
| 41 | + <if test="deviceId != null and deviceId.trim() !=''"> | ||
| 42 | + and clint_id = #{deviceId} | ||
| 43 | + </if> | ||
| 44 | + </select> | ||
| 22 | 45 | ||
| 23 | </mapper> | 46 | </mapper> | 
| 24 | \ No newline at end of file | 47 | \ No newline at end of file | 
cloud/dahua/src/test/java/com/example/dahua/mapper/SearchMapperTest.java
| @@ -145,4 +145,9 @@ public class SearchMapperTest extends Tester { | @@ -145,4 +145,9 @@ public class SearchMapperTest extends Tester { | ||
| 145 | String schoolId = "1485"; | 145 | String schoolId = "1485"; | 
| 146 | deleteBatchTest.test3(schoolId); | 146 | deleteBatchTest.test3(schoolId); | 
| 147 | } | 147 | } | 
| 148 | + | ||
| 149 | + @Test | ||
| 150 | + public void test9() { | ||
| 151 | + deleteBatchTest.test4(27,2,"1"); | ||
| 152 | + } | ||
| 148 | } | 153 | } | 
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; | ||
| 5 | import com.alibaba.fastjson.JSONObject; | 4 | import com.alibaba.fastjson.JSONObject; | 
| 6 | -import com.sincere.haikangface.bean.*; | 5 | +import com.sincere.haikangface.bean.AttendanceBean; | 
| 6 | +import com.sincere.haikangface.bean.StudentBean; | ||
| 7 | import com.sincere.haikangface.bean.xiaoan.Face_Recoder; | 7 | import com.sincere.haikangface.bean.xiaoan.Face_Recoder; | 
| 8 | import com.sincere.haikangface.dao.DeviceDao; | 8 | import com.sincere.haikangface.dao.DeviceDao; | 
| 9 | import com.sincere.haikangface.dao.UserDao; | 9 | import com.sincere.haikangface.dao.UserDao; | 
| 10 | -import com.sincere.haikangface.enums.EnumSzBusinessType; | ||
| 11 | import com.sincere.haikangface.haikanglibs.HCEHomeAlarm; | 10 | import com.sincere.haikangface.haikanglibs.HCEHomeAlarm; | 
| 12 | import com.sincere.haikangface.haikanglibs.HCEHomeCMS; | 11 | import com.sincere.haikangface.haikanglibs.HCEHomeCMS; | 
| 13 | import com.sincere.haikangface.haikanglibs.HCEHomeSS; | 12 | import com.sincere.haikangface.haikanglibs.HCEHomeSS; | 
| 14 | -import com.sincere.haikangface.mqtt.MqtUtils; | ||
| 15 | import com.sincere.haikangface.service.impl.BaseService; | 13 | import com.sincere.haikangface.service.impl.BaseService; | 
| 16 | -import com.sincere.haikangface.utils.*; | 14 | +import com.sincere.haikangface.utils.AlarmUtils; | 
| 15 | +import com.sincere.haikangface.utils.FileUtils; | ||
| 17 | import com.sincere.haikangface.xiananDao.SendRecordDao; | 16 | import com.sincere.haikangface.xiananDao.SendRecordDao; | 
| 18 | import com.sun.jna.NativeLong; | 17 | import com.sun.jna.NativeLong; | 
| 19 | import com.sun.jna.Pointer; | 18 | import com.sun.jna.Pointer; | 
| @@ -23,15 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired; | @@ -23,15 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired; | ||
| 23 | import org.springframework.beans.factory.annotation.Value; | 22 | import org.springframework.beans.factory.annotation.Value; | 
| 24 | import org.springframework.boot.ApplicationArguments; | 23 | import org.springframework.boot.ApplicationArguments; | 
| 25 | import org.springframework.boot.ApplicationRunner; | 24 | 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; | ||
| 30 | -import org.springframework.http.ResponseEntity; | ||
| 31 | -import org.springframework.scheduling.annotation.Scheduled; | ||
| 32 | import org.springframework.stereotype.Component; | 25 | import org.springframework.stereotype.Component; | 
| 33 | -import org.springframework.util.LinkedMultiValueMap; | ||
| 34 | -import org.springframework.util.MultiValueMap; | ||
| 35 | import org.springframework.util.StringUtils; | 26 | import org.springframework.util.StringUtils; | 
| 36 | import org.springframework.web.client.RestTemplate; | 27 | import org.springframework.web.client.RestTemplate; | 
| 37 | 28 | ||
| @@ -40,7 +31,10 @@ import java.net.InetAddress; | @@ -40,7 +31,10 @@ import java.net.InetAddress; | ||
| 40 | import java.net.UnknownHostException; | 31 | import java.net.UnknownHostException; | 
| 41 | import java.nio.ByteBuffer; | 32 | import java.nio.ByteBuffer; | 
| 42 | import java.text.SimpleDateFormat; | 33 | import java.text.SimpleDateFormat; | 
| 43 | -import java.util.*; | 34 | +import java.util.Date; | 
| 35 | +import java.util.HashMap; | ||
| 36 | +import java.util.List; | ||
| 37 | +import java.util.Map; | ||
| 44 | import java.util.regex.Pattern; | 38 | import java.util.regex.Pattern; | 
| 45 | 39 | ||
| 46 | @Component | 40 | @Component | 
| @@ -67,17 +61,19 @@ public class CMSServer implements ApplicationRunner { | @@ -67,17 +61,19 @@ public class CMSServer implements ApplicationRunner { | ||
| 67 | // 存储设备登录句柄 | 61 | // 存储设备登录句柄 | 
| 68 | static Map<String, NativeLong> map = new HashMap<>(); | 62 | static Map<String, NativeLong> map = new HashMap<>(); | 
| 69 | 63 | ||
| 64 | + public static String inTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); | ||
| 65 | + | ||
| 70 | //114.55.30.100 | 66 | //114.55.30.100 | 
| 71 | //120.26.116.253 | 67 | //120.26.116.253 | 
| 72 | // private String ip_cloud = "114.55.30.100"; | 68 | // private String ip_cloud = "114.55.30.100"; | 
| 73 | - private String ip_cloud = "172.16.2.166"; | 69 | + private String ip_cloud = "114.55.30.100"; | 
| 74 | 70 | ||
| 75 | private String ip; | 71 | private String ip; | 
| 76 | { | 72 | { | 
| 77 | try { | 73 | try { | 
| 78 | ip = InetAddress.getLocalHost().getHostAddress(); | 74 | ip = InetAddress.getLocalHost().getHostAddress(); | 
| 79 | } catch (UnknownHostException e) { | 75 | } catch (UnknownHostException e) { | 
| 80 | - e.printStackTrace(); | 76 | + log.error("获取主机IP异常,错误信息:{}",e); | 
| 81 | } | 77 | } | 
| 82 | } | 78 | } | 
| 83 | 79 | ||
| @@ -247,7 +243,7 @@ public class CMSServer implements ApplicationRunner { | @@ -247,7 +243,7 @@ public class CMSServer implements ApplicationRunner { | ||
| 247 | try { | 243 | try { | 
| 248 | deviceId = new String(strDevRegInfo.byDeviceID, "utf-8").trim(); | 244 | deviceId = new String(strDevRegInfo.byDeviceID, "utf-8").trim(); | 
| 249 | } catch (UnsupportedEncodingException e) { | 245 | } catch (UnsupportedEncodingException e) { | 
| 250 | - e.printStackTrace(); | 246 | + log.error("注册设备,设置设备ID异常,错误信息:{}",e); | 
| 251 | } | 247 | } | 
| 252 | pInBuffer.dwSize = pInBuffer.size(); | 248 | pInBuffer.dwSize = pInBuffer.size(); | 
| 253 | AttendanceBean attendanceBean = new AttendanceBean(); | 249 | AttendanceBean attendanceBean = new AttendanceBean(); | 
| @@ -262,7 +258,7 @@ public class CMSServer implements ApplicationRunner { | @@ -262,7 +258,7 @@ public class CMSServer implements ApplicationRunner { | ||
| 262 | attendanceBean.setSchool_id("-1"); | 258 | attendanceBean.setSchool_id("-1"); | 
| 263 | attendanceBean.setState(1); | 259 | attendanceBean.setState(1); | 
| 264 | if (deviceDao.selectDevice(deviceId) != null) { | 260 | if (deviceDao.selectDevice(deviceId) != null) { | 
| 265 | - deviceDao.updateDeviceStatu(1, deviceId); | 261 | + deviceDao.updateDeviceStatu(1,inTime,deviceId); | 
| 266 | } else { | 262 | } else { | 
| 267 | deviceDao.addDevide(attendanceBean.getClint_id(), attendanceBean.getClint_type(), attendanceBean.getIntime(), | 263 | deviceDao.addDevide(attendanceBean.getClint_id(), attendanceBean.getClint_type(), attendanceBean.getIntime(), | 
| 268 | attendanceBean.getSchool_id(), attendanceBean.getState() + "", attendanceBean.getIsConnection() + ""); | 264 | attendanceBean.getSchool_id(), attendanceBean.getState() + "", attendanceBean.getIsConnection() + ""); | 
| @@ -305,7 +301,6 @@ public class CMSServer implements ApplicationRunner { | @@ -305,7 +301,6 @@ public class CMSServer implements ApplicationRunner { | ||
| 305 | String szDevUri = new String(pTomcatMsg.szDevUri).trim(); | 301 | String szDevUri = new String(pTomcatMsg.szDevUri).trim(); | 
| 306 | int dwPicNum = pTomcatMsg.dwPicNum; | 302 | int dwPicNum = pTomcatMsg.dwPicNum; | 
| 307 | String pPicURLs = pTomcatMsg.pPicURLs; | 303 | String pPicURLs = pTomcatMsg.pPicURLs; | 
| 308 | -// System.out.println("szDevUri = " + szDevUri + " dwPicNum= " + dwPicNum + " pPicURLs=" + pPicURLs); | ||
| 309 | } else if (2 == enumType) { | 304 | } else if (2 == enumType) { | 
| 310 | // int type = pInBuffer.dwAlarmServerType; | 305 | // int type = pInBuffer.dwAlarmServerType; | 
| 311 | // int picServerType = pInBuffer.dwPicServerType; | 306 | // int picServerType = pInBuffer.dwPicServerType; | 
| @@ -339,7 +334,7 @@ public class CMSServer implements ApplicationRunner { | @@ -339,7 +334,7 @@ public class CMSServer implements ApplicationRunner { | ||
| 339 | try { | 334 | try { | 
| 340 | strFilePathFile.createNewFile(); | 335 | strFilePathFile.createNewFile(); | 
| 341 | } catch (IOException e) { | 336 | } catch (IOException e) { | 
| 342 | - e.printStackTrace(); | 337 | + log.error("处理人脸机抓拍文件异常,错误信息:{}",e); | 
| 343 | } | 338 | } | 
| 344 | } | 339 | } | 
| 345 | if (dwFileLen > 0 && pFileBuf != null) { | 340 | if (dwFileLen > 0 && pFileBuf != null) { | 
| @@ -366,9 +361,9 @@ public class CMSServer implements ApplicationRunner { | @@ -366,9 +361,9 @@ public class CMSServer implements ApplicationRunner { | ||
| 366 | baseService.sendUserInfoToKB(strFilePathFile, deviceId); | 361 | baseService.sendUserInfoToKB(strFilePathFile, deviceId); | 
| 367 | } | 362 | } | 
| 368 | } catch (FileNotFoundException e) { | 363 | } catch (FileNotFoundException e) { | 
| 369 | - e.printStackTrace(); | 364 | + log.error("处理人脸机抓拍文件异常,错误信息:{}",e); | 
| 370 | } catch (IOException e) { | 365 | } catch (IOException e) { | 
| 371 | - e.printStackTrace(); | 366 | + log.error("处理人脸机抓拍文件异常,错误信息:{}",e); | 
| 372 | } | 367 | } | 
| 373 | } | 368 | } | 
| 374 | 369 | ||
| @@ -397,30 +392,36 @@ public class CMSServer implements ApplicationRunner { | @@ -397,30 +392,36 @@ public class CMSServer implements ApplicationRunner { | ||
| 397 | strXMLData.read(); | 392 | strXMLData.read(); | 
| 398 | String strXML = new String(strXMLData.byValue); | 393 | String strXML = new String(strXMLData.byValue); | 
| 399 | if (null == alarmUtils) { | 394 | if (null == alarmUtils) { | 
| 395 | + log.info("初始化报警工具类"); | ||
| 400 | alarmUtils = new AlarmUtils(deviceDao, userDao); | 396 | alarmUtils = new AlarmUtils(deviceDao, userDao); | 
| 401 | alarmUtils.setCallBack(new AlarmUtils.AlarmCallBack() { | 397 | alarmUtils.setCallBack(new AlarmUtils.AlarmCallBack() { | 
| 402 | @Override | 398 | @Override | 
| 403 | public void callBack(String minorType, String deviceID, String cardNo, String time, String picDataUrlId, String currTemperature) { | 399 | public void callBack(String minorType, String deviceID, String cardNo, String time, String picDataUrlId, String currTemperature) { | 
| 404 | switch (minorType) { | 400 | switch (minorType) { | 
| 405 | case "0x4b"://人脸认证通过 | 401 | case "0x4b"://人脸认证通过 | 
| 402 | + log.info("人脸验证通过,事件次类型:"+minorType); | ||
| 406 | saveFaceRecoder(deviceID, cardNo, time, picDataUrlId, currTemperature); | 403 | saveFaceRecoder(deviceID, cardNo, time, picDataUrlId, currTemperature); | 
| 407 | break; | 404 | break; | 
| 408 | case "0x426"://人证设备在线 | 405 | case "0x426"://人证设备在线 | 
| 409 | break; | 406 | break; | 
| 410 | case "0x427"://人证设备离线 | 407 | case "0x427"://人证设备离线 | 
| 408 | + log.info("设备掉线了,设备ID: "+deviceID); | ||
| 411 | map.remove(deviceID); | 409 | map.remove(deviceID); | 
| 412 | - deviceDao.updateDeviceStatu(0, deviceID); | 410 | + deviceDao.updateDeviceStatu(0,inTime,deviceID); | 
| 413 | break; | 411 | break; | 
| 414 | case "0x69"://人证比对通过 | 412 | case "0x69"://人证比对通过 | 
| 413 | + log.info("人证比对通过,事件次类型:"+minorType); | ||
| 415 | saveFaceRecoder(deviceID, cardNo, time, picDataUrlId, currTemperature); | 414 | saveFaceRecoder(deviceID, cardNo, time, picDataUrlId, currTemperature); | 
| 416 | break; | 415 | break; | 
| 417 | case "0x6": | 416 | case "0x6": | 
| 417 | + log.info("通过,事件次类型:"+minorType); | ||
| 418 | saveFaceRecoder(deviceID, cardNo, time, picDataUrlId, currTemperature); | 418 | saveFaceRecoder(deviceID, cardNo, time, picDataUrlId, currTemperature); | 
| 419 | break; | 419 | break; | 
| 420 | } | 420 | } | 
| 421 | } | 421 | } | 
| 422 | }); | 422 | }); | 
| 423 | } else { | 423 | } else { | 
| 424 | + log.info("处理报警进来了"); | ||
| 424 | //处理报警事件 | 425 | //处理报警事件 | 
| 425 | alarmUtils.deleAlarm(strXML); | 426 | alarmUtils.deleAlarm(strXML); | 
| 426 | } | 427 | } | 
| @@ -447,6 +448,7 @@ public class CMSServer implements ApplicationRunner { | @@ -447,6 +448,7 @@ public class CMSServer implements ApplicationRunner { | ||
| 447 | try { | 448 | try { | 
| 448 | if (!StringUtils.isEmpty(cardNo) && isNumeric(cardNo)) { | 449 | if (!StringUtils.isEmpty(cardNo) && isNumeric(cardNo)) { | 
| 449 | Face_Recoder face_recoder = new Face_Recoder(); | 450 | Face_Recoder face_recoder = new Face_Recoder(); | 
| 451 | + //十进制卡转十六进制卡 | ||
| 450 | String card = splicingZero(Long.toHexString(Long.parseLong(cardNo)), 8).toUpperCase(); | 452 | String card = splicingZero(Long.toHexString(Long.parseLong(cardNo)), 8).toUpperCase(); | 
| 451 | //卡号逆转 | 453 | //卡号逆转 | 
| 452 | cardNo = baseService.getCard(card); | 454 | cardNo = baseService.getCard(card); | 
| @@ -486,7 +488,6 @@ public class CMSServer implements ApplicationRunner { | @@ -486,7 +488,6 @@ public class CMSServer implements ApplicationRunner { | ||
| 486 | 488 | ||
| 487 | public void isTeacher(String cardNo, String deviceID) { | 489 | public void isTeacher(String cardNo, String deviceID) { | 
| 488 | List<String> devLists = userDao.getDeviceRoomRelation(deviceID); | 490 | List<String> devLists = userDao.getDeviceRoomRelation(deviceID); | 
| 489 | -// log.error("cardNo:{},devLists{}", cardNo, devLists); | ||
| 490 | if (null != devLists && devLists.size() > 0) { | 491 | if (null != devLists && devLists.size() > 0) { | 
| 491 | 492 | ||
| 492 | StudentBean teacher = userDao.getTeacherWithCard(cardNo); | 493 | StudentBean teacher = userDao.getTeacherWithCard(cardNo); | 
| @@ -509,7 +510,8 @@ public class CMSServer implements ApplicationRunner { | @@ -509,7 +510,8 @@ public class CMSServer implements ApplicationRunner { | ||
| 509 | * @param deviceId | 510 | * @param deviceId | 
| 510 | * @return | 511 | * @return | 
| 511 | */ | 512 | */ | 
| 512 | - public boolean createImgPath(String srcFile, String picUrl, String card, String startTime, String endTime, int validTimeEnabled, String name, String deviceId, String userType, String employeeNo,Integer schoolId) { | 513 | + public boolean createImgPath(String srcFile, String picUrl, String card, String startTime, String endTime, int validTimeEnabled, String name, String deviceId, String userType, String employeeNo,Integer schoolId,String cardNum) { | 
| 514 | + log.info("下发卡号:"+card); | ||
| 513 | if (map.containsKey(deviceId)) { | 515 | if (map.containsKey(deviceId)) { | 
| 514 | HCEHomeSS.NET_EHOME_SS_CLIENT_PARAM pClientParam = new HCEHomeSS.NET_EHOME_SS_CLIENT_PARAM(); | 516 | HCEHomeSS.NET_EHOME_SS_CLIENT_PARAM pClientParam = new HCEHomeSS.NET_EHOME_SS_CLIENT_PARAM(); | 
| 515 | pClientParam.enumType = HCEHomeSS.NET_EHOME_SS_CLIENT_TYPE_KMS; | 517 | pClientParam.enumType = HCEHomeSS.NET_EHOME_SS_CLIENT_TYPE_KMS; | 
| @@ -548,11 +550,11 @@ public class CMSServer implements ApplicationRunner { | @@ -548,11 +550,11 @@ public class CMSServer implements ApplicationRunner { | ||
| 548 | /** | 550 | /** | 
| 549 | * 下发用户信息 | 551 | * 下发用户信息 | 
| 550 | */ | 552 | */ | 
| 551 | - return sendInfo(srcFile, url, card, startTime, endTime, validTimeEnabled, name, deviceId, userType, employeeNo, schoolId); | 553 | + return sendInfo(srcFile, url, card, startTime, endTime, validTimeEnabled, name, deviceId, userType, employeeNo, schoolId,cardNum); | 
| 552 | } | 554 | } | 
| 553 | - if(schoolId !=null && (schoolId.intValue() == 4 || | ||
| 554 | - schoolId.intValue() == 27|| schoolId.intValue() == 2 || schoolId.intValue() == 16)){ | ||
| 555 | - baseService.sendFailRecord(card, srcFile, deviceId,"设备不在线", userType); | 555 | + if(schoolId !=null && (schoolId.intValue() == 4 || schoolId.intValue() == 27 || schoolId.intValue() == 864 || | 
| 556 | + schoolId.intValue() == 2 || schoolId.intValue() == 16)){ | ||
| 557 | + baseService.sendFailRecord(cardNum, srcFile, deviceId,"设备不在线", userType); | ||
| 556 | }else{ | 558 | }else{ | 
| 557 | baseService.sendFail(card, srcFile, deviceId,"设备不在线", userType); | 559 | baseService.sendFail(card, srcFile, deviceId,"设备不在线", userType); | 
| 558 | } | 560 | } | 
| @@ -564,7 +566,7 @@ public class CMSServer implements ApplicationRunner { | @@ -564,7 +566,7 @@ public class CMSServer implements ApplicationRunner { | ||
| 564 | * | 566 | * | 
| 565 | * @Param picUrl 原图 | 567 | * @Param picUrl 原图 | 
| 566 | */ | 568 | */ | 
| 567 | - public boolean sendInfo(String srcFile, String url, String card, String startTime, String endTime, int validTimeEnabled, String name, String deviceId, String userType, String employeeNo,Integer schoolId) { | 569 | + public boolean sendInfo(String srcFile, String url, String card, String startTime, String endTime, int validTimeEnabled, String name, String deviceId, String userType, String employeeNo,Integer schoolId,String cardNum) { | 
| 568 | // deleteCard(deviceId, card); | 570 | // deleteCard(deviceId, card); | 
| 569 | // editCard(startTime, endTime, 0, name, card, deviceId, employeeNo); | 571 | // editCard(startTime, endTime, 0, name, card, deviceId, employeeNo); | 
| 570 | editCard(startTime, endTime, validTimeEnabled, name, card, deviceId, employeeNo); | 572 | editCard(startTime, endTime, validTimeEnabled, name, card, deviceId, employeeNo); | 
| @@ -579,7 +581,7 @@ public class CMSServer implements ApplicationRunner { | @@ -579,7 +581,7 @@ public class CMSServer implements ApplicationRunner { | ||
| 579 | "</SetFaceParamCfg>"; | 581 | "</SetFaceParamCfg>"; | 
| 580 | //开始下发人脸 | 582 | //开始下发人脸 | 
| 581 | 583 | ||
| 582 | - return editFace(srcFile, url, card, strRequest, strConfigXML, "下发人脸", deviceId, EnumSzBusinessType.EnumHkOperateType.ADD.code, userType,schoolId); | 584 | + return editFace(srcFile, url, card, strRequest, strConfigXML, "下发人脸", deviceId, validTimeEnabled, userType,schoolId,cardNum); | 
| 583 | } | 585 | } | 
| 584 | 586 | ||
| 585 | /** | 587 | /** | 
| @@ -653,7 +655,7 @@ public class CMSServer implements ApplicationRunner { | @@ -653,7 +655,7 @@ public class CMSServer implements ApplicationRunner { | ||
| 653 | 655 | ||
| 654 | System.arraycopy(nameAfterBy, 0, resultBy, nameBeforBy.length + nameBy.length, nameAfterBy.length); | 656 | System.arraycopy(nameAfterBy, 0, resultBy, nameBeforBy.length + nameBy.length, nameAfterBy.length); | 
| 655 | } catch (UnsupportedEncodingException e) { | 657 | } catch (UnsupportedEncodingException e) { | 
| 656 | - e.printStackTrace(); | 658 | + log.error("编码异常:异常信息:{}",e); | 
| 657 | } | 659 | } | 
| 658 | 660 | ||
| 659 | struConfigXMLCard.byString = resultBy; | 661 | struConfigXMLCard.byString = resultBy; | 
| @@ -701,7 +703,7 @@ public class CMSServer implements ApplicationRunner { | @@ -701,7 +703,7 @@ public class CMSServer implements ApplicationRunner { | ||
| 701 | * | 703 | * | 
| 702 | * @param clint_id | 704 | * @param clint_id | 
| 703 | */ | 705 | */ | 
| 704 | - public void SetCardWeekPlan(String clint_id, String card, String userType, String strConfigXMLCard, String content,Integer schoolId) { | 706 | + public void SetCardWeekPlan(String clint_id, String card, String userType, String strConfigXMLCard, String content,Integer schoolId,String cardNum) { | 
| 705 | try { | 707 | try { | 
| 706 | 708 | ||
| 707 | HCEHomeCMS.NET_EHOME_XML_CFG struXMLCard = new HCEHomeCMS.NET_EHOME_XML_CFG(); | 709 | HCEHomeCMS.NET_EHOME_XML_CFG struXMLCard = new HCEHomeCMS.NET_EHOME_XML_CFG(); | 
| @@ -745,7 +747,7 @@ public class CMSServer implements ApplicationRunner { | @@ -745,7 +747,7 @@ public class CMSServer implements ApplicationRunner { | ||
| 745 | log.error(content + "失败:" + iErr); | 747 | log.error(content + "失败:" + iErr); | 
| 746 | if(schoolId !=null && (schoolId.intValue() == 4 || | 748 | if(schoolId !=null && (schoolId.intValue() == 4 || | 
| 747 | schoolId.intValue() == 27 || schoolId.intValue() == 2 || schoolId.intValue() == 16)){ | 749 | schoolId.intValue() == 27 || schoolId.intValue() == 2 || schoolId.intValue() == 16)){ | 
| 748 | - baseService.sendFailRecord(card,"",clint_id,content + "失败:" + iErr, userType); | 750 | + baseService.sendFailRecord(cardNum,"",clint_id,content + "失败:" + iErr, userType); | 
| 749 | }else{ | 751 | }else{ | 
| 750 | baseService.sendFail(card,"",clint_id,content + "失败:" + iErr, userType); | 752 | baseService.sendFail(card,"",clint_id,content + "失败:" + iErr, userType); | 
| 751 | } | 753 | } | 
| @@ -753,7 +755,7 @@ public class CMSServer implements ApplicationRunner { | @@ -753,7 +755,7 @@ public class CMSServer implements ApplicationRunner { | ||
| 753 | log.info(content + "成功"); | 755 | log.info(content + "成功"); | 
| 754 | } | 756 | } | 
| 755 | } catch (Exception e) { | 757 | } catch (Exception e) { | 
| 756 | - e.printStackTrace(); | 758 | + log.error("设置卡权限周计划异常:异常信息:{}",e); | 
| 757 | } | 759 | } | 
| 758 | } | 760 | } | 
| 759 | 761 | ||
| @@ -769,7 +771,7 @@ public class CMSServer implements ApplicationRunner { | @@ -769,7 +771,7 @@ public class CMSServer implements ApplicationRunner { | ||
| 769 | String strConfigXML = "<DelFaceParamCfg>" + | 771 | String strConfigXML = "<DelFaceParamCfg>" + | 
| 770 | "<cardNo>" + card + "</cardNo><cardReaderNo>1</cardReaderNo>" + | 772 | "<cardNo>" + card + "</cardNo><cardReaderNo>1</cardReaderNo>" + | 
| 771 | "<faceID>1</faceID></DelFaceParamCfg>"; | 773 | "<faceID>1</faceID></DelFaceParamCfg>"; | 
| 772 | - return editFace("", "", card, strRequest, strConfigXML, "删除人脸", deviceId, 2, "",schoolId); | 774 | + return editFace("", "", card, strRequest, strConfigXML, "删除人脸", deviceId, 2, "",schoolId,""); | 
| 773 | } | 775 | } | 
| 774 | 776 | ||
| 775 | /** | 777 | /** | 
| @@ -784,10 +786,10 @@ public class CMSServer implements ApplicationRunner { | @@ -784,10 +786,10 @@ public class CMSServer implements ApplicationRunner { | ||
| 784 | String strConfigXML = "<GetFaceParamCfgCond version=\"2.0\" xmlns=\"http://www.isapi.org/ver20/XMLSchema\">" + | 786 | String strConfigXML = "<GetFaceParamCfgCond version=\"2.0\" xmlns=\"http://www.isapi.org/ver20/XMLSchema\">" + | 
| 785 | "<cardNo>" + card + "</cardNo><cardReaderNo>1</cardReaderNo>" + | 787 | "<cardNo>" + card + "</cardNo><cardReaderNo>1</cardReaderNo>" + | 
| 786 | "<faceID>1</faceID></GetFaceParamCfgCond>"; | 788 | "<faceID>1</faceID></GetFaceParamCfgCond>"; | 
| 787 | - return editFace("", "", card, strRequest, strConfigXML, "获取人脸信息", deviceId, 3, "",schoolId); | 789 | + return editFace("", "", card, strRequest, strConfigXML, "获取人脸信息", deviceId, 3, "",schoolId,""); | 
| 788 | } | 790 | } | 
| 789 | 791 | ||
| 790 | - private boolean editFace(String srcFile, String faceUrl, String card, String strRequest, String strConfigXML, String content, String deviceId, int type, String userType,Integer schoolId) { | 792 | + private boolean editFace(String srcFile, String faceUrl, String card, String strRequest, String strConfigXML, String content, String deviceId, int type, String userType,Integer schoolId,String cardNum) { | 
| 791 | 793 | ||
| 792 | // deleteCard(deviceId, card); | 794 | // deleteCard(deviceId, card); | 
| 793 | // lLoginID = map.get(deviceId); | 795 | // lLoginID = map.get(deviceId); | 
| @@ -818,24 +820,24 @@ public class CMSServer implements ApplicationRunner { | @@ -818,24 +820,24 @@ public class CMSServer implements ApplicationRunner { | ||
| 818 | if (type == 1) {//下发人脸 | 820 | if (type == 1) {//下发人脸 | 
| 819 | if (!hCEhomeCMS.NET_ECMS_PostPTXMLConfig(map.get(deviceId), struISAPXML)) { | 821 | if (!hCEhomeCMS.NET_ECMS_PostPTXMLConfig(map.get(deviceId), struISAPXML)) { | 
| 820 | int iErr = hCEhomeCMS.NET_ECMS_GetLastError(); | 822 | int iErr = hCEhomeCMS.NET_ECMS_GetLastError(); | 
| 821 | - System.err.println(content + "失败,错误号:" + iErr + "---" + strConfigXML + "\n"); | ||
| 822 | - if(schoolId !=null && (schoolId.intValue() == 4 || | ||
| 823 | - schoolId.intValue() == 27 || schoolId.intValue() == 2 || schoolId.intValue() == 16)){ | ||
| 824 | - baseService.sendFailRecord(card,"",deviceId,content + "失败:" + iErr, userType); | 823 | + log.error(content + "失败,错误号:" + iErr + "---" + strConfigXML + "\n"); | 
| 824 | + if(schoolId !=null && (schoolId.intValue() == 4 || schoolId.intValue() == 27 || schoolId.intValue() == 864 || | ||
| 825 | + schoolId.intValue() == 2 || schoolId.intValue() == 16)){ | ||
| 826 | + baseService.sendFailRecord(cardNum,"",deviceId,content + "失败,错误号:" + iErr, userType); | ||
| 825 | }else{ | 827 | }else{ | 
| 826 | - baseService.sendFail(card,"",deviceId,content + "失败:" + iErr, userType); | 828 | + baseService.sendFail(card,"",deviceId,content + "失败,错误号:" + iErr, userType); | 
| 827 | } | 829 | } | 
| 828 | // sendRecoderUtils.sendFailRecord(sendRecordDao, card, srcFile, deviceId, userDao, content + "失败,错误号:" + iErr, userType); | 830 | // sendRecoderUtils.sendFailRecord(sendRecordDao, card, srcFile, deviceId, userDao, content + "失败,错误号:" + iErr, userType); | 
| 829 | } else { | 831 | } else { | 
| 830 | stringXMLOut.read(); | 832 | stringXMLOut.read(); | 
| 831 | String strOutXML = new String(stringXMLOut.byString).trim(); | 833 | String strOutXML = new String(stringXMLOut.byString).trim(); | 
| 832 | - if(schoolId !=null && (schoolId.intValue() == 4 || | ||
| 833 | - schoolId.intValue() == 27 || schoolId.intValue() == 2 || schoolId.intValue() == 16)){ | ||
| 834 | - baseService.sendSuccessRecord(card,faceUrl, deviceId,userType); | 834 | + if(schoolId !=null && (schoolId.intValue() == 4 || schoolId.intValue() == 27 || schoolId.intValue() == 864 || | 
| 835 | + schoolId.intValue() == 2 || schoolId.intValue() == 16)){ | ||
| 836 | + baseService.sendSuccessRecord(cardNum,faceUrl, deviceId,userType); | ||
| 835 | }else{ | 837 | }else{ | 
| 836 | baseService.sendSuccess(card,faceUrl, deviceId,userType); | 838 | baseService.sendSuccess(card,faceUrl, deviceId,userType); | 
| 837 | } | 839 | } | 
| 838 | - log.info(content + "成功:" + card); | 840 | + log.info(content + "成功: 下发卡号:" + card); | 
| 839 | } | 841 | } | 
| 840 | } else if (type == 2) {//删除人脸 | 842 | } else if (type == 2) {//删除人脸 | 
| 841 | if (!hCEhomeCMS.NET_ECMS_PutPTXMLConfig(map.get(deviceId), struISAPXML)) { | 843 | if (!hCEhomeCMS.NET_ECMS_PutPTXMLConfig(map.get(deviceId), struISAPXML)) { | 
cloud/haikangface/src/main/java/com/sincere/haikangface/HaikangfaceApplication.java
| @@ -11,11 +11,13 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerA | @@ -11,11 +11,13 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerA | ||
| 11 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; | 11 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; | 
| 12 | import org.springframework.cloud.openfeign.EnableFeignClients; | 12 | import org.springframework.cloud.openfeign.EnableFeignClients; | 
| 13 | import org.springframework.context.annotation.ComponentScan; | 13 | import org.springframework.context.annotation.ComponentScan; | 
| 14 | +import org.springframework.scheduling.annotation.EnableAsync; | ||
| 14 | 15 | ||
| 15 | @EnableAutoConfiguration(exclude = {DataSourceAutoConfiguration.class, DataSourceTransactionManagerAutoConfiguration.class, MybatisAutoConfiguration.class}) | 16 | @EnableAutoConfiguration(exclude = {DataSourceAutoConfiguration.class, DataSourceTransactionManagerAutoConfiguration.class, MybatisAutoConfiguration.class}) | 
| 16 | @SpringBootApplication | 17 | @SpringBootApplication | 
| 17 | @EnableDiscoveryClient | 18 | @EnableDiscoveryClient | 
| 18 | @EnableFeignClients(basePackages = "com.sincere.haikangface.fegin") | 19 | @EnableFeignClients(basePackages = "com.sincere.haikangface.fegin") | 
| 20 | +//@EnableAsync | ||
| 19 | public class HaikangfaceApplication { | 21 | public class HaikangfaceApplication { | 
| 20 | 22 | ||
| 21 | public static void main(String[] args) { | 23 | public static void main(String[] args) { | 
cloud/haikangface/src/main/java/com/sincere/haikangface/async/SendFaceBatchTask100.java
0 → 100644
| @@ -0,0 +1,110 @@ | @@ -0,0 +1,110 @@ | ||
| 1 | +package com.sincere.haikangface.async; | ||
| 2 | + | ||
| 3 | +import com.sincere.haikangface.bean.StudentBean; | ||
| 4 | +import com.sincere.haikangface.enums.EnumSzBusinessType; | ||
| 5 | +import com.sincere.haikangface.service.impl.BaseService; | ||
| 6 | +import com.sincere.haikangface.utils.CompressPic; | ||
| 7 | +import com.sincere.haikangface.utils.FileUtils; | ||
| 8 | +import lombok.extern.slf4j.Slf4j; | ||
| 9 | +import org.apache.commons.lang3.StringUtils; | ||
| 10 | + | ||
| 11 | +import java.io.File; | ||
| 12 | +import java.text.SimpleDateFormat; | ||
| 13 | +import java.util.Calendar; | ||
| 14 | +import java.util.Date; | ||
| 15 | +import java.util.List; | ||
| 16 | +import java.util.concurrent.CountDownLatch; | ||
| 17 | + | ||
| 18 | +/** | ||
| 19 | + * 多线程执行卡下发 | ||
| 20 | + * @author xuquan | ||
| 21 | + * @date 2021/01/12 15:56 | ||
| 22 | + */ | ||
| 23 | +@Slf4j | ||
| 24 | +public class SendFaceBatchTask100 implements Runnable { | ||
| 25 | + | ||
| 26 | + private String schoolId; | ||
| 27 | + private String userType; | ||
| 28 | + private List<StudentBean> students; | ||
| 29 | + private String sno; | ||
| 30 | + private FileUtils fileUtils; | ||
| 31 | + private SendUserAsync sendUserAsync; | ||
| 32 | + private BaseService baseService; | ||
| 33 | + CountDownLatch begin; | ||
| 34 | + CountDownLatch end; | ||
| 35 | + | ||
| 36 | + public SendFaceBatchTask100(String schoolId, String userType,String sno,List<StudentBean> students,BaseService baseService, | ||
| 37 | + FileUtils fileUtils,SendUserAsync sendUserAsync, CountDownLatch begin, CountDownLatch end){ | ||
| 38 | + this.userType=userType; | ||
| 39 | + this.schoolId=schoolId; | ||
| 40 | + this.students=students; | ||
| 41 | + this.sno=sno; | ||
| 42 | + this.fileUtils=fileUtils; | ||
| 43 | + this.sendUserAsync=sendUserAsync; | ||
| 44 | + this.baseService=baseService; | ||
| 45 | + this.begin=begin; | ||
| 46 | + this.end=end; | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + @Override | ||
| 50 | + public void run() { | ||
| 51 | + try { | ||
| 52 | + begin.await(); | ||
| 53 | + String startTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); | ||
| 54 | + Calendar calendar = Calendar.getInstance(); | ||
| 55 | + calendar.add(Calendar.YEAR, 10); | ||
| 56 | + String endTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(calendar.getTime()); | ||
| 57 | + //下发标识:详情见枚举 EnumHkOperateType | ||
| 58 | + int validTimeEnabled = EnumSzBusinessType.EnumHkOperateType.ADD.code; | ||
| 59 | + for(StudentBean studentBean : students){ | ||
| 60 | + try{ | ||
| 61 | + String photo= studentBean.getPhoto(); | ||
| 62 | + if (StringUtils.isBlank(photo)){ | ||
| 63 | + continue; | ||
| 64 | + } | ||
| 65 | + String userName= studentBean.getName(); | ||
| 66 | + String cardNum =""; | ||
| 67 | + String typeName=""; | ||
| 68 | + if(userType.equals("1")){ | ||
| 69 | + cardNum = studentBean.getTeacher_num(); | ||
| 70 | + typeName= "Teacher"; | ||
| 71 | + }else { | ||
| 72 | + cardNum = studentBean.getStudent_num(); | ||
| 73 | + typeName= "Student"; | ||
| 74 | + } | ||
| 75 | + String path = "E:\\wwwhtdocs\\SmartCampus\\face17e50\\School" + schoolId + "\\" + typeName; | ||
| 76 | + log.info("人脸路径:"+photo); | ||
| 77 | + //以学籍号为名的文件名 | ||
| 78 | + String fileName = photo.split(typeName +"/")[1]; | ||
| 79 | + //100服务器上人脸照绝对路径 | ||
| 80 | + String filePath = path+ "\\" + fileName; | ||
| 81 | + File file = new File(filePath);//图片 | ||
| 82 | + if(file.exists()){ | ||
| 83 | + String targetPath = fileUtils.picPathComp + file.getName(); | ||
| 84 | + log.info("文件名:"+fileName); | ||
| 85 | + try { | ||
| 86 | + CompressPic.CompressPic(file.getAbsolutePath(), targetPath); | ||
| 87 | + } catch (Exception e) { | ||
| 88 | + log.error("压缩图片失败"); | ||
| 89 | + e.printStackTrace(); | ||
| 90 | + continue; | ||
| 91 | + } | ||
| 92 | + String cardNumLong = Long.parseLong(baseService.getCard(cardNum), 16) + ""; | ||
| 93 | + //下发100海康设备 | ||
| 94 | + sendUserAsync.sendStuToHaiKang(file.getAbsolutePath(),targetPath,cardNumLong, startTime, endTime, validTimeEnabled, userName, sno, userType,Integer.parseInt(schoolId),cardNum); | ||
| 95 | + } | ||
| 96 | + }catch (Exception e){ | ||
| 97 | + log.error("人脸下发失败"); | ||
| 98 | + e.printStackTrace(); | ||
| 99 | + continue; | ||
| 100 | + } | ||
| 101 | + } | ||
| 102 | + }catch (Exception e){ | ||
| 103 | + log.error("下发人脸异常,信息:"); | ||
| 104 | + e.printStackTrace(); | ||
| 105 | + }finally { | ||
| 106 | + end.countDown(); | ||
| 107 | + } | ||
| 108 | + } | ||
| 109 | + | ||
| 110 | +} | 
cloud/haikangface/src/main/java/com/sincere/haikangface/async/SendFaceBatchTask253.java
0 → 100644
| @@ -0,0 +1,89 @@ | @@ -0,0 +1,89 @@ | ||
| 1 | +package com.sincere.haikangface.async; | ||
| 2 | + | ||
| 3 | +import com.sincere.haikangface.bean.StudentBean; | ||
| 4 | +import com.sincere.haikangface.enums.EnumSzBusinessType; | ||
| 5 | +import lombok.extern.slf4j.Slf4j; | ||
| 6 | +import org.apache.commons.lang3.StringUtils; | ||
| 7 | + | ||
| 8 | +import java.text.SimpleDateFormat; | ||
| 9 | +import java.util.Calendar; | ||
| 10 | +import java.util.Date; | ||
| 11 | +import java.util.List; | ||
| 12 | +import java.util.concurrent.CountDownLatch; | ||
| 13 | + | ||
| 14 | +/** | ||
| 15 | + * 多线程执行卡下发 | ||
| 16 | + * @author xuquan | ||
| 17 | + * @date 2021/01/12 15:56 | ||
| 18 | + */ | ||
| 19 | +@Slf4j | ||
| 20 | +public class SendFaceBatchTask253 implements Runnable { | ||
| 21 | + | ||
| 22 | + private String schoolId; | ||
| 23 | + private String userType; | ||
| 24 | + private List<StudentBean> students; | ||
| 25 | + private String sno; | ||
| 26 | + private SendUserAsync sendUserAsync; | ||
| 27 | + CountDownLatch begin; | ||
| 28 | + CountDownLatch end; | ||
| 29 | + | ||
| 30 | + public SendFaceBatchTask253(String schoolId, String userType,String sno,List<StudentBean> students, | ||
| 31 | + SendUserAsync sendUserAsync, CountDownLatch begin, CountDownLatch end){ | ||
| 32 | + this.userType=userType; | ||
| 33 | + this.schoolId=schoolId; | ||
| 34 | + this.students=students; | ||
| 35 | + this.sno=sno; | ||
| 36 | + this.sendUserAsync=sendUserAsync; | ||
| 37 | + this.begin=begin; | ||
| 38 | + this.end=end; | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + @Override | ||
| 42 | + public void run() { | ||
| 43 | + try { | ||
| 44 | + begin.await(); | ||
| 45 | + String startTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); | ||
| 46 | + Calendar calendar = Calendar.getInstance(); | ||
| 47 | + calendar.add(Calendar.YEAR, 10); | ||
| 48 | + String endTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(calendar.getTime()); | ||
| 49 | + //下发标识:详情见枚举 EnumHkOperateType | ||
| 50 | + int validTimeEnabled = EnumSzBusinessType.EnumHkOperateType.ADD.code; | ||
| 51 | + for(StudentBean studentBean : students){ | ||
| 52 | + try{ | ||
| 53 | + String photo= studentBean.getPhoto(); | ||
| 54 | + if (StringUtils.isBlank(photo)){ | ||
| 55 | + continue; | ||
| 56 | + } | ||
| 57 | + String userName= studentBean.getName(); | ||
| 58 | + String cardNum =""; | ||
| 59 | + String typeName=""; | ||
| 60 | + if(userType.equals("1")){ | ||
| 61 | + cardNum = studentBean.getTeacher_num(); | ||
| 62 | + typeName= "Teacher"; | ||
| 63 | + }else { | ||
| 64 | + cardNum = studentBean.getStudent_num(); | ||
| 65 | + typeName= "Student"; | ||
| 66 | + } | ||
| 67 | + String path = "E:\\wwwhtdocs\\SmartCampus\\face17e50\\School" + schoolId + "\\" + typeName; | ||
| 68 | + //以学籍号为名的文件名 | ||
| 69 | + String fileName = photo.split(typeName+"/")[1]; | ||
| 70 | + //100服务器上人脸照绝对路径 | ||
| 71 | + String filePath = path+ "\\" + fileName; | ||
| 72 | + Thread.sleep(1000); | ||
| 73 | + //下发253服务器 | ||
| 74 | + sendUserAsync.uploadImgs(filePath, cardNum, userName, sno, startTime, endTime, validTimeEnabled, userType); | ||
| 75 | + }catch (Exception e){ | ||
| 76 | + log.error("人脸下发失败"); | ||
| 77 | + e.printStackTrace(); | ||
| 78 | + continue; | ||
| 79 | + } | ||
| 80 | + } | ||
| 81 | + }catch (Exception e){ | ||
| 82 | + log.error("下发人脸异常,信息:"); | ||
| 83 | + e.printStackTrace(); | ||
| 84 | + }finally { | ||
| 85 | + end.countDown(); | ||
| 86 | + } | ||
| 87 | + } | ||
| 88 | + | ||
| 89 | +} | 
cloud/haikangface/src/main/java/com/sincere/haikangface/async/SendUserAsync.java
| @@ -12,17 +12,21 @@ import com.sincere.haikangface.dao.DeviceDao; | @@ -12,17 +12,21 @@ import com.sincere.haikangface.dao.DeviceDao; | ||
| 12 | import com.sincere.haikangface.dao.UserDao; | 12 | import com.sincere.haikangface.dao.UserDao; | 
| 13 | import com.sincere.haikangface.enums.EnumSzBusinessType; | 13 | import com.sincere.haikangface.enums.EnumSzBusinessType; | 
| 14 | import com.sincere.haikangface.service.impl.BaseService; | 14 | import com.sincere.haikangface.service.impl.BaseService; | 
| 15 | -import com.sincere.haikangface.utils.*; | 15 | +import com.sincere.haikangface.utils.FileUtils; | 
| 16 | +import com.sincere.haikangface.utils.HKXmlUtils; | ||
| 17 | +import com.sincere.haikangface.utils.HttpUtil; | ||
| 18 | +import com.sincere.haikangface.utils.SendRecoderUtils; | ||
| 16 | import com.sincere.haikangface.xiananDao.SendRecordDao; | 19 | import com.sincere.haikangface.xiananDao.SendRecordDao; | 
| 17 | import lombok.extern.slf4j.Slf4j; | 20 | import lombok.extern.slf4j.Slf4j; | 
| 18 | import org.springframework.beans.factory.annotation.Autowired; | 21 | import org.springframework.beans.factory.annotation.Autowired; | 
| 19 | -import org.springframework.http.ResponseEntity; | ||
| 20 | import org.springframework.scheduling.annotation.Async; | 22 | import org.springframework.scheduling.annotation.Async; | 
| 21 | import org.springframework.stereotype.Component; | 23 | import org.springframework.stereotype.Component; | 
| 22 | import org.springframework.util.StringUtils; | 24 | import org.springframework.util.StringUtils; | 
| 23 | -import org.springframework.web.client.RestTemplate; | ||
| 24 | 25 | ||
| 25 | -import java.util.*; | 26 | +import java.util.ArrayList; | 
| 27 | +import java.util.HashMap; | ||
| 28 | +import java.util.List; | ||
| 29 | +import java.util.Map; | ||
| 26 | 30 | ||
| 27 | @Component | 31 | @Component | 
| 28 | @Slf4j | 32 | @Slf4j | 
| @@ -59,14 +63,14 @@ public class SendUserAsync { | @@ -59,14 +63,14 @@ public class SendUserAsync { | ||
| 59 | * @param deviceId | 63 | * @param deviceId | 
| 60 | * @param userType | 64 | * @param userType | 
| 61 | */ | 65 | */ | 
| 62 | - public void sendStuToHaiKang(String srcFile, String picUrl, String card, String startTime, String endTime, int validTimeEnabled, String name, String deviceId, String userType,Integer schoolId) { | 66 | + public void sendStuToHaiKang(String srcFile, String picUrl, String card, String startTime, String endTime, int validTimeEnabled, String name, String deviceId, String userType,Integer schoolId,String cardNum) { | 
| 63 | //1、检测图片是否合格 | 67 | //1、检测图片是否合格 | 
| 64 | boolean check = true; | 68 | boolean check = true; | 
| 65 | if (check) {//合格 | 69 | if (check) {//合格 | 
| 66 | //根据设备是5603 还是新设备 | 70 | //根据设备是5603 还是新设备 | 
| 67 | String employeeNo = ""; | 71 | String employeeNo = ""; | 
| 68 | //picUrl:压缩后的图片路径,图片上传,用户信息、用户卡下发。 | 72 | //picUrl:压缩后的图片路径,图片上传,用户信息、用户卡下发。 | 
| 69 | - cmsServer.createImgPath(srcFile, picUrl, card, startTime, endTime, validTimeEnabled, name, deviceId, userType, employeeNo,schoolId); | 73 | + cmsServer.createImgPath(srcFile, picUrl, card, startTime, endTime, validTimeEnabled, name, deviceId, userType, employeeNo,schoolId,cardNum); | 
| 70 | //根据设备 | 74 | //根据设备 | 
| 71 | if (deviceId.contains("ymzx") || deviceId.contains("5607") || deviceId.contains("5671") || deviceId.contains("5604")) { | 75 | if (deviceId.contains("ymzx") || deviceId.contains("5607") || deviceId.contains("5671") || deviceId.contains("5604")) { | 
| 72 | long lon = Long.parseLong(card); | 76 | long lon = Long.parseLong(card); | 
| @@ -94,18 +98,18 @@ public class SendUserAsync { | @@ -94,18 +98,18 @@ public class SendUserAsync { | ||
| 94 | } | 98 | } | 
| 95 | } | 99 | } | 
| 96 | //设置卡权限计划模板 | 100 | //设置卡权限计划模板 | 
| 97 | - cmsServer.SetCardWeekPlan(deviceId, card, userType, HKXmlUtils.getInstance().SetCardTemplate(), "设置卡权限计划模板",schoolId); | 101 | + cmsServer.SetCardWeekPlan(deviceId, card, userType, HKXmlUtils.getInstance().SetCardTemplate(), "设置卡权限计划模板",schoolId,cardNum); | 
| 98 | //设置卡权限周计划 | 102 | //设置卡权限周计划 | 
| 99 | - cmsServer.SetCardWeekPlan(deviceId, card, userType, HKXmlUtils.getInstance().SetCardWeekPlan(), "卡权限周计划" ,schoolId); | 103 | + cmsServer.SetCardWeekPlan(deviceId, card, userType, HKXmlUtils.getInstance().SetCardWeekPlan(), "卡权限周计划" ,schoolId,cardNum); | 
| 100 | for (int i = 0; i < 7; i++) { | 104 | for (int i = 0; i < 7; i++) { | 
| 101 | - cmsServer.SetCardWeekPlan(deviceId, card, userType, HKXmlUtils.getInstance().SetCardWeekPlanTime(HKXmlUtils.getInstance().SetCardWeekPlanTimes("00:00:00", "23:00:00"), "" + i), "设置卡权限周计划时间",schoolId); | 105 | + cmsServer.SetCardWeekPlan(deviceId, card, userType, HKXmlUtils.getInstance().SetCardWeekPlanTime(HKXmlUtils.getInstance().SetCardWeekPlanTimes("00:00:00", "23:00:00"), "" + i), "设置卡权限周计划时间",schoolId,cardNum); | 
| 102 | } | 106 | } | 
| 103 | - cmsServer.SetCardWeekPlan(deviceId, card, userType, HKXmlUtils.getInstance().SetCardRightCfg(card), "设置卡权限",schoolId); | 107 | + cmsServer.SetCardWeekPlan(deviceId, card, userType, HKXmlUtils.getInstance().SetCardRightCfg(card), "设置卡权限",schoolId,cardNum); | 
| 104 | } | 108 | } | 
| 105 | } else {//不合格 | 109 | } else {//不合格 | 
| 106 | - if(schoolId !=null && (schoolId.intValue() == 4 || | ||
| 107 | - schoolId.intValue() == 27 || schoolId.intValue() == 2 || schoolId.intValue() == 16)){ | ||
| 108 | - baseService.sendFailRecord(card, srcFile, deviceId, "人脸照片不合格", userType); | 110 | + if(schoolId !=null && (schoolId.intValue() == 4 || schoolId.intValue() == 27 || schoolId.intValue() == 864 || | 
| 111 | + schoolId.intValue() == 2 || schoolId.intValue() == 16)){ | ||
| 112 | + baseService.sendFailRecord(cardNum, srcFile, deviceId, "人脸照片不合格", userType); | ||
| 109 | }else{ | 113 | }else{ | 
| 110 | baseService.sendFail(card, srcFile, deviceId, "人脸照片不合格", userType); | 114 | baseService.sendFail(card, srcFile, deviceId, "人脸照片不合格", userType); | 
| 111 | } | 115 | } | 
| @@ -154,8 +158,7 @@ public class SendUserAsync { | @@ -154,8 +158,7 @@ public class SendUserAsync { | ||
| 154 | log.info("map{}", JSON.toJSONString(map)); | 158 | log.info("map{}", JSON.toJSONString(map)); | 
| 155 | return true; | 159 | return true; | 
| 156 | }catch (Exception e){ | 160 | }catch (Exception e){ | 
| 157 | - e.printStackTrace(); | ||
| 158 | - log.error("下发权限失败"); | 161 | + log.error("下发卡权限失败,异常信息:{}",e); | 
| 159 | } | 162 | } | 
| 160 | return false; | 163 | return false; | 
| 161 | } | 164 | } | 
| @@ -190,8 +193,7 @@ public class SendUserAsync { | @@ -190,8 +193,7 @@ public class SendUserAsync { | ||
| 190 | cardNumList.addAll(cardList); | 193 | cardNumList.addAll(cardList); | 
| 191 | } | 194 | } | 
| 192 | if (Integer.parseInt(userType) == EnumSzBusinessType.EnumUserType.STUDENT.code) { | 195 | if (Integer.parseInt(userType) == EnumSzBusinessType.EnumUserType.STUDENT.code) { | 
| 193 | -// cardNumList = getCards(sex, userType, schoolId); | ||
| 194 | - cardNumList = getStudentCard(Integer.parseInt(schoolId),studentType,sex); | 196 | + cardNumList = baseService.getStudentCard(Integer.parseInt(schoolId),studentType,sex); | 
| 195 | } | 197 | } | 
| 196 | //整理周和时间段 | 198 | //整理周和时间段 | 
| 197 | initWeedayAndTimes(weekDay, map); | 199 | initWeedayAndTimes(weekDay, map); | 
| @@ -203,8 +205,7 @@ public class SendUserAsync { | @@ -203,8 +205,7 @@ public class SendUserAsync { | ||
| 203 | userDao.updateAuthRecord(id,1); | 205 | userDao.updateAuthRecord(id,1); | 
| 204 | return true; | 206 | return true; | 
| 205 | }catch (Exception e){ | 207 | }catch (Exception e){ | 
| 206 | - e.printStackTrace(); | ||
| 207 | - log.error("下发权限失败"); | 208 | + log.error("下发卡权限失败,异常信息:{}",e); | 
| 208 | } | 209 | } | 
| 209 | return false; | 210 | return false; | 
| 210 | } | 211 | } | 
| @@ -229,7 +230,7 @@ public class SendUserAsync { | @@ -229,7 +230,7 @@ public class SendUserAsync { | ||
| 229 | } | 230 | } | 
| 230 | 231 | ||
| 231 | } catch (Exception e) { | 232 | } catch (Exception e) { | 
| 232 | - e.printStackTrace(); | 233 | + log.error("获取用户卡异常,异常信息:{}",e); | 
| 233 | } | 234 | } | 
| 234 | return cards; | 235 | return cards; | 
| 235 | } | 236 | } | 
| @@ -268,8 +269,8 @@ public class SendUserAsync { | @@ -268,8 +269,8 @@ public class SendUserAsync { | ||
| 268 | } | 269 | } | 
| 269 | cardNum = Long.parseLong(newCardNum, 16) + ""; | 270 | cardNum = Long.parseLong(newCardNum, 16) + ""; | 
| 270 | 271 | ||
| 271 | - cmsServer.SetCardWeekPlan(deviceId, cardNum, userType, HKXmlUtils.getInstance().SetCardTemplate(), "设置卡权限计划模板",schoolId); | ||
| 272 | - cmsServer.SetCardWeekPlan(deviceId, cardNum, userType, HKXmlUtils.getInstance().SetCardWeekPlan(), "卡权限周计划",schoolId); | 272 | + cmsServer.SetCardWeekPlan(deviceId, cardNum, userType, HKXmlUtils.getInstance().SetCardTemplate(), "设置卡权限计划模板",schoolId,cardNum); | 
| 273 | + cmsServer.SetCardWeekPlan(deviceId, cardNum, userType, HKXmlUtils.getInstance().SetCardWeekPlan(), "卡权限周计划",schoolId,cardNum); | ||
| 273 | 274 | ||
| 274 | for (Map.Entry<Integer, List<WeekTime>> weeKdayMap : map.entrySet()) { | 275 | for (Map.Entry<Integer, List<WeekTime>> weeKdayMap : map.entrySet()) { | 
| 275 | 276 | ||
| @@ -285,20 +286,19 @@ public class SendUserAsync { | @@ -285,20 +286,19 @@ public class SendUserAsync { | ||
| 285 | String weekPlanTime = HKXmlUtils.getInstance().SetCardWeekPlanTime(stringBuffer.toString(), "" + week); | 286 | String weekPlanTime = HKXmlUtils.getInstance().SetCardWeekPlanTime(stringBuffer.toString(), "" + week); | 
| 286 | String serCardRightCfg = HKXmlUtils.getInstance().SetCardRightCfg(cardNum); | 287 | String serCardRightCfg = HKXmlUtils.getInstance().SetCardRightCfg(cardNum); | 
| 287 | FileUtils.getInstance().writeLogs(weekPlanTime, "设置卡权限周计划时间.txt"); | 288 | FileUtils.getInstance().writeLogs(weekPlanTime, "设置卡权限周计划时间.txt"); | 
| 288 | - cmsServer.SetCardWeekPlan(deviceId, cardNum, userType, weekPlanTime, "设置卡权限周计划时间",schoolId); | ||
| 289 | - cmsServer.SetCardWeekPlan(deviceId, cardNum, userType, serCardRightCfg, "设置卡权限",schoolId); | 289 | + cmsServer.SetCardWeekPlan(deviceId, cardNum, userType, weekPlanTime, "设置卡权限周计划时间",schoolId,cardNum); | 
| 290 | + cmsServer.SetCardWeekPlan(deviceId, cardNum, userType, serCardRightCfg, "设置卡权限",schoolId,cardNum); | ||
| 290 | } | 291 | } | 
| 291 | } | 292 | } | 
| 292 | } | 293 | } | 
| 293 | - } else {//设备不在线 | 294 | + } else {//设备不在线,请求253服务器执行下发 | 
| 294 | if (i == 0) HttpUtil.sendPermission2HK(permissionBean); | 295 | if (i == 0) HttpUtil.sendPermission2HK(permissionBean); | 
| 295 | log.error("deviceId:{}", deviceId + "不在线"); | 296 | log.error("deviceId:{}", deviceId + "不在线"); | 
| 296 | } | 297 | } | 
| 297 | } | 298 | } | 
| 298 | return true; | 299 | return true; | 
| 299 | }catch (Exception e){ | 300 | }catch (Exception e){ | 
| 300 | - log.error("下发失败,错误信息{}",e); | ||
| 301 | - e.printStackTrace(); | 301 | + log.error("下发卡权限失败,异常信息{}",e); | 
| 302 | } | 302 | } | 
| 303 | return false; | 303 | return false; | 
| 304 | } | 304 | } | 
| @@ -320,14 +320,7 @@ public class SendUserAsync { | @@ -320,14 +320,7 @@ public class SendUserAsync { | ||
| 320 | return cardList; | 320 | return cardList; | 
| 321 | } | 321 | } | 
| 322 | 322 | ||
| 323 | - public List<String> getStudentCard(int schoolId, int studentType, String sex) { | ||
| 324 | - String[] msg = sex.split(","); | ||
| 325 | - List<Integer> list = new ArrayList<>(); | ||
| 326 | - for(String s : msg){ | ||
| 327 | - list.add(Integer.valueOf(s)); | ||
| 328 | - } | ||
| 329 | - return userDao.getStudentCard(schoolId,studentType, list); | ||
| 330 | - } | 323 | + | 
| 331 | 324 | ||
| 332 | 325 | ||
| 333 | private void initWeedayAndTimes(WeekDay weekDay, Map<Integer, List<WeekTime>> map) { | 326 | private void initWeedayAndTimes(WeekDay weekDay, Map<Integer, List<WeekTime>> map) { | 
| @@ -393,32 +386,4 @@ public class SendUserAsync { | @@ -393,32 +386,4 @@ public class SendUserAsync { | ||
| 393 | public boolean IsDeviceOnline(String deviceId) { | 386 | public boolean IsDeviceOnline(String deviceId) { | 
| 394 | return HttpUtil.IsDeviceOnline(deviceId); | 387 | return HttpUtil.IsDeviceOnline(deviceId); | 
| 395 | } | 388 | } | 
| 396 | - | ||
| 397 | - @Async | ||
| 398 | - public void uploadHkImg( String schoolId,int userType,String deviceIds) { | ||
| 399 | - String api = "http://114.55.30.100:8089/facereco/sendFaces"; | ||
| 400 | - try { | ||
| 401 | - String url = String.format(api +"?schoolId=%s&userType=%s&deviceIds=%s",schoolId,userType,deviceIds); | ||
| 402 | - RestTemplate restTemplate = new RestTemplate(); | ||
| 403 | - ResponseEntity<String> responseEntity = restTemplate.getForEntity(url, String.class); | ||
| 404 | - log.info("请求成功:responseEntity:" + responseEntity.getBody()); | ||
| 405 | - } catch (Exception e) { | ||
| 406 | - e.printStackTrace(); | ||
| 407 | - } | ||
| 408 | - | ||
| 409 | - } | ||
| 410 | - | ||
| 411 | - @Async | ||
| 412 | - public void uploadDHImg( String schoolId,int userType,String deviceIds) { | ||
| 413 | - String api = "http://114.55.30.100:8991/user/sendFaces"; | ||
| 414 | - try { | ||
| 415 | - String url = String.format(api +"?schoolId=%s&userType=%s&deviceIds=%s",schoolId,userType,deviceIds); | ||
| 416 | - RestTemplate restTemplate = new RestTemplate(); | ||
| 417 | - ResponseEntity<String> responseEntity = restTemplate.getForEntity(url, String.class); | ||
| 418 | - log.info("请求成功:responseEntity:" + responseEntity.getBody()); | ||
| 419 | - } catch (Exception e) { | ||
| 420 | - e.printStackTrace(); | ||
| 421 | - } | ||
| 422 | - } | ||
| 423 | - | ||
| 424 | } | 389 | } | 
cloud/haikangface/src/main/java/com/sincere/haikangface/bean/face/AuthRecordDto.java
| @@ -15,13 +15,13 @@ public class AuthRecordDto { | @@ -15,13 +15,13 @@ public class AuthRecordDto { | ||
| 15 | 15 | ||
| 16 | @ApiModelProperty("权限表ID") | 16 | @ApiModelProperty("权限表ID") | 
| 17 | private Integer id ; | 17 | private Integer id ; | 
| 18 | - @ApiModelProperty("1 学生类型 2 学生组") | 18 | + @ApiModelProperty("1学生类型 2 学生组") | 
| 19 | private Integer type ; | 19 | private Integer type ; | 
| 20 | @ApiModelProperty("学校ID") | 20 | @ApiModelProperty("学校ID") | 
| 21 | private Integer schoolId ; | 21 | private Integer schoolId ; | 
| 22 | - @ApiModelProperty("设备号,逗号隔开") | 22 | + @ApiModelProperty("设备号集合") | 
| 23 | private List<String> snList; | 23 | private List<String> snList; | 
| 24 | - @ApiModelProperty("学生类型,1通校2住校") | 24 | + @ApiModelProperty("学生类型,1通校2住校;群组时,为群组号") | 
| 25 | private Integer studentType ; | 25 | private Integer studentType ; | 
| 26 | @ApiModelProperty("权限周计划列表") | 26 | @ApiModelProperty("权限周计划列表") | 
| 27 | private List<WeekDay> weekDays ; | 27 | private List<WeekDay> weekDays ; | 
cloud/haikangface/src/main/java/com/sincere/haikangface/bean/face/PermissionDHBean.java
0 → 100644
| @@ -0,0 +1,63 @@ | @@ -0,0 +1,63 @@ | ||
| 1 | +package com.sincere.haikangface.bean.face; | ||
| 2 | + | ||
| 3 | +import io.swagger.annotations.ApiModelProperty; | ||
| 4 | + | ||
| 5 | +import java.io.Serializable; | ||
| 6 | +import java.util.List; | ||
| 7 | + | ||
| 8 | +public class PermissionDHBean implements Serializable { | ||
| 9 | + | ||
| 10 | + @ApiModelProperty(value = "设备id",required = true) | ||
| 11 | + private List<String> deviceIds; | ||
| 12 | + | ||
| 13 | + private List<WeekDay> weekDays; | ||
| 14 | + | ||
| 15 | + @ApiModelProperty("用逗号隔开,1:通校生,2:住校生,3:全部") | ||
| 16 | + private String studentType; | ||
| 17 | + | ||
| 18 | + @ApiModelProperty("权限通道号") | ||
| 19 | + private String channel; | ||
| 20 | + | ||
| 21 | + @ApiModelProperty("权限自定义名成") | ||
| 22 | + private String customName; | ||
| 23 | + | ||
| 24 | + public String getStudentType() { | ||
| 25 | + return studentType; | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | + public void setStudentType(String studentType) { | ||
| 29 | + this.studentType = studentType; | ||
| 30 | + } | ||
| 31 | + | ||
| 32 | + public List<String> getDeviceIds() { | ||
| 33 | + return deviceIds; | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + public void setDeviceIds(List<String> deviceIds) { | ||
| 37 | + this.deviceIds = deviceIds; | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | + public List<WeekDay> getWeekDays() { | ||
| 41 | + return weekDays; | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | + public void setWeekDays(List<WeekDay> weekDays) { | ||
| 45 | + this.weekDays = weekDays; | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + public String getChannel() { | ||
| 49 | + return channel; | ||
| 50 | + } | ||
| 51 | + | ||
| 52 | + public void setChannel(String channel) { | ||
| 53 | + this.channel = channel; | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + public String getCustomName() { | ||
| 57 | + return customName; | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + public void setCustomName(String customName) { | ||
| 61 | + this.customName = customName; | ||
| 62 | + } | ||
| 63 | +} | 
cloud/haikangface/src/main/java/com/sincere/haikangface/bean/face/SendFaceDto.java
0 → 100644
| @@ -0,0 +1,66 @@ | @@ -0,0 +1,66 @@ | ||
| 1 | +package com.sincere.haikangface.bean.face; | ||
| 2 | + | ||
| 3 | +import io.swagger.annotations.ApiModel; | ||
| 4 | +import io.swagger.annotations.ApiModelProperty; | ||
| 5 | + | ||
| 6 | +import java.util.List; | ||
| 7 | + | ||
| 8 | +/** | ||
| 9 | + * 照片下发人脸实体类 | ||
| 10 | + * @author xuquan | ||
| 11 | + * @date 2020/12/16 09:10 | ||
| 12 | + */ | ||
| 13 | +@ApiModel | ||
| 14 | +public class SendFaceDto { | ||
| 15 | + | ||
| 16 | + @ApiModelProperty("0主卡1教师卡2副卡") | ||
| 17 | + private Integer type ; | ||
| 18 | + @ApiModelProperty("学校ID") | ||
| 19 | + private Integer schoolId ; | ||
| 20 | + @ApiModelProperty("设备号,逗号隔开") | ||
| 21 | + private String sNos; | ||
| 22 | + @ApiModelProperty("学生类型,1通校2住校;群组时,为群组号") | ||
| 23 | + private Integer studentType; | ||
| 24 | + @ApiModelProperty("性别:1男2女,多个逗号隔开") | ||
| 25 | + private String sex; | ||
| 26 | + | ||
| 27 | + public Integer getType() { | ||
| 28 | + return type; | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + public void setType(Integer type) { | ||
| 32 | + this.type = type; | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | + public Integer getSchoolId() { | ||
| 36 | + return schoolId; | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + public void setSchoolId(Integer schoolId) { | ||
| 40 | + this.schoolId = schoolId; | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + public String getsNos() { | ||
| 44 | + return sNos; | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + public void setsNos(String sNos) { | ||
| 48 | + this.sNos = sNos; | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + public Integer getStudentType() { | ||
| 52 | + return studentType; | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + public void setStudentType(Integer studentType) { | ||
| 56 | + this.studentType = studentType; | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + public String getSex() { | ||
| 60 | + return sex; | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + public void setSex(String sex) { | ||
| 64 | + this.sex = sex; | ||
| 65 | + } | ||
| 66 | +} | 
cloud/haikangface/src/main/java/com/sincere/haikangface/control/FileControl.java
| @@ -3,21 +3,16 @@ package com.sincere.haikangface.control; | @@ -3,21 +3,16 @@ package com.sincere.haikangface.control; | ||
| 3 | import com.alibaba.fastjson.JSON; | 3 | import com.alibaba.fastjson.JSON; | 
| 4 | import com.sincere.haikangface.CMSServer; | 4 | import com.sincere.haikangface.CMSServer; | 
| 5 | import com.sincere.haikangface.async.SendUserAsync; | 5 | import com.sincere.haikangface.async.SendUserAsync; | 
| 6 | -import com.sincere.haikangface.bean.Images2Ddevices; | ||
| 7 | import com.sincere.haikangface.bean.StudentBean; | 6 | import com.sincere.haikangface.bean.StudentBean; | 
| 8 | -import com.sincere.haikangface.bean.UploadBean; | ||
| 9 | import com.sincere.haikangface.bean.face.PermissionBean; | 7 | import com.sincere.haikangface.bean.face.PermissionBean; | 
| 10 | import com.sincere.haikangface.dao.UserDao; | 8 | import com.sincere.haikangface.dao.UserDao; | 
| 11 | import com.sincere.haikangface.service.impl.BaseService; | 9 | import com.sincere.haikangface.service.impl.BaseService; | 
| 12 | import com.sincere.haikangface.utils.CompressPic; | 10 | import com.sincere.haikangface.utils.CompressPic; | 
| 13 | import com.sincere.haikangface.utils.FileUtils; | 11 | import com.sincere.haikangface.utils.FileUtils; | 
| 14 | -import com.sincere.haikangface.utils.SendRecoderUtils; | ||
| 15 | import com.sincere.haikangface.xiananDao.SendRecordDao; | 12 | import com.sincere.haikangface.xiananDao.SendRecordDao; | 
| 16 | import io.swagger.annotations.Api; | 13 | import io.swagger.annotations.Api; | 
| 17 | import io.swagger.annotations.ApiOperation; | 14 | import io.swagger.annotations.ApiOperation; | 
| 18 | import lombok.extern.slf4j.Slf4j; | 15 | import lombok.extern.slf4j.Slf4j; | 
| 19 | -import org.slf4j.Logger; | ||
| 20 | -import org.slf4j.LoggerFactory; | ||
| 21 | import org.springframework.beans.factory.annotation.Autowired; | 16 | import org.springframework.beans.factory.annotation.Autowired; | 
| 22 | import org.springframework.util.StringUtils; | 17 | import org.springframework.util.StringUtils; | 
| 23 | import org.springframework.web.bind.annotation.*; | 18 | import org.springframework.web.bind.annotation.*; | 
| @@ -25,8 +20,6 @@ import org.springframework.web.multipart.MultipartFile; | @@ -25,8 +20,6 @@ import org.springframework.web.multipart.MultipartFile; | ||
| 25 | 20 | ||
| 26 | import java.io.File; | 21 | import java.io.File; | 
| 27 | import java.io.FileOutputStream; | 22 | import java.io.FileOutputStream; | 
| 28 | -import java.text.SimpleDateFormat; | ||
| 29 | -import java.util.*; | ||
| 30 | 23 | ||
| 31 | @RestController | 24 | @RestController | 
| 32 | @Api("文件管理器") | 25 | @Api("文件管理器") | 
| @@ -65,7 +58,11 @@ public class FileControl { | @@ -65,7 +58,11 @@ public class FileControl { | ||
| 65 | @RequestParam("endTime") String endTime, @RequestParam("validTimeEnabled") int validTimeEnabled, @RequestParam("userType") String userType) { | 58 | @RequestParam("endTime") String endTime, @RequestParam("validTimeEnabled") int validTimeEnabled, @RequestParam("userType") String userType) { | 
| 66 | try { | 59 | try { | 
| 67 | if (!cmsServer.getIsDeviceOnline(deviceId)) { | 60 | if (!cmsServer.getIsDeviceOnline(deviceId)) { | 
| 68 | - FileUtils.getInstance().writeLogs("设备不在线:" + deviceId, FileUtils.devices); | 61 | + log.warn("设备ID: {},设备不在线",deviceId); | 
| 62 | + return "0"; | ||
| 63 | + } | ||
| 64 | + if(StringUtils.isEmpty(card)){ | ||
| 65 | + log.warn("卡号为空"); | ||
| 69 | return "0"; | 66 | return "0"; | 
| 70 | } | 67 | } | 
| 71 | String fileName = file.getOriginalFilename();//文件名 | 68 | String fileName = file.getOriginalFilename();//文件名 | 
| @@ -76,11 +73,10 @@ public class FileControl { | @@ -76,11 +73,10 @@ public class FileControl { | ||
| 76 | fileOutputStream.write(file.getBytes()); | 73 | fileOutputStream.write(file.getBytes()); | 
| 77 | fileOutputStream.close(); | 74 | fileOutputStream.close(); | 
| 78 | String filePath = dest.getAbsolutePath(); | 75 | String filePath = dest.getAbsolutePath(); | 
| 79 | - FileUtils.getInstance().writeLogs("filePath:" + filePath + " card:" + card + " name:" + name + " deviceId:" + deviceId, FileUtils.sendUserInfo); | ||
| 80 | long time = System.currentTimeMillis(); | 76 | long time = System.currentTimeMillis(); | 
| 81 | StudentBean studentBean = userDao.getStudentWithCard(card); | 77 | StudentBean studentBean = userDao.getStudentWithCard(card); | 
| 82 | Integer schoolId = studentBean ==null ?null:studentBean.getSchool_id(); | 78 | Integer schoolId = studentBean ==null ?null:studentBean.getSchool_id(); | 
| 83 | - String cardNum = Long.parseLong(baseService.getCard(card), 16) + ""; | 79 | + String cardNum = Long.parseLong(baseService.getCard(card),16) + ""; | 
| 84 | if (new File(filePath.trim()).exists()) { | 80 | if (new File(filePath.trim()).exists()) { | 
| 85 | String targetPath = FileUtils.picPathComp + new File(filePath).getName(); | 81 | String targetPath = FileUtils.picPathComp + new File(filePath).getName(); | 
| 86 | try { | 82 | try { | 
| @@ -89,7 +85,8 @@ public class FileControl { | @@ -89,7 +85,8 @@ public class FileControl { | ||
| 89 | e.printStackTrace(); | 85 | e.printStackTrace(); | 
| 90 | } | 86 | } | 
| 91 | try { | 87 | try { | 
| 92 | - sendUserAsync.sendStuToHaiKang(filePath, targetPath,cardNum,startTime, endTime, validTimeEnabled, name, deviceId, userType,schoolId); | 88 | + log.info("下发人脸,人脸路径:{},用户名:{},下发设备:{}",filePath,name,deviceId); | 
| 89 | + sendUserAsync.sendStuToHaiKang(filePath, targetPath,cardNum,startTime, endTime, validTimeEnabled, name, deviceId, userType,schoolId,card); | ||
| 93 | System.out.println("time:" + (System.currentTimeMillis() - time) / 1000); | 90 | System.out.println("time:" + (System.currentTimeMillis() - time) / 1000); | 
| 94 | return "1"; | 91 | return "1"; | 
| 95 | } catch (Exception e) { | 92 | } catch (Exception e) { | 
cloud/haikangface/src/main/java/com/sincere/haikangface/control/UserControl.java
| @@ -137,7 +137,7 @@ public class UserControl { | @@ -137,7 +137,7 @@ public class UserControl { | ||
| 137 | if (null != studentBean) { | 137 | if (null != studentBean) { | 
| 138 | if (cmsServer.getIsDeviceOnline(devId)) { | 138 | if (cmsServer.getIsDeviceOnline(devId)) { | 
| 139 | String cardNum = Long.parseLong(baseService.getCard(card), 16) + ""; | 139 | String cardNum = Long.parseLong(baseService.getCard(card), 16) + ""; | 
| 140 | - sendUserAsync.sendStuToHaiKang(filePath.getAbsolutePath(),targetPath,cardNum, startTime, endTime, 1, name, devId, images2Ddevices.getUserType(), 0); | 140 | + sendUserAsync.sendStuToHaiKang(filePath.getAbsolutePath(),targetPath,cardNum, startTime, endTime,1, name, devId, images2Ddevices.getUserType(), 0,card); | 
| 141 | } else { | 141 | } else { | 
| 142 | sendUserAsync.uploadImgs(targetPath, card, name, devId, startTime, endTime, 1, images2Ddevices.getUserType()); | 142 | sendUserAsync.uploadImgs(targetPath, card, name, devId, startTime, endTime, 1, images2Ddevices.getUserType()); | 
| 143 | } | 143 | } | 
cloud/haikangface/src/main/java/com/sincere/haikangface/control/UserOperateController.java
| 1 | package com.sincere.haikangface.control; | 1 | package com.sincere.haikangface.control; | 
| 2 | 2 | ||
| 3 | -import com.alibaba.fastjson.JSON; | ||
| 4 | -import com.fasterxml.jackson.databind.JavaType; | ||
| 5 | -import com.sincere.haikangface.async.SendUserAsync; | ||
| 6 | import com.sincere.haikangface.bean.Result; | 3 | import com.sincere.haikangface.bean.Result; | 
| 7 | import com.sincere.haikangface.bean.ResultGenerator; | 4 | import com.sincere.haikangface.bean.ResultGenerator; | 
| 8 | import com.sincere.haikangface.bean.face.AuthRecordDto; | 5 | import com.sincere.haikangface.bean.face.AuthRecordDto; | 
| 9 | import com.sincere.haikangface.bean.face.DeviceAuthRecord; | 6 | import com.sincere.haikangface.bean.face.DeviceAuthRecord; | 
| 10 | -import com.sincere.haikangface.bean.face.PermissionBean; | ||
| 11 | -import com.sincere.haikangface.bean.face.WeekDay; | 7 | +import com.sincere.haikangface.bean.face.SendFaceDto; | 
| 12 | import com.sincere.haikangface.dao.UserDao; | 8 | import com.sincere.haikangface.dao.UserDao; | 
| 13 | -import com.sincere.haikangface.enums.EnumSzBusinessType; | ||
| 14 | import com.sincere.haikangface.service.UserOperateService; | 9 | import com.sincere.haikangface.service.UserOperateService; | 
| 15 | -import com.sincere.haikangface.utils.FileUtils; | ||
| 16 | import com.sincere.haikangface.utils.JsonUtils; | 10 | import com.sincere.haikangface.utils.JsonUtils; | 
| 17 | import io.swagger.annotations.ApiOperation; | 11 | import io.swagger.annotations.ApiOperation; | 
| 18 | import lombok.extern.slf4j.Slf4j; | 12 | import lombok.extern.slf4j.Slf4j; | 
| 19 | import org.springframework.beans.factory.annotation.Autowired; | 13 | import org.springframework.beans.factory.annotation.Autowired; | 
| 20 | import org.springframework.http.MediaType; | 14 | import org.springframework.http.MediaType; | 
| 21 | -import org.springframework.util.StringUtils; | ||
| 22 | import org.springframework.web.bind.annotation.*; | 15 | import org.springframework.web.bind.annotation.*; | 
| 23 | 16 | ||
| 24 | -import java.util.ArrayList; | ||
| 25 | -import java.util.Arrays; | ||
| 26 | -import java.util.List; | ||
| 27 | -import java.util.Map; | ||
| 28 | - | ||
| 29 | /** | 17 | /** | 
| 30 | * 用户信息、人脸、卡信息、权限下发控制类 | 18 | * 用户信息、人脸、卡信息、权限下发控制类 | 
| 31 | * @author xuquan | 19 | * @author xuquan | 
| @@ -39,14 +27,11 @@ public class UserOperateController { | @@ -39,14 +27,11 @@ public class UserOperateController { | ||
| 39 | @Autowired | 27 | @Autowired | 
| 40 | UserDao userDao; | 28 | UserDao userDao; | 
| 41 | @Autowired | 29 | @Autowired | 
| 42 | - SendUserAsync sendUserAsync; | ||
| 43 | - @Autowired | ||
| 44 | UserOperateService userOperateService; | 30 | UserOperateService userOperateService; | 
| 45 | 31 | ||
| 46 | @RequestMapping(value = "createHKAuth", method = RequestMethod.POST) | 32 | @RequestMapping(value = "createHKAuth", method = RequestMethod.POST) | 
| 47 | @ApiOperation("人脸机创建权限2.0") | 33 | @ApiOperation("人脸机创建权限2.0") | 
| 48 | - public Result sendPermiss(@RequestBody AuthRecordDto authRecordDto) { | ||
| 49 | - log.info("permissionBean:{}", JSON.toJSONString(authRecordDto)); | 34 | + public Result createHKAuth(@RequestBody AuthRecordDto authRecordDto) { | 
| 50 | if(userOperateService.createHKAuth(authRecordDto)){ | 35 | if(userOperateService.createHKAuth(authRecordDto)){ | 
| 51 | return ResultGenerator.genSuccessResult(); | 36 | return ResultGenerator.genSuccessResult(); | 
| 52 | }else{ | 37 | }else{ | 
| @@ -57,34 +42,8 @@ public class UserOperateController { | @@ -57,34 +42,8 @@ public class UserOperateController { | ||
| 57 | private static JsonUtils objectMapper = JsonUtils.nonEmptyMapper(); | 42 | private static JsonUtils objectMapper = JsonUtils.nonEmptyMapper(); | 
| 58 | @RequestMapping(value = "sendHKAuth", method = RequestMethod.POST) | 43 | @RequestMapping(value = "sendHKAuth", method = RequestMethod.POST) | 
| 59 | @ApiOperation("下发权限给设备2.0") | 44 | @ApiOperation("下发权限给设备2.0") | 
| 60 | - public Result sendHKPermiss(@RequestParam("authId") Integer authId) { | ||
| 61 | - DeviceAuthRecord record = userDao.getAuthRecord(authId); | ||
| 62 | - if(record ==null){ | ||
| 63 | - log.info("未查询到对应权限ID: {}, 权限计划。",authId); | ||
| 64 | - return ResultGenerator.genFailResult("未查询到对应权限"); | ||
| 65 | - } | ||
| 66 | - Integer studentType = record.getStudentType(); | ||
| 67 | - //周计划 | ||
| 68 | - String weekDaysJson = record.getWeekDays(); | ||
| 69 | - JavaType javaType = objectMapper.contructCollectionType(ArrayList.class, WeekDay.class); | ||
| 70 | - ArrayList<WeekDay> weekDayList = objectMapper.fromJson(weekDaysJson,javaType); | ||
| 71 | - //设备ID | ||
| 72 | - String[] deviceArr = record.getSno().split(","); | ||
| 73 | - List<String> devices= new ArrayList<>(Arrays.asList(deviceArr)); | ||
| 74 | - PermissionBean permissionBean = new PermissionBean(); | ||
| 75 | - permissionBean.setWeekDays(weekDayList); | ||
| 76 | - permissionBean.setDeviceIds(devices); | ||
| 77 | - permissionBean.setSchoolId(String.valueOf(record.getSchoolId())); | ||
| 78 | - permissionBean.setUserType(String.valueOf(EnumSzBusinessType.EnumUserType.STUDENT.code)); | ||
| 79 | - FileUtils.getInstance().writeLogs("传入权限模板:" + JSON.toJSONString(permissionBean), "设置权限内容.txt"); | ||
| 80 | - if (!StringUtils.isEmpty(permissionBean.getDeviceIds())) { | ||
| 81 | - if(sendUserAsync.sendHKAuth(permissionBean,record.getId(),studentType)){ | ||
| 82 | - return ResultGenerator.genSuccessResult(); | ||
| 83 | - }else{ | ||
| 84 | - return ResultGenerator.genFailResult("下发权限失败"); | ||
| 85 | - } | ||
| 86 | - } | ||
| 87 | - return ResultGenerator.genSuccessResult(); | 45 | + public Result sendHKAuth(@RequestParam("authId") Integer authId) { | 
| 46 | + return userOperateService.sendHKAuth(authId); | ||
| 88 | } | 47 | } | 
| 89 | 48 | ||
| 90 | @ApiOperation("删除单卡权限2.0") | 49 | @ApiOperation("删除单卡权限2.0") | 
| @@ -112,25 +71,34 @@ public class UserOperateController { | @@ -112,25 +71,34 @@ public class UserOperateController { | ||
| 112 | return userOperateService.sendFace(schoolId,type,deviceIds); | 71 | return userOperateService.sendFace(schoolId,type,deviceIds); | 
| 113 | } | 72 | } | 
| 114 | 73 | ||
| 115 | - // /** | ||
| 116 | -// * 下发卡权限至指定设备(含批量) | ||
| 117 | -// * @param permissionBean | ||
| 118 | -// * @return | ||
| 119 | -// */ | ||
| 120 | -// @RequestMapping(value = "sendUserPermission", method = RequestMethod.POST) | ||
| 121 | -// @ApiOperation("下发权限给设备") | ||
| 122 | -// public boolean sendUserPermission(@RequestBody PermissionBean permissionBean) { | ||
| 123 | -// log.error("permissionBean:{}", JSON.toJSONString(permissionBean)); | ||
| 124 | -// FileUtils.getInstance().writeLogs("传入权限模板:" + JSON.toJSONString(permissionBean), "设置权限内容.txt"); | ||
| 125 | -// | ||
| 126 | -// return userOperateService.sendUserPermission(permissionBean); | ||
| 127 | -// } | ||
| 128 | -// | ||
| 129 | -// | ||
| 130 | -// @RequestMapping(value = "sendUserFace", method = RequestMethod.POST) | ||
| 131 | -// @ApiOperation("下发人脸给设备") | ||
| 132 | -// public boolean sendUserFace(@RequestParam("filePath") String filePath, @RequestParam("userId") String userId,@RequestParam("userType") Integer userType, | ||
| 133 | -// @RequestParam("schoolId") String schoolId, @RequestParam("deviceId") String deviceId) { | ||
| 134 | -// return userOperateService.sendUserFace(filePath,schoolId, userId,userType,deviceId); | ||
| 135 | -// } | 74 | + @ApiOperation(value = "照片下发2.1") | 
| 75 | + @RequestMapping(value = "sendFaceByThread", method = RequestMethod.POST) | ||
| 76 | + public Result sendFaceByThread(@RequestBody SendFaceDto sendFaceDto) { | ||
| 77 | + return userOperateService.sendUserFaceByThread(sendFaceDto); | ||
| 78 | + } | ||
| 79 | + | ||
| 80 | + @ApiOperation(value = "删除下发失败人脸2.0") | ||
| 81 | + @RequestMapping(value = "deleteFailFace", method = RequestMethod.POST) | ||
| 82 | + public Result deleteFailFace(@RequestParam("schoolId") Integer schoolId) { | ||
| 83 | + return userOperateService.deleteFailFace(schoolId); | ||
| 84 | + } | ||
| 85 | + | ||
| 86 | + @RequestMapping(value = "sendFailFace", method = RequestMethod.POST) | ||
| 87 | + @ApiOperation(value = "重新下发失败人脸2.0") | ||
| 88 | + public Result sendFailFace(@RequestParam("schoolId") Integer schoolId) { | ||
| 89 | + return userOperateService.sendFailFace(schoolId); | ||
| 90 | + } | ||
| 91 | + | ||
| 92 | + @ApiOperation(value = "删除指定人脸2.0") | ||
| 93 | + @RequestMapping(value = "deleteFace", method = RequestMethod.POST) | ||
| 94 | + public Result deleteFace(@RequestParam("schoolId") Integer schoolId, @RequestParam("cards") String cards,@RequestParam("deviceIds") String deviceIds) { | ||
| 95 | + return userOperateService.deleteFace(schoolId,cards,deviceIds); | ||
| 96 | + } | ||
| 97 | + | ||
| 98 | + @ApiOperation(value = "测试下发人脸2.0") | ||
| 99 | + @RequestMapping(value = "deleteFaceTest", method = RequestMethod.POST) | ||
| 100 | + public Result deleteFaceTest(@RequestParam("schoolId") Integer schoolId,@RequestParam("deviceIds") String deviceIds) { | ||
| 101 | + return userOperateService.deleteFaceTest(schoolId,deviceIds); | ||
| 102 | + } | ||
| 103 | + | ||
| 136 | } | 104 | } | 
cloud/haikangface/src/main/java/com/sincere/haikangface/dao/DeviceDao.java
| @@ -27,8 +27,8 @@ public interface DeviceDao { | @@ -27,8 +27,8 @@ public interface DeviceDao { | ||
| 27 | // @Select("select * from SZ_Attendance where IsKaoqin = #{IsKaoqin}") | 27 | // @Select("select * from SZ_Attendance where IsKaoqin = #{IsKaoqin}") | 
| 28 | // List<SZ_AttendanceDto> getAttensWithIsKaoqin(@Param("IsKaoqin")int IsKaoqin); | 28 | // List<SZ_AttendanceDto> getAttensWithIsKaoqin(@Param("IsKaoqin")int IsKaoqin); | 
| 29 | 29 | ||
| 30 | - @Update("update SZ_Attendance set isConnection = #{isConnection} where clint_id = #{clint_id}") | ||
| 31 | - int updateDeviceStatu(@Param("isConnection") int isConnection, @Param("clint_id") String clint_id); | 30 | + @Update("update SZ_Attendance set isConnection = #{isConnection},intime = #{inTime} where clint_id = #{clint_id}") | 
| 31 | + int updateDeviceStatu(@Param("isConnection") int isConnection, @Param("inTime") String inTime, @Param("clint_id") String clint_id); | ||
| 32 | 32 | ||
| 33 | 33 | ||
| 34 | /** | 34 | /** | 
cloud/haikangface/src/main/java/com/sincere/haikangface/dao/UserDao.java
| @@ -29,18 +29,12 @@ public interface UserDao { | @@ -29,18 +29,12 @@ public interface UserDao { | ||
| 29 | */ | 29 | */ | 
| 30 | @Select("select * from HS_StudentUpdateCard where ID > #{id} and StudentType = #{StudentType} order by AddTime desc") | 30 | @Select("select * from HS_StudentUpdateCard where ID > #{id} and StudentType = #{StudentType} order by AddTime desc") | 
| 31 | List<StudentBean> getAllStudents(@Param("id") long id, @Param("StudentType") int StudentType); | 31 | List<StudentBean> getAllStudents(@Param("id") long id, @Param("StudentType") int StudentType); | 
| 32 | -// @Select("select * from HS_StudentUpdateCard where ID > #{id} order by AddTime desc") | ||
| 33 | -// List<StudentBean> getAllStudents(@Param("id")long id); | ||
| 34 | - | ||
| 35 | @Update("update SZ_V_School_Student set name = #{name} where student_id = #{student_id}") | 32 | @Update("update SZ_V_School_Student set name = #{name} where student_id = #{student_id}") | 
| 36 | void updateTest(@Param("student_id") String student_id, @Param("name") String name); | 33 | void updateTest(@Param("student_id") String student_id, @Param("name") String name); | 
| 37 | 34 | ||
| 38 | @Select("select Top(1) student_num from SZ_V_School_Student where student_id = #{student_id} and role_state = 1") | 35 | @Select("select Top(1) student_num from SZ_V_School_Student where student_id = #{student_id} and role_state = 1") | 
| 39 | String getStudent_Num(@Param("student_id") String student_id); | 36 | String getStudent_Num(@Param("student_id") String student_id); | 
| 40 | 37 | ||
| 41 | -// @Select("select * from TK_QuestionBar") | ||
| 42 | -// List<TK_Question> getQuestion(); | ||
| 43 | - | ||
| 44 | @Insert("insert into TK_Question (Question,Qtype,Answer,CorrectAnswer,Analysis,State,Intime,ExamineFlag,ExamineUserId, " + | 38 | @Insert("insert into TK_Question (Question,Qtype,Answer,CorrectAnswer,Analysis,State,Intime,ExamineFlag,ExamineUserId, " + | 
| 45 | "CreateUserId,SubjectId,SuggestionTime,DifficulteId,KnowledgeId,TestId,ChapterId,\n" + | 39 | "CreateUserId,SubjectId,SuggestionTime,DifficulteId,KnowledgeId,TestId,ChapterId,\n" + | 
| 46 | "GradeId,SourceId,OrderId,SId,StemId,AutomaticCorrection,SchoolId) values(#{Question},#{Qtype},#{Answer},#{CorrectAnswer},#{Analysis}" + | 40 | "GradeId,SourceId,OrderId,SId,StemId,AutomaticCorrection,SchoolId) values(#{Question},#{Qtype},#{Answer},#{CorrectAnswer},#{Analysis}" + | 
| @@ -262,6 +256,8 @@ public interface UserDao { | @@ -262,6 +256,8 @@ public interface UserDao { | ||
| 262 | /**************************************** add by xuquan **************************************/ | 256 | /**************************************** add by xuquan **************************************/ | 
| 263 | DeviceAuthRecord getAuthRecord(Integer authId); | 257 | DeviceAuthRecord getAuthRecord(Integer authId); | 
| 264 | 258 | ||
| 259 | + Integer getAuthRecordBySchoolId(@Param("schoolId") Integer schoolId, @Param("studentType") Integer studentType,@Param("status") Integer status); | ||
| 260 | + | ||
| 265 | void insertAuthRecord(DeviceAuthRecord record); | 261 | void insertAuthRecord(DeviceAuthRecord record); | 
| 266 | 262 | ||
| 267 | void deleteAuthRecord(@Param("id") Integer authId); | 263 | void deleteAuthRecord(@Param("id") Integer authId); | 
| @@ -274,4 +270,10 @@ public interface UserDao { | @@ -274,4 +270,10 @@ public interface UserDao { | ||
| 274 | 270 | ||
| 275 | @Select("select clint_type from SZ_Attendance where clint_id = #{deviceId}") | 271 | @Select("select clint_type from SZ_Attendance where clint_id = #{deviceId}") | 
| 276 | Integer getClintTypeByDeviceId(@Param("deviceId") String deviceId); | 272 | Integer getClintTypeByDeviceId(@Param("deviceId") String deviceId); | 
| 273 | + | ||
| 274 | + List<StudentBean> getStudentList(@Param("schoolId") Integer schoolId,@Param("studentType")Integer studentType,@Param("sex") List<Integer> sex); | ||
| 275 | + | ||
| 276 | + List<StudentBean> getTeacherList(@Param("schoolId") Integer schoolId); | ||
| 277 | + | ||
| 278 | + List<String> getDeviceIds(@Param("schoolId") Integer schoolId,@Param("deviceId") String deviceId); | ||
| 277 | } | 279 | } | 
cloud/haikangface/src/main/java/com/sincere/haikangface/enums/EnumSzBusinessType.java
| @@ -41,10 +41,24 @@ public interface EnumSzBusinessType { | @@ -41,10 +41,24 @@ public interface EnumSzBusinessType { | ||
| 41 | public final int code; | 41 | public final int code; | 
| 42 | public final String name; | 42 | public final String name; | 
| 43 | 43 | ||
| 44 | + public int getCode() { | ||
| 45 | + return code; | ||
| 46 | + } | ||
| 47 | + public String getName() { | ||
| 48 | + return name; | ||
| 49 | + } | ||
| 44 | EnumStudentType(int code, String name) { | 50 | EnumStudentType(int code, String name) { | 
| 45 | this.code = code; | 51 | this.code = code; | 
| 46 | this.name = name; | 52 | this.name = name; | 
| 47 | } | 53 | } | 
| 54 | + public static EnumSzBusinessType.EnumStudentType getByCode(int code){ | ||
| 55 | + for(EnumSzBusinessType.EnumStudentType enums: EnumSzBusinessType.EnumStudentType.values()){ | ||
| 56 | + if(enums.getCode()==code){ | ||
| 57 | + return enums; | ||
| 58 | + } | ||
| 59 | + } | ||
| 60 | + return null; | ||
| 61 | + } | ||
| 48 | } | 62 | } | 
| 49 | 63 | ||
| 50 | /** | 64 | /** | 
cloud/haikangface/src/main/java/com/sincere/haikangface/service/UserOperateService.java
| @@ -4,24 +4,17 @@ import com.sincere.haikangface.bean.Result; | @@ -4,24 +4,17 @@ import com.sincere.haikangface.bean.Result; | ||
| 4 | import com.sincere.haikangface.bean.face.AuthRecordDto; | 4 | import com.sincere.haikangface.bean.face.AuthRecordDto; | 
| 5 | import com.sincere.haikangface.bean.face.DeviceAuthRecord; | 5 | import com.sincere.haikangface.bean.face.DeviceAuthRecord; | 
| 6 | import com.sincere.haikangface.bean.face.PermissionBean; | 6 | import com.sincere.haikangface.bean.face.PermissionBean; | 
| 7 | +import com.sincere.haikangface.bean.face.SendFaceDto; | ||
| 7 | import org.apache.ibatis.annotations.Param; | 8 | import org.apache.ibatis.annotations.Param; | 
| 8 | 9 | ||
| 9 | /** | 10 | /** | 
| 11 | + * 用户操作业务接口 | ||
| 10 | * @author xuquan | 12 | * @author xuquan | 
| 11 | * @date 2020/12/10 17:25 | 13 | * @date 2020/12/10 17:25 | 
| 12 | */ | 14 | */ | 
| 13 | 15 | ||
| 14 | public interface UserOperateService { | 16 | public interface UserOperateService { | 
| 15 | 17 | ||
| 16 | -// /** | ||
| 17 | -// * 下发卡权限至指定设备(含批量)a/ | ||
| 18 | -// * @param permissionBean | ||
| 19 | -// * @return | ||
| 20 | -// */ | ||
| 21 | -// boolean sendUserPermission(PermissionBean permissionBean); | ||
| 22 | -// | ||
| 23 | -// boolean sendUserFace(String filePath, String schoolId,String userId,int userType, String deviceId); | ||
| 24 | - | ||
| 25 | /** | 18 | /** | 
| 26 | * 创建权限 | 19 | * 创建权限 | 
| 27 | * @param recordDto | 20 | * @param recordDto | 
| @@ -30,6 +23,13 @@ public interface UserOperateService { | @@ -30,6 +23,13 @@ public interface UserOperateService { | ||
| 30 | boolean createHKAuth(AuthRecordDto recordDto); | 23 | boolean createHKAuth(AuthRecordDto recordDto); | 
| 31 | 24 | ||
| 32 | /** | 25 | /** | 
| 26 | + * 下发权限 | ||
| 27 | + * @param authId | ||
| 28 | + * @return | ||
| 29 | + */ | ||
| 30 | + Result sendHKAuth(Integer authId); | ||
| 31 | + | ||
| 32 | + /** | ||
| 33 | * 权限ID删除权限下发记录 | 33 | * 权限ID删除权限下发记录 | 
| 34 | * @param authId | 34 | * @param authId | 
| 35 | * @return | 35 | * @return | 
| @@ -43,8 +43,54 @@ public interface UserOperateService { | @@ -43,8 +43,54 @@ public interface UserOperateService { | ||
| 43 | */ | 43 | */ | 
| 44 | DeviceAuthRecord getAuthRecord(Integer authId); | 44 | DeviceAuthRecord getAuthRecord(Integer authId); | 
| 45 | 45 | ||
| 46 | + /** | ||
| 47 | + * 重新下发人脸 | ||
| 48 | + * @param userId | ||
| 49 | + * @param deviceId | ||
| 50 | + * @param userType | ||
| 51 | + * @return | ||
| 52 | + */ | ||
| 46 | Result againSendFace(String userId,String deviceId,Integer userType); | 53 | Result againSendFace(String userId,String deviceId,Integer userType); | 
| 47 | 54 | ||
| 55 | + /** | ||
| 56 | + * 批量照片下发 | ||
| 57 | + * @param schoolId | ||
| 58 | + * @param type | ||
| 59 | + * @param deviceIds | ||
| 60 | + * @return | ||
| 61 | + */ | ||
| 48 | Result sendFace(String schoolId,Integer type,String deviceIds); | 62 | Result sendFace(String schoolId,Integer type,String deviceIds); | 
| 49 | 63 | ||
| 64 | + /** | ||
| 65 | + * 多线程照片下发 | ||
| 66 | + * @param sendFaceDto | ||
| 67 | + * @return | ||
| 68 | + */ | ||
| 69 | + Result sendUserFaceByThread(SendFaceDto sendFaceDto); | ||
| 70 | + | ||
| 71 | + /** | ||
| 72 | + * 删除失败表人脸 | ||
| 73 | + * @param schoolId | ||
| 74 | + * @return | ||
| 75 | + */ | ||
| 76 | + Result deleteFailFace(Integer schoolId); | ||
| 77 | + | ||
| 78 | + /** | ||
| 79 | + * 下发失败表人脸 | ||
| 80 | + * @param schoolId | ||
| 81 | + * @return | ||
| 82 | + */ | ||
| 83 | + Result sendFailFace(Integer schoolId); | ||
| 84 | + | ||
| 85 | + /** | ||
| 86 | + * 删除指定人脸 | ||
| 87 | + * @param schoolId | ||
| 88 | + * @param cards | ||
| 89 | + * @param deviceIds | ||
| 90 | + * @return | ||
| 91 | + */ | ||
| 92 | + Result deleteFace(Integer schoolId,String cards,String deviceIds); | ||
| 93 | + | ||
| 94 | + Result deleteFaceTest(Integer schoolId,String deviceIds); | ||
| 95 | + | ||
| 50 | } | 96 | } | 
cloud/haikangface/src/main/java/com/sincere/haikangface/service/impl/BaseService.java
| @@ -3,7 +3,10 @@ package com.sincere.haikangface.service.impl; | @@ -3,7 +3,10 @@ package com.sincere.haikangface.service.impl; | ||
| 3 | 3 | ||
| 4 | import com.alibaba.fastjson.JSONArray; | 4 | import com.alibaba.fastjson.JSONArray; | 
| 5 | import com.alibaba.fastjson.JSONObject; | 5 | import com.alibaba.fastjson.JSONObject; | 
| 6 | +import com.google.common.util.concurrent.ThreadFactoryBuilder; | ||
| 6 | import com.sincere.haikangface.CMSServer; | 7 | import com.sincere.haikangface.CMSServer; | 
| 8 | +import com.sincere.haikangface.async.SendFaceBatchTask100; | ||
| 9 | +import com.sincere.haikangface.async.SendFaceBatchTask253; | ||
| 7 | import com.sincere.haikangface.async.SendUserAsync; | 10 | import com.sincere.haikangface.async.SendUserAsync; | 
| 8 | import com.sincere.haikangface.bean.BaiduFaceRecorder; | 11 | import com.sincere.haikangface.bean.BaiduFaceRecorder; | 
| 9 | import com.sincere.haikangface.bean.SendRecordBean; | 12 | import com.sincere.haikangface.bean.SendRecordBean; | 
| @@ -12,17 +15,23 @@ import com.sincere.haikangface.bean.TeacherBean; | @@ -12,17 +15,23 @@ import com.sincere.haikangface.bean.TeacherBean; | ||
| 12 | import com.sincere.haikangface.dao.UserDao; | 15 | import com.sincere.haikangface.dao.UserDao; | 
| 13 | import com.sincere.haikangface.enums.EnumSzBusinessType; | 16 | import com.sincere.haikangface.enums.EnumSzBusinessType; | 
| 14 | import com.sincere.haikangface.mqtt.MqtUtils; | 17 | import com.sincere.haikangface.mqtt.MqtUtils; | 
| 15 | -import com.sincere.haikangface.utils.*; | 18 | +import com.sincere.haikangface.utils.CompressPic; | 
| 19 | +import com.sincere.haikangface.utils.DateUtils; | ||
| 20 | +import com.sincere.haikangface.utils.FileUtils; | ||
| 21 | +import com.sincere.haikangface.utils.HttpUtil; | ||
| 16 | import com.sincere.haikangface.xiananDao.SendRecordDao; | 22 | import com.sincere.haikangface.xiananDao.SendRecordDao; | 
| 17 | import lombok.extern.slf4j.Slf4j; | 23 | import lombok.extern.slf4j.Slf4j; | 
| 18 | import org.apache.commons.lang3.StringUtils; | 24 | import org.apache.commons.lang3.StringUtils; | 
| 19 | import org.springframework.beans.factory.annotation.Autowired; | 25 | import org.springframework.beans.factory.annotation.Autowired; | 
| 20 | import org.springframework.beans.factory.annotation.Value; | 26 | import org.springframework.beans.factory.annotation.Value; | 
| 27 | +import org.springframework.scheduling.annotation.Async; | ||
| 21 | import org.springframework.stereotype.Service; | 28 | import org.springframework.stereotype.Service; | 
| 22 | 29 | ||
| 23 | import java.io.File; | 30 | import java.io.File; | 
| 24 | import java.text.SimpleDateFormat; | 31 | import java.text.SimpleDateFormat; | 
| 25 | import java.util.*; | 32 | import java.util.*; | 
| 33 | +import java.util.concurrent.*; | ||
| 34 | +import java.util.stream.Collectors; | ||
| 26 | 35 | ||
| 27 | /** | 36 | /** | 
| 28 | * 业务基础类 | 37 | * 业务基础类 | 
| @@ -90,13 +99,13 @@ public class BaseService { | @@ -90,13 +99,13 @@ public class BaseService { | ||
| 90 | if (cmsServer.getIsDeviceOnline(deviceId)) { | 99 | if (cmsServer.getIsDeviceOnline(deviceId)) { | 
| 91 | String cardNo = Long.parseLong(getCard(card),16)+""; | 100 | String cardNo = Long.parseLong(getCard(card),16)+""; | 
| 92 | //下发海康设备 | 101 | //下发海康设备 | 
| 93 | - sendUserAsync.sendStuToHaiKang(filePath,targetPath, cardNo, startTime, endTime, validTimeEnabled, name, deviceId, userType,schoolId); | 102 | + sendUserAsync.sendStuToHaiKang(filePath,targetPath, cardNo, startTime, endTime, validTimeEnabled, name, deviceId, userType,schoolId,card); | 
| 94 | }else { | 103 | }else { | 
| 95 | sendUserAsync.uploadImgs(targetPath, card, name, deviceId, startTime, endTime, validTimeEnabled, userType); | 104 | sendUserAsync.uploadImgs(targetPath, card, name, deviceId, startTime, endTime, validTimeEnabled, userType); | 
| 96 | } | 105 | } | 
| 97 | return true; | 106 | return true; | 
| 98 | } catch (Exception e) { | 107 | } catch (Exception e) { | 
| 99 | - log.error("下发人脸照失败,错误信息:"+ e.getMessage()); | 108 | + log.error("下发人脸照失败,错误信息:"+e); | 
| 100 | return false; | 109 | return false; | 
| 101 | } | 110 | } | 
| 102 | } | 111 | } | 
| @@ -149,91 +158,93 @@ public class BaseService { | @@ -149,91 +158,93 @@ public class BaseService { | ||
| 149 | /** | 158 | /** | 
| 150 | * 保存成功下发记录 | 159 | * 保存成功下发记录 | 
| 151 | */ | 160 | */ | 
| 152 | - public synchronized void sendSuccessRecord(String card, String faceUrl, String deviceId,String userType) { | ||
| 153 | - long lon = Long.parseLong(card); | ||
| 154 | - String resultCard = getCard(String.format("%08x", lon)).toUpperCase(); | ||
| 155 | - StudentBean studentBean = null; | ||
| 156 | - switch (userType) { | ||
| 157 | - case "1"://老师 | ||
| 158 | - studentBean = userDao.getTeacherWithCard(resultCard); | ||
| 159 | - break; | ||
| 160 | - case "2"://学生 | ||
| 161 | - studentBean = userDao.getStudentWithCard(resultCard); | ||
| 162 | - break; | ||
| 163 | - case "3"://家长 | ||
| 164 | - break; | ||
| 165 | - } | ||
| 166 | - if (null != studentBean) { | ||
| 167 | - //用户ID | ||
| 168 | - String userId = studentBean.getUser_id(); | ||
| 169 | - //用户名称 | ||
| 170 | - String userName = studentBean.getName(); | ||
| 171 | - //所属学校 | ||
| 172 | - int schoolId = studentBean.getSchool_id(); | ||
| 173 | - String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); | ||
| 174 | - String schoolName = userDao.getSchoolName(studentBean.getSchool_id() + ""); | ||
| 175 | - List<SendRecordBean> sendRecordBeans = sendRecordDao.getRecordIsExit(deviceId,resultCard,userId); | ||
| 176 | - SendRecordBean sendRecordBean =null; | ||
| 177 | - if(sendRecordBeans.size()>0){ | ||
| 178 | - sendRecordBean = sendRecordBeans.get(0); | 161 | + public synchronized void sendSuccessRecord(String resultCard, String faceUrl, String deviceId,String userType) { | 
| 162 | + try{ | ||
| 163 | + StudentBean studentBean = null; | ||
| 164 | + switch (userType) { | ||
| 165 | + case "1"://老师 | ||
| 166 | + studentBean = userDao.getTeacherWithCard(resultCard); | ||
| 167 | + break; | ||
| 168 | + case "2"://学生 | ||
| 169 | + studentBean = userDao.getStudentWithCard(resultCard); | ||
| 170 | + break; | ||
| 171 | + case "3"://家长 | ||
| 172 | + break; | ||
| 179 | } | 173 | } | 
| 180 | - if (null == sendRecordBean) { | ||
| 181 | - sendRecordDao.saveFaceRecord(userId, deviceId, resultCard, userName, time, schoolName, | ||
| 182 | - faceUrl, schoolId,null,null, Integer.parseInt(userType),18,1); | 174 | + if (null != studentBean) { | 
| 175 | + //用户ID | ||
| 176 | + String userId = studentBean.getUser_id(); | ||
| 177 | + //用户名称 | ||
| 178 | + String userName = studentBean.getName(); | ||
| 179 | + //所属学校 | ||
| 180 | + int schoolId = studentBean.getSchool_id(); | ||
| 181 | + String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); | ||
| 182 | + String schoolName = userDao.getSchoolName(studentBean.getSchool_id() + ""); | ||
| 183 | + List<SendRecordBean> sendRecordBeans = sendRecordDao.getRecordIsExit(deviceId,resultCard,userId); | ||
| 184 | + SendRecordBean sendRecordBean =null; | ||
| 185 | + if(sendRecordBeans.size()>0){ | ||
| 186 | + sendRecordBean = sendRecordBeans.get(0); | ||
| 187 | + } | ||
| 188 | + if (null == sendRecordBean) { | ||
| 189 | + sendRecordDao.saveFaceRecord(userId, deviceId, resultCard, userName, time, schoolName, | ||
| 190 | + faceUrl, schoolId,null,null, Integer.parseInt(userType),18,1); | ||
| 191 | + } else { | ||
| 192 | + sendRecordDao.updateFaceSuccessRecord(deviceId,resultCard,time,faceUrl,userName,userId); | ||
| 193 | + } | ||
| 194 | + FileUtils.getInstance().writeLogs(studentBean.toString() + "\r\n" + resultCard, "下发成功记录"); | ||
| 183 | } else { | 195 | } else { | 
| 184 | - sendRecordDao.updateFaceSuccessRecord(deviceId,resultCard,time,faceUrl,userName,userId); | 196 | + log.error("用户不存在: 对应卡号{} ," + resultCard); | 
| 185 | } | 197 | } | 
| 186 | - FileUtils.getInstance().writeLogs(studentBean.toString() + "\r\n" + resultCard, "下发成功记录"); | ||
| 187 | - } else { | ||
| 188 | - log.error("用户不存在: 对应卡号{} ," + resultCard); | 198 | + }catch (Exception e){ | 
| 199 | + log.error("保存记录异常,异常信息:{}",e); | ||
| 189 | } | 200 | } | 
| 190 | } | 201 | } | 
| 191 | 202 | ||
| 192 | - | ||
| 193 | /** | 203 | /** | 
| 194 | * 保存下发失败记录 | 204 | * 保存下发失败记录 | 
| 195 | - * @param card | ||
| 196 | * @param faceUrl | 205 | * @param faceUrl | 
| 197 | * @param deviceId | 206 | * @param deviceId | 
| 198 | * @param content | 207 | * @param content | 
| 199 | * @param userType | 208 | * @param userType | 
| 200 | */ | 209 | */ | 
| 201 | - public synchronized void sendFailRecord(String card, String faceUrl, String deviceId,String content,String userType) { | ||
| 202 | - long lon = Long.parseLong(card); | ||
| 203 | - String resultCard = getCard(String.format("%08x", lon)).toUpperCase(); | ||
| 204 | - StudentBean studentBean = null; | ||
| 205 | - switch (userType) { | ||
| 206 | - case "1"://老师 | ||
| 207 | - studentBean = userDao.getTeacherWithCard(resultCard); | ||
| 208 | - break; | ||
| 209 | - case "2"://学生 | ||
| 210 | - studentBean = userDao.getStudentWithCard(resultCard); | ||
| 211 | - break; | ||
| 212 | - case "3"://家长 | ||
| 213 | - break; | ||
| 214 | - } | ||
| 215 | - if (null != studentBean) { | ||
| 216 | - //用户ID | ||
| 217 | - String userId = studentBean.getUser_id(); | ||
| 218 | - //用户名称 | ||
| 219 | - String userName = studentBean.getName(); | ||
| 220 | - //所属学校 | ||
| 221 | - int schoolId = studentBean.getSchool_id(); | ||
| 222 | - String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); | ||
| 223 | - String schoolName = userDao.getSchoolName(studentBean.getSchool_id() + ""); | ||
| 224 | - List<SendRecordBean> sendRecordBeans = sendRecordDao.getRecordIsExit(deviceId,resultCard,userId); | ||
| 225 | - SendRecordBean sendRecordBean =null; | ||
| 226 | - if(sendRecordBeans.size()>0){ | ||
| 227 | - sendRecordBean = sendRecordBeans.get(0); | 210 | + public synchronized void sendFailRecord(String resultCard, String faceUrl, String deviceId,String content,String userType) { | 
| 211 | + try{ | ||
| 212 | + StudentBean studentBean = null; | ||
| 213 | + switch (userType) { | ||
| 214 | + case "1"://老师 | ||
| 215 | + studentBean = userDao.getTeacherWithCard(resultCard); | ||
| 216 | + break; | ||
| 217 | + case "2"://学生 | ||
| 218 | + studentBean = userDao.getStudentWithCard(resultCard); | ||
| 219 | + break; | ||
| 220 | + case "3"://家长 | ||
| 221 | + break; | ||
| 228 | } | 222 | } | 
| 229 | - if (null == sendRecordBean) { | ||
| 230 | - sendRecordDao.saveFaceRecord(userId, deviceId, resultCard, userName, time, schoolName, | ||
| 231 | - faceUrl, schoolId, content,9, Integer.parseInt(userType),18,2); | ||
| 232 | - }else { | ||
| 233 | - sendRecordDao.updateFaceFailRecord(deviceId,faceUrl,resultCard,time,content,userId); | 223 | + if (null != studentBean) { | 
| 224 | + //用户ID | ||
| 225 | + String userId = studentBean.getUser_id(); | ||
| 226 | + //用户名称 | ||
| 227 | + String userName = studentBean.getName(); | ||
| 228 | + //所属学校 | ||
| 229 | + int schoolId = studentBean.getSchool_id(); | ||
| 230 | + String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); | ||
| 231 | + String schoolName = userDao.getSchoolName(studentBean.getSchool_id() + ""); | ||
| 232 | + List<SendRecordBean> sendRecordBeans = sendRecordDao.getRecordIsExit(deviceId,resultCard,userId); | ||
| 233 | + SendRecordBean sendRecordBean =null; | ||
| 234 | + if(sendRecordBeans.size()>0){ | ||
| 235 | + sendRecordBean = sendRecordBeans.get(0); | ||
| 236 | + } | ||
| 237 | + if (null == sendRecordBean) { | ||
| 238 | + sendRecordDao.saveFaceRecord(userId, deviceId, resultCard, userName, time, schoolName, | ||
| 239 | + faceUrl, schoolId, content,9, Integer.parseInt(userType),18,2); | ||
| 240 | + }else { | ||
| 241 | + sendRecordDao.updateFaceFailRecord(deviceId,faceUrl,resultCard,time,content,userId); | ||
| 242 | + } | ||
| 243 | + } else { | ||
| 244 | + log.error("用户不存在: 对应卡号: {}" + resultCard); | ||
| 234 | } | 245 | } | 
| 235 | - } else { | ||
| 236 | - log.error("用户不存在: 对应卡号{} ," + resultCard); | 246 | + }catch (Exception e){ | 
| 247 | + log.error("保存记录失败,异常信息:{}",e); | ||
| 237 | } | 248 | } | 
| 238 | } | 249 | } | 
| 239 | 250 | ||
| @@ -339,7 +350,7 @@ public class BaseService { | @@ -339,7 +350,7 @@ public class BaseService { | ||
| 339 | * @param card | 350 | * @param card | 
| 340 | * @return | 351 | * @return | 
| 341 | */ | 352 | */ | 
| 342 | - public String getCard(String card) { | 353 | + public static String getCard(String card) { | 
| 343 | if (card.length() == 8) { | 354 | if (card.length() == 8) { | 
| 344 | int length = card.length(); | 355 | int length = card.length(); | 
| 345 | String result = card.substring(length - 2, length) + card.substring(length - 4, length - 2) + card.substring(length - 6, length - 4) | 356 | String result = card.substring(length - 2, length) + card.substring(length - 4, length - 2) + card.substring(length - 6, length - 4) | 
| @@ -512,4 +523,220 @@ public class BaseService { | @@ -512,4 +523,220 @@ public class BaseService { | ||
| 512 | //插入百度人脸记录表 | 523 | //插入百度人脸记录表 | 
| 513 | userDao.insertBaiduFaceRecorder(baiduFaceRecorder); | 524 | userDao.insertBaiduFaceRecorder(baiduFaceRecorder); | 
| 514 | } | 525 | } | 
| 526 | + | ||
| 527 | + @Async | ||
| 528 | + public void sendUserFaceByAsyncThread(Integer schoolId,Integer userType,Integer studentType,String sex,List<String> deviceList){ | ||
| 529 | + List<String> deviceId_100 = new ArrayList<>(); | ||
| 530 | + List<String> deviceId_253 = new ArrayList<>(); | ||
| 531 | + //过滤设备 | ||
| 532 | + for (String sno : deviceList) { | ||
| 533 | + //若100服务器有此设备再进行多线程执行下发人脸任务,否则请求253服务执行单个下发人脸 | ||
| 534 | + if (cmsServer.getIsDeviceOnline(sno)) { | ||
| 535 | + deviceId_100.add(sno); | ||
| 536 | + }else{ | ||
| 537 | + deviceId_253.add(sno); | ||
| 538 | + } | ||
| 539 | + } | ||
| 540 | + //根据类型获取下发用户信息 | ||
| 541 | + List<StudentBean> studentBeanList = null; | ||
| 542 | + if (userType == EnumSzBusinessType.EnumUserType.TEACHER.code) { | ||
| 543 | + studentBeanList = getTeacherList(schoolId); | ||
| 544 | + } | ||
| 545 | + if (userType == EnumSzBusinessType.EnumUserType.STUDENT.code) { | ||
| 546 | + studentBeanList = getStudentList(schoolId,studentType,sex); | ||
| 547 | + } | ||
| 548 | + log.info("统计共有下发用户数量:"+studentBeanList.size()); | ||
| 549 | + if(deviceId_100.size()>0){ | ||
| 550 | + //100服务器 | ||
| 551 | + sendFaceToDevice100(deviceId_100,studentBeanList,String.valueOf(schoolId),userType); | ||
| 552 | + } | ||
| 553 | + if(deviceId_253.size()>0){ | ||
| 554 | + //253服务器 | ||
| 555 | + sendFaceToDevice253(deviceId_253,studentBeanList,String.valueOf(schoolId),userType); | ||
| 556 | + } | ||
| 557 | + } | ||
| 558 | + | ||
| 559 | + | ||
| 560 | + protected void sendFaceToDevice100(List<String> deviceIds,List<StudentBean> studentBeanList,String schoolId,Integer userType){ | ||
| 561 | + log.info("------------------------开始执行100服务,人脸照下发---------------------"); | ||
| 562 | +// //启用多线程执行 | ||
| 563 | +// CountDownLatch begin = new CountDownLatch(1); | ||
| 564 | +// CountDownLatch end = new CountDownLatch(deviceIds.size()); | ||
| 565 | +// ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat("thread-sendFace-runner-%d").build(); | ||
| 566 | +// ExecutorService exe = new ThreadPoolExecutor(4,8,0L, TimeUnit.MILLISECONDS,new LinkedBlockingQueue<Runnable>(),namedThreadFactory); | ||
| 567 | +// for(String sno : deviceIds){ | ||
| 568 | +// log.info("设备ID:"+ sno); | ||
| 569 | +// exe.execute(new SendFaceBatchTask100(schoolId,userType,sno,studentBeanList,FileUtils.getInstance(),sendUserAsync,begin,end)); | ||
| 570 | +// } | ||
| 571 | +// begin.countDown(); | ||
| 572 | +// try { | ||
| 573 | +// end.await(); | ||
| 574 | +// }catch (Exception e){ | ||
| 575 | +// log.error("下发人脸照失败"+e); | ||
| 576 | +// e.printStackTrace(); | ||
| 577 | +// } | ||
| 578 | +// exe.shutdown(); | ||
| 579 | +// System.out.println("统计100服务器总共有"+deviceIds.size()+"个设备,处理完毕"); | ||
| 580 | + String startTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); | ||
| 581 | + Calendar calendar = Calendar.getInstance(); | ||
| 582 | + calendar.add(Calendar.YEAR, 10); | ||
| 583 | + String endTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(calendar.getTime()); | ||
| 584 | + //下发标识:详情见枚举 EnumHkOperateType | ||
| 585 | + int validTimeEnabled = EnumSzBusinessType.EnumHkOperateType.ADD.code; | ||
| 586 | + for(StudentBean studentBean : studentBeanList){ | ||
| 587 | + try{ | ||
| 588 | + String userName= studentBean.getName(); | ||
| 589 | + String photo = userType.intValue()==1?studentBean.getFace():studentBean.getPhoto(); | ||
| 590 | + String cardNum =userType.intValue()==1?studentBean.getTeacher_num():studentBean.getStudent_num(); | ||
| 591 | + String typeName=userType.intValue()==1?"Teacher":"Student"; | ||
| 592 | + if (StringUtils.isBlank(photo) || StringUtils.isBlank(cardNum)){ | ||
| 593 | + continue; | ||
| 594 | + } | ||
| 595 | +// String path = "E:\\wwwhtdocs\\SmartCampus\\face17e50\\School" + schoolId + "\\" + typeName; | ||
| 596 | + String path = "D:\\haikangface\\School" + schoolId + "\\" + typeName; | ||
| 597 | + String filePath=""; | ||
| 598 | + if(photo.indexOf("f0i5l7e5")!=-1){ | ||
| 599 | + String afterStr = photo.split("f0i5l7e5/")[1].replace("/","\\"); | ||
| 600 | + filePath="E:\\wwwhtdocs\\SmartCampus\\f0i5l7e5\\" + afterStr; | ||
| 601 | + } else{ | ||
| 602 | + //以学籍号为名的文件名 | ||
| 603 | + String fileName = photo.split(typeName +"/")[1]; | ||
| 604 | + //100服务器上人脸照绝对路径 | ||
| 605 | + filePath = path+ "\\" + fileName; | ||
| 606 | + } | ||
| 607 | + log.info("卡号:{},人脸路径:{}, ",cardNum,filePath); | ||
| 608 | + File file = new File(filePath);//图片 | ||
| 609 | + if(file.exists()){ | ||
| 610 | + String targetPath = FileUtils.picPathComp + file.getName(); | ||
| 611 | + try { | ||
| 612 | + CompressPic.CompressPic(file.getAbsolutePath(), targetPath); | ||
| 613 | + } catch (Exception e) { | ||
| 614 | + log.error("压缩图片失败"); | ||
| 615 | + e.printStackTrace(); | ||
| 616 | + continue; | ||
| 617 | + } | ||
| 618 | + for(String sno : deviceIds){ | ||
| 619 | + if(cmsServer.getIsDeviceOnline(sno)){ | ||
| 620 | + if(!StringUtils.isBlank(cardNum)){ | ||
| 621 | + String cardNumLong = Long.parseLong(getCard(cardNum),16) + ""; | ||
| 622 | + //下发100海康设备 | ||
| 623 | + sendUserAsync.sendStuToHaiKang(file.getAbsolutePath(),targetPath,cardNumLong, startTime, endTime, validTimeEnabled, userName, sno, String.valueOf(userType),Integer.parseInt(schoolId),cardNum); | ||
| 624 | + } | ||
| 625 | + }else{ | ||
| 626 | + log.error("100服务器,设备不在线"); | ||
| 627 | + } | ||
| 628 | + | ||
| 629 | + } | ||
| 630 | + } | ||
| 631 | + }catch (Exception e){ | ||
| 632 | + log.error("人脸下发失败"); | ||
| 633 | + e.printStackTrace(); | ||
| 634 | + continue; | ||
| 635 | + } | ||
| 636 | + } | ||
| 637 | + } | ||
| 638 | + | ||
| 639 | + protected void sendFaceToDevice253(List<String> deviceIds,List<StudentBean> studentBeanList,String schoolId,Integer userType){ | ||
| 640 | + log.info("------------------------开始执行253服务,人脸照下发---------------------"); | ||
| 641 | +// //启用多线程执行 | ||
| 642 | +// CountDownLatch begin = new CountDownLatch(1); | ||
| 643 | +// CountDownLatch end = new CountDownLatch(deviceIds.size()); | ||
| 644 | +// ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat("thread-sendFace-runner-%d").build(); | ||
| 645 | +// ExecutorService exe = new ThreadPoolExecutor(8,8,0L, TimeUnit.MILLISECONDS,new LinkedBlockingQueue<Runnable>(),namedThreadFactory); | ||
| 646 | +// for(String sno : deviceIds){ | ||
| 647 | +// log.info("设备ID:"+ sno); | ||
| 648 | +// exe.execute(new SendFaceBatchTask253(schoolId,userType,sno,studentBeanList,sendUserAsync,begin,end)); | ||
| 649 | +// } | ||
| 650 | +// begin.countDown(); | ||
| 651 | +// try { | ||
| 652 | +// end.await(); | ||
| 653 | +// }catch (Exception e){ | ||
| 654 | +// log.error("下发人脸照失败"+e); | ||
| 655 | +// e.printStackTrace(); | ||
| 656 | +// } | ||
| 657 | +// exe.shutdown(); | ||
| 658 | +// System.out.println("统计253服务器总共有"+deviceIds.size()+"个设备,处理完毕"); | ||
| 659 | + String startTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); | ||
| 660 | + Calendar calendar = Calendar.getInstance(); | ||
| 661 | + calendar.add(Calendar.YEAR, 10); | ||
| 662 | + String endTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(calendar.getTime()); | ||
| 663 | + //下发标识:详情见枚举 EnumHkOperateType | ||
| 664 | + int validTimeEnabled = EnumSzBusinessType.EnumHkOperateType.ADD.code; | ||
| 665 | + for(StudentBean studentBean : studentBeanList){ | ||
| 666 | + try{ | ||
| 667 | + String userName= studentBean.getName(); | ||
| 668 | + String photo = userType.intValue()==1?studentBean.getFace():studentBean.getPhoto(); | ||
| 669 | + String cardNum =userType.intValue()==1?studentBean.getTeacher_num():studentBean.getStudent_num(); | ||
| 670 | + String typeName=userType.intValue()==1?"Teacher":"Student"; | ||
| 671 | + if (StringUtils.isBlank(photo) || StringUtils.isBlank(cardNum)){ | ||
| 672 | + continue; | ||
| 673 | + } | ||
| 674 | + String path = "E:\\wwwhtdocs\\SmartCampus\\face17e50\\School" + schoolId + "\\" + typeName; | ||
| 675 | + String filePath=""; | ||
| 676 | + if(photo.indexOf("f0i5l7e5")!=-1){ | ||
| 677 | + String afterStr = photo.split("f0i5l7e5/")[1].replace("/","\\"); | ||
| 678 | + filePath="E:\\wwwhtdocs\\SmartCampus\\f0i5l7e5\\" + afterStr; | ||
| 679 | + } else{ | ||
| 680 | + //以学籍号为名的文件名 | ||
| 681 | + String fileName = photo.split(typeName +"/")[1]; | ||
| 682 | + //100服务器上人脸照绝对路径 | ||
| 683 | + filePath = path+ "\\" + fileName; | ||
| 684 | + } | ||
| 685 | + log.info("卡号:{},人脸路径:{}, ",cardNum,filePath); | ||
| 686 | + for(String sno : deviceIds) { | ||
| 687 | + //下发253服务器 | ||
| 688 | + sendUserAsync.uploadImgs(filePath, cardNum, userName, sno, startTime, endTime, validTimeEnabled, String.valueOf(userType)); | ||
| 689 | + } | ||
| 690 | + }catch (Exception e){ | ||
| 691 | + log.error("人脸下发失败"); | ||
| 692 | + e.printStackTrace(); | ||
| 693 | + continue; | ||
| 694 | + } | ||
| 695 | + } | ||
| 696 | + } | ||
| 697 | + | ||
| 698 | + | ||
| 699 | + public List<String> getStudentCard(int schoolId, int studentType, String sex) { | ||
| 700 | + String[] msg = sex.split(","); | ||
| 701 | + List<Integer> list = new ArrayList<>(); | ||
| 702 | + for(String s : msg){ | ||
| 703 | + list.add(Integer.valueOf(s)); | ||
| 704 | + } | ||
| 705 | + return userDao.getStudentCard(schoolId,studentType, list); | ||
| 706 | + } | ||
| 707 | + | ||
| 708 | + /** | ||
| 709 | + * 获取学校下学生数据 | ||
| 710 | + * @param schoolId | ||
| 711 | + * @param studentType | ||
| 712 | + * @param sex | ||
| 713 | + * @return | ||
| 714 | + */ | ||
| 715 | + public List<StudentBean> getStudentList(Integer schoolId, Integer studentType, String sex) { | ||
| 716 | + List<Integer> list = new ArrayList<>(); | ||
| 717 | + if(StringUtils.isNotBlank(sex)){ | ||
| 718 | + String[] msg = sex.split(","); | ||
| 719 | + for(String s : msg){ | ||
| 720 | + list.add(Integer.valueOf(s)); | ||
| 721 | + } | ||
| 722 | + } | ||
| 723 | + List<StudentBean> students = userDao.getStudentList(schoolId,studentType,list); | ||
| 724 | + //去重重复数据 | ||
| 725 | + List<StudentBean> studentList = students.stream().collect(Collectors.collectingAndThen( | ||
| 726 | + Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(StudentBean::getStudent_num))), ArrayList::new)); | ||
| 727 | + return studentList; | ||
| 728 | + } | ||
| 729 | + | ||
| 730 | + /** | ||
| 731 | + * 获取学校下老师数据 | ||
| 732 | + * @param schoolId | ||
| 733 | + * @return | ||
| 734 | + */ | ||
| 735 | + public List<StudentBean> getTeacherList(Integer schoolId) { | ||
| 736 | + List<StudentBean> teachers = userDao.getTeacherList(schoolId); | ||
| 737 | + //去重重复数据 | ||
| 738 | + List<StudentBean> teacherist = teachers.stream().collect(Collectors.collectingAndThen( | ||
| 739 | + Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(StudentBean::getTeacher_num))), ArrayList::new)); | ||
| 740 | + return teacherist; | ||
| 741 | + } | ||
| 515 | } | 742 | } | 
cloud/haikangface/src/main/java/com/sincere/haikangface/service/impl/UserOperateServiceImpl.java
| 1 | package com.sincere.haikangface.service.impl; | 1 | package com.sincere.haikangface.service.impl; | 
| 2 | + | ||
| 3 | +import com.alibaba.fastjson.JSON; | ||
| 4 | +import com.fasterxml.jackson.databind.JavaType; | ||
| 2 | import com.sincere.haikangface.CMSServer; | 5 | import com.sincere.haikangface.CMSServer; | 
| 3 | import com.sincere.haikangface.async.SendUserAsync; | 6 | import com.sincere.haikangface.async.SendUserAsync; | 
| 4 | -import com.sincere.haikangface.bean.*; | 7 | +import com.sincere.haikangface.bean.Result; | 
| 8 | +import com.sincere.haikangface.bean.ResultGenerator; | ||
| 9 | +import com.sincere.haikangface.bean.SendRecordBean; | ||
| 10 | +import com.sincere.haikangface.bean.StudentBean; | ||
| 5 | import com.sincere.haikangface.bean.face.*; | 11 | import com.sincere.haikangface.bean.face.*; | 
| 12 | +import com.sincere.haikangface.control.UserControl; | ||
| 6 | import com.sincere.haikangface.dao.DeviceDao; | 13 | import com.sincere.haikangface.dao.DeviceDao; | 
| 7 | import com.sincere.haikangface.dao.UserDao; | 14 | import com.sincere.haikangface.dao.UserDao; | 
| 15 | +import com.sincere.haikangface.enums.EnumSzBusinessType; | ||
| 8 | import com.sincere.haikangface.service.UserOperateService; | 16 | import com.sincere.haikangface.service.UserOperateService; | 
| 9 | import com.sincere.haikangface.utils.*; | 17 | import com.sincere.haikangface.utils.*; | 
| 10 | import com.sincere.haikangface.xiananDao.SendRecordDao; | 18 | import com.sincere.haikangface.xiananDao.SendRecordDao; | 
| 11 | import lombok.extern.slf4j.Slf4j; | 19 | import lombok.extern.slf4j.Slf4j; | 
| 12 | import org.apache.commons.lang3.StringUtils; | 20 | import org.apache.commons.lang3.StringUtils; | 
| 13 | import org.springframework.beans.factory.annotation.Autowired; | 21 | import org.springframework.beans.factory.annotation.Autowired; | 
| 22 | +import org.springframework.scheduling.annotation.Async; | ||
| 14 | import org.springframework.stereotype.Service; | 23 | import org.springframework.stereotype.Service; | 
| 24 | + | ||
| 15 | import java.io.File; | 25 | import java.io.File; | 
| 26 | +import java.io.IOException; | ||
| 27 | +import java.text.SimpleDateFormat; | ||
| 16 | import java.util.*; | 28 | import java.util.*; | 
| 17 | 29 | ||
| 18 | /** | 30 | /** | 
| 19 | - * TODO | ||
| 20 | - * | ||
| 21 | - * @author Administrator | 31 | + * 海康设备用户操作业务实现 | 
| 32 | + * @author xuquan | ||
| 22 | * @date 2020/12/10 21:26 | 33 | * @date 2020/12/10 21:26 | 
| 23 | */ | 34 | */ | 
| 24 | @Slf4j | 35 | @Slf4j | 
| @@ -37,6 +48,8 @@ public class UserOperateServiceImpl implements UserOperateService { | @@ -37,6 +48,8 @@ public class UserOperateServiceImpl implements UserOperateService { | ||
| 37 | BaseService baseService; | 48 | BaseService baseService; | 
| 38 | @Autowired | 49 | @Autowired | 
| 39 | SendUserAsync sendUserAsync; | 50 | SendUserAsync sendUserAsync; | 
| 51 | + @Autowired | ||
| 52 | + UserControl userControl; | ||
| 40 | 53 | ||
| 41 | private static JsonUtils objectMapper = JsonUtils.nonEmptyMapper(); | 54 | private static JsonUtils objectMapper = JsonUtils.nonEmptyMapper(); | 
| 42 | 55 | ||
| @@ -45,18 +58,20 @@ public class UserOperateServiceImpl implements UserOperateService { | @@ -45,18 +58,20 @@ public class UserOperateServiceImpl implements UserOperateService { | ||
| 45 | try { | 58 | try { | 
| 46 | String sexStr = recordDto.getWeekDays().get(0).getSex(); | 59 | String sexStr = recordDto.getWeekDays().get(0).getSex(); | 
| 47 | //1学生类型,当为组时为群组iD | 60 | //1学生类型,当为组时为群组iD | 
| 48 | - int studentType = recordDto.getStudentType(); | 61 | + Integer studentType = recordDto.getStudentType(); | 
| 49 | //学校ID | 62 | //学校ID | 
| 50 | - int schoolId = recordDto.getSchoolId(); | 63 | + Integer schoolId = recordDto.getSchoolId(); | 
| 51 | //设备ID | 64 | //设备ID | 
| 52 | List<String> deviceIds = recordDto.getSnList(); | 65 | List<String> deviceIds = recordDto.getSnList(); | 
| 53 | //1 学生类型 2 学生组 | 66 | //1 学生类型 2 学生组 | 
| 54 | - int type = recordDto.getType(); | 67 | + Integer type = recordDto.getType(); | 
| 55 | //权限类型 | 68 | //权限类型 | 
| 56 | - int authType = recordDto.getAuthType(); | 69 | + Integer authType = recordDto.getAuthType(); | 
| 57 | //权限周计划 | 70 | //权限周计划 | 
| 58 | List<WeekDay> weekDay = recordDto.getWeekDays(); | 71 | List<WeekDay> weekDay = recordDto.getWeekDays(); | 
| 59 | String weekDayJson = objectMapper.toJson(weekDay); | 72 | String weekDayJson = objectMapper.toJson(weekDay); | 
| 73 | + //设备类型 | ||
| 74 | + Integer deviceType = userDao.getClintTypeByDeviceId(deviceIds.get(0)); | ||
| 60 | String deviceStr = ""; | 75 | String deviceStr = ""; | 
| 61 | for (String sn : deviceIds) { | 76 | for (String sn : deviceIds) { | 
| 62 | deviceStr += sn + ","; | 77 | deviceStr += sn + ","; | 
| @@ -65,16 +80,15 @@ public class UserOperateServiceImpl implements UserOperateService { | @@ -65,16 +80,15 @@ public class UserOperateServiceImpl implements UserOperateService { | ||
| 65 | Date end = DateUtils.string2Date("2030-01-01", DateUtils.format1); | 80 | Date end = DateUtils.string2Date("2030-01-01", DateUtils.format1); | 
| 66 | deviceStr = deviceStr.substring(0, deviceStr.length() - 1); | 81 | deviceStr = deviceStr.substring(0, deviceStr.length() - 1); | 
| 67 | //保存权限计划 | 82 | //保存权限计划 | 
| 68 | - saveDeviceAuth(schoolId, deviceStr, studentType, start, end, weekDayJson, sexStr, type, authType); | 83 | + saveDeviceAuth(schoolId, deviceStr, studentType, start, end, weekDayJson, sexStr, type, authType,deviceType); | 
| 69 | return true; | 84 | return true; | 
| 70 | } catch (Exception e) { | 85 | } catch (Exception e) { | 
| 71 | - e.printStackTrace(); | ||
| 72 | - log.error("创建权限失败"); | 86 | + log.error("创建权限失败,异常信息:{}",e); | 
| 73 | } | 87 | } | 
| 74 | return false; | 88 | return false; | 
| 75 | } | 89 | } | 
| 76 | 90 | ||
| 77 | - private void saveDeviceAuth(int schoolId, String sn, int studentType, Date start, Date end, String json, String sexStr, int type, int authType) { | 91 | + private void saveDeviceAuth(Integer schoolId, String sn, Integer studentType, Date start, Date end, String json, String sexStr, Integer type, Integer authType,Integer deviceType) { | 
| 78 | //设置权限信息 | 92 | //设置权限信息 | 
| 79 | DeviceAuthRecord record = new DeviceAuthRecord(); | 93 | DeviceAuthRecord record = new DeviceAuthRecord(); | 
| 80 | //学校ID | 94 | //学校ID | 
| @@ -89,8 +103,14 @@ public class UserOperateServiceImpl implements UserOperateService { | @@ -89,8 +103,14 @@ public class UserOperateServiceImpl implements UserOperateService { | ||
| 89 | record.setStudentType(studentType); | 103 | record.setStudentType(studentType); | 
| 90 | //性别 | 104 | //性别 | 
| 91 | record.setSex(sexStr); | 105 | record.setSex(sexStr); | 
| 92 | - //时段 | ||
| 93 | - record.setShiduan(null); | 106 | + if(deviceType.intValue()== 22 || deviceType.intValue()== 29){ | 
| 107 | + Integer shiduan = userDao.getAuthRecordBySchoolId(schoolId,studentType,null); | ||
| 108 | + //如果是大华一体机 | ||
| 109 | + record.setShiduan(shiduan!=null?shiduan+1+"":1+""); | ||
| 110 | + }else{ | ||
| 111 | + //时段 | ||
| 112 | + record.setShiduan(null); | ||
| 113 | + } | ||
| 94 | //计划状态1正常2停用 | 114 | //计划状态1正常2停用 | 
| 95 | record.setState(1); | 115 | record.setState(1); | 
| 96 | //计划下发状态1下发成功2下发失败3待下发 | 116 | //计划下发状态1下发成功2下发失败3待下发 | 
| @@ -103,6 +123,59 @@ public class UserOperateServiceImpl implements UserOperateService { | @@ -103,6 +123,59 @@ public class UserOperateServiceImpl implements UserOperateService { | ||
| 103 | record.setaType(type); | 123 | record.setaType(type); | 
| 104 | //插入权限记录表AC_DeviceAuthRecord | 124 | //插入权限记录表AC_DeviceAuthRecord | 
| 105 | userDao.insertAuthRecord(record); | 125 | userDao.insertAuthRecord(record); | 
| 126 | + log.info("创建权限周计划成功", JSON.toJSONString(record)); | ||
| 127 | + } | ||
| 128 | + | ||
| 129 | + @Override | ||
| 130 | + public Result sendHKAuth(Integer authId) { | ||
| 131 | + DeviceAuthRecord record = userDao.getAuthRecord(authId); | ||
| 132 | + if(record ==null){ | ||
| 133 | + log.info("未查询到对应权限ID: {}, 权限计划。",authId); | ||
| 134 | + return ResultGenerator.genFailResult("未查询到对应权限"); | ||
| 135 | + } | ||
| 136 | + //设备ID | ||
| 137 | + String[] deviceArr = record.getSno().split(","); | ||
| 138 | + List<String> devices= new ArrayList<>(Arrays.asList(deviceArr)); | ||
| 139 | + if(devices.size()<1){ | ||
| 140 | + return ResultGenerator.genFailResult("未选择下发设备"); | ||
| 141 | + } | ||
| 142 | + //学生类型 | ||
| 143 | + Integer studentType = record.getStudentType(); | ||
| 144 | + //周计划 | ||
| 145 | + String weekDaysJson = record.getWeekDays(); | ||
| 146 | + JavaType javaType = objectMapper.contructCollectionType(ArrayList.class, WeekDay.class); | ||
| 147 | + ArrayList<WeekDay> weekDayList = objectMapper.fromJson(weekDaysJson,javaType); | ||
| 148 | + //设备类型 | ||
| 149 | + Integer clintType = userDao.getClintTypeByDeviceId(devices.get(0)); | ||
| 150 | + if(clintType.intValue()== 22 || clintType.intValue()== 29){ | ||
| 151 | + PermissionDHBean dhBean = new PermissionDHBean(); | ||
| 152 | + dhBean.setWeekDays(weekDayList); | ||
| 153 | + dhBean.setDeviceIds(devices); | ||
| 154 | + dhBean.setChannel(record.getShiduan()); | ||
| 155 | + dhBean.setCustomName(EnumSzBusinessType.EnumStudentType.getByCode(studentType).code+""); | ||
| 156 | + dhBean.setStudentType(String.valueOf(studentType)); | ||
| 157 | + //发送大华设备 | ||
| 158 | + HttpUtil.sendDHPermission(dhBean); | ||
| 159 | + log.info("map{}", JSON.toJSONString(dhBean)); | ||
| 160 | + //更新计划位下发成功 | ||
| 161 | + userDao.updateAuthRecord(record.getId(),1); | ||
| 162 | + return ResultGenerator.genSuccessResult(); | ||
| 163 | + } | ||
| 164 | + if(clintType.intValue()== 18 || clintType.intValue()== 28){ | ||
| 165 | + PermissionBean permissionBean = new PermissionBean(); | ||
| 166 | + permissionBean.setWeekDays(weekDayList); | ||
| 167 | + permissionBean.setDeviceIds(devices); | ||
| 168 | + permissionBean.setSchoolId(String.valueOf(record.getSchoolId())); | ||
| 169 | + permissionBean.setUserType(String.valueOf(EnumSzBusinessType.EnumUserType.STUDENT.code)); | ||
| 170 | + if (!org.springframework.util.StringUtils.isEmpty(permissionBean.getDeviceIds())) { | ||
| 171 | + if(sendUserAsync.sendHKAuth(permissionBean,record.getId(),studentType)){ | ||
| 172 | + return ResultGenerator.genSuccessResult(); | ||
| 173 | + }else{ | ||
| 174 | + return ResultGenerator.genFailResult("下发权限失败"); | ||
| 175 | + } | ||
| 176 | + } | ||
| 177 | + } | ||
| 178 | + return ResultGenerator.genSuccessResult(); | ||
| 106 | } | 179 | } | 
| 107 | 180 | ||
| 108 | @Override | 181 | @Override | 
| @@ -149,8 +222,8 @@ public class UserOperateServiceImpl implements UserOperateService { | @@ -149,8 +222,8 @@ public class UserOperateServiceImpl implements UserOperateService { | ||
| 149 | File file = new File(filePath.trim()); | 222 | File file = new File(filePath.trim()); | 
| 150 | if (!file.exists()) { | 223 | if (!file.exists()) { | 
| 151 | log.error("文件不存在:" + filePath); | 224 | log.error("文件不存在:" + filePath); | 
| 152 | - String card = Long.parseLong(baseService.getCard(cardNum), 16)+""; | ||
| 153 | - baseService.sendFailRecord(card, filePath, deviceId, "文件不存在", String.valueOf(userType)); | 225 | +// String card = Long.parseLong(baseService.getCard(cardNum), 16)+""; | 
| 226 | + baseService.sendFailRecord(cardNum, filePath, deviceId, "文件不存在", String.valueOf(userType)); | ||
| 154 | return ResultGenerator.genFailResult("文件不存在"); | 227 | return ResultGenerator.genFailResult("文件不存在"); | 
| 155 | } | 228 | } | 
| 156 | //设备类型 | 229 | //设备类型 | 
| @@ -170,7 +243,7 @@ public class UserOperateServiceImpl implements UserOperateService { | @@ -170,7 +243,7 @@ public class UserOperateServiceImpl implements UserOperateService { | ||
| 170 | } catch (Exception e) { | 243 | } catch (Exception e) { | 
| 171 | log.error("图片压缩失败"); | 244 | log.error("图片压缩失败"); | 
| 172 | } | 245 | } | 
| 173 | - boolean isOk = baseService.sendImg(photo, targetPath, deviceId, cardNum, userName, String.valueOf(userType), schoolId); | 246 | + boolean isOk = baseService.sendImg(file.getAbsolutePath(), targetPath, deviceId, cardNum, userName, String.valueOf(userType), schoolId); | 
| 174 | if (isOk) { | 247 | if (isOk) { | 
| 175 | return ResultGenerator.genSuccessResult(); | 248 | return ResultGenerator.genSuccessResult(); | 
| 176 | } else { | 249 | } else { | 
| @@ -217,10 +290,10 @@ public class UserOperateServiceImpl implements UserOperateService { | @@ -217,10 +290,10 @@ public class UserOperateServiceImpl implements UserOperateService { | ||
| 217 | //设备类型 | 290 | //设备类型 | 
| 218 | Integer clintType = userDao.getClintTypeByDeviceId(idLists.get(0)); | 291 | Integer clintType = userDao.getClintTypeByDeviceId(idLists.get(0)); | 
| 219 | if(clintType.intValue()== 22 || clintType.intValue()== 29){ | 292 | if(clintType.intValue()== 22 || clintType.intValue()== 29){ | 
| 220 | - sendUserAsync.uploadDHImg(schoolId,userType,deviceIds); | 293 | + HttpUtil.uploadDHImg(schoolId,userType,deviceIds); | 
| 221 | } | 294 | } | 
| 222 | if(clintType.intValue()== 18 || clintType.intValue()== 28){ | 295 | if(clintType.intValue()== 18 || clintType.intValue()== 28){ | 
| 223 | - sendUserAsync.uploadHkImg(schoolId,userType,deviceIds); | 296 | + HttpUtil.uploadHkImg(schoolId,userType,deviceIds); | 
| 224 | } | 297 | } | 
| 225 | int fileSize = filesStudent.length; | 298 | int fileSize = filesStudent.length; | 
| 226 | int clintNum = deviceArr.length; | 299 | int clintNum = deviceArr.length; | 
| @@ -238,260 +311,283 @@ public class UserOperateServiceImpl implements UserOperateService { | @@ -238,260 +311,283 @@ public class UserOperateServiceImpl implements UserOperateService { | ||
| 238 | return ResultGenerator.genFailResult("下发失败"); | 311 | return ResultGenerator.genFailResult("下发失败"); | 
| 239 | } | 312 | } | 
| 240 | } | 313 | } | 
| 241 | -} | ||
| 242 | 314 | ||
| 243 | -// p }ublic boolean sendPermiss2(PermissionBean permissionBean, int i) { | ||
| 244 | -// return sendImg(filePath, targetPath, deviceId, card, name, userType); String userType = permissionBean.getUserType(); | ||
| 245 | -// String schoolId = permissionBean.getSchoolId(); | ||
| 246 | -// //设备ID,多设备户英文逗号,隔开 | ||
| 247 | -// List<String> deviceIds = permissionBean.getDeviceIds(); | ||
| 248 | -// //用户iD,批量用户英文逗号,隔开 | ||
| 249 | -// String userIds = permissionBean.getUserIds(); | ||
| 250 | -// String[] userIdsStr = userIds.split(","); | ||
| 251 | -// | ||
| 252 | -// List<String> cardNumList = new ArrayList<>(); | ||
| 253 | -// if (Integer.parseInt(userType) == EnumSzBusinessType.EnumUserType.TEACHER.code) { | ||
| 254 | -// List<String> cardList = getUserCard(userIds,EnumSzBusinessType.EnumUserType.TEACHER.code); | ||
| 255 | -// cardNumList.addAll(cardList); | ||
| 256 | -// } | ||
| 257 | -// if (Integer.parseInt(userType) == EnumSzBusinessType.EnumUserType.STUDENT.code) { | ||
| 258 | -// for (String userId : userIdsStr) { | ||
| 259 | -// String cardNum = userDao.getStudentCardWithUserId(schoolId,userId); | ||
| 260 | -// cardNumList.add(cardNum); | ||
| 261 | -// } | ||
| 262 | -// } | ||
| 263 | -// //权限周计划 | ||
| 264 | -// List<WeekDay> weekDays = permissionBean.getWeekDays(); | ||
| 265 | -// //存储周计划时段 | ||
| 266 | -// Map<Integer, List<WeekTime>> map = new HashMap<>(); | ||
| 267 | -// for (WeekDay weekDay : weekDays) { | ||
| 268 | -// //整理周和时间段 | ||
| 269 | -// initWeedayAndTimes(weekDay, map); | ||
| 270 | -// senPsermiss(permissionBean, map, deviceIds, cardNumList, i); | ||
| 271 | -// } | ||
| 272 | -// log.error("map{}", JSON.toJSONString(map)); | ||
| 273 | -// return true; | ||
| 274 | -// } | 315 | + @Override | 
| 316 | + public Result sendUserFaceByThread(SendFaceDto sendFaceDto) { | ||
| 317 | + //下发设备集合 | ||
| 318 | + String[] deviceArr = sendFaceDto.getsNos().split(","); | ||
| 319 | + List<String> deviceList= new ArrayList<>(Arrays.asList(deviceArr)); | ||
| 320 | + if(deviceList.size()<1){ | ||
| 321 | + return ResultGenerator.genFailResult("未选择下发设备"); | ||
| 322 | + } | ||
| 323 | + Integer schoolId = sendFaceDto.getSchoolId(); | ||
| 324 | + Integer studentType = sendFaceDto.getStudentType(); | ||
| 325 | + String sex = sendFaceDto.getSex(); | ||
| 326 | + Integer userType = null; | ||
| 327 | + if(sendFaceDto.getType().intValue()==0 || sendFaceDto.getType().intValue()==1){ | ||
| 328 | + userType = 2; | ||
| 329 | + }else{ | ||
| 330 | + userType = 1; | ||
| 331 | + } | ||
| 332 | + //设备类型 | ||
| 333 | + Integer clintType = userDao.getClintTypeByDeviceId(deviceList.get(0)); | ||
| 334 | + if(clintType.intValue()== 22 || clintType.intValue()== 29){ | ||
| 335 | + //发送大华设备 | ||
| 336 | + HttpUtil.uploadDHImg(String.valueOf(schoolId),userType,sendFaceDto.getsNos()); | ||
| 337 | + } | ||
| 338 | + if(clintType.intValue()== 18 || clintType.intValue()== 28){ | ||
| 339 | + //发送海康设备 | ||
| 340 | + baseService.sendUserFaceByAsyncThread(schoolId,userType,studentType,sex,deviceList); | ||
| 341 | + } | ||
| 342 | + return ResultGenerator.genSuccessResult(); | ||
| 343 | + } | ||
| 344 | + | ||
| 345 | + @Override | ||
| 346 | + public Result deleteFailFace(Integer schoolId) { | ||
| 347 | + if(schoolId ==null){ | ||
| 348 | + return ResultGenerator.genFailResult("删除失败人脸,学校ID不能为空"); | ||
| 349 | + } | ||
| 350 | + List<SendRecordBean> recordBeanList = sendRecordDao.getFailRecord(schoolId); | ||
| 351 | + if(recordBeanList.size()>0){ | ||
| 352 | + for(SendRecordBean recordBean : recordBeanList){ | ||
| 353 | + try{ | ||
| 354 | + //人脸卡号 | ||
| 355 | + String cardNum = recordBean.getNum(); | ||
| 356 | + //设备ID、设备类型 | ||
| 357 | + String deviceId = recordBean.getDeviceID(); | ||
| 358 | + Integer clintType = userDao.getClintTypeByDeviceId(deviceId); | ||
| 359 | + //删除海康人脸 | ||
| 360 | + if(clintType.intValue()== 18 || clintType.intValue()== 28){ | ||
| 361 | + if (cmsServer.getIsDeviceOnline(deviceId)) { | ||
| 362 | + String cardNo = Long.parseLong(baseService.getCard(cardNum),16) + ""; | ||
| 363 | + cmsServer.deleteCard(deviceId, cardNo,schoolId); | ||
| 364 | + }else{ | ||
| 365 | + //不在线,去253服务器上删除 | ||
| 366 | + HttpUtil.deleteCard(deviceId, cardNum); | ||
| 367 | + } | ||
| 368 | + } | ||
| 369 | + //删除大华人脸 | ||
| 370 | + if(clintType.intValue()== 22 || clintType.intValue()== 29){ | ||
| 371 | + HttpUtil.deleteDHFace(schoolId,cardNum,deviceId); | ||
| 372 | + } | ||
| 373 | + }catch (Exception e){ | ||
| 374 | + log.error("删除失败人脸失败,异常信息:{}",e); | ||
| 375 | + continue; | ||
| 376 | + } | ||
| 377 | + } | ||
| 378 | + } | ||
| 379 | + return ResultGenerator.genSuccessResult(); | ||
| 380 | + } | ||
| 381 | + | ||
| 382 | + @Override | ||
| 383 | + public Result sendFailFace(Integer schoolId) { | ||
| 384 | + if(schoolId ==null){ | ||
| 385 | + return ResultGenerator.genFailResult("删除失败人脸,学校ID不能为空"); | ||
| 386 | + } | ||
| 387 | + List<SendRecordBean> recordBeanList = sendRecordDao.getFailRecord(schoolId); | ||
| 388 | + if(recordBeanList.size()>0){ | ||
| 389 | + for(SendRecordBean recordBean : recordBeanList){ | ||
| 390 | + try{ | ||
| 391 | + //用户类型1老师2学生 | ||
| 392 | + int userType = recordBean.getUserType(); | ||
| 393 | + //人脸卡号 | ||
| 394 | + String cardNum = recordBean.getNum(); | ||
| 395 | + //设备ID、设备类型 | ||
| 396 | + String deviceId = recordBean.getDeviceID(); | ||
| 397 | + Integer clintType = userDao.getClintTypeByDeviceId(deviceId); | ||
| 398 | + //2.重新下发 | ||
| 399 | + StudentBean studentBean= null; | ||
| 400 | + String typeName =""; | ||
| 401 | + if(userType ==1){ | ||
| 402 | + typeName= "Teacher"; | ||
| 403 | + studentBean = userDao.getTeacherWithCard(cardNum); | ||
| 404 | + }else{ | ||
| 405 | + typeName= "Student"; | ||
| 406 | + studentBean= userDao.getStudentWithCard(cardNum); | ||
| 407 | + } | ||
| 408 | + if(studentBean==null){ | ||
| 409 | + continue; | ||
| 410 | + } | ||
| 411 | + String studentCode = studentBean.getStudentCode(); | ||
| 412 | + String filePath=""; | ||
| 413 | + //下发海康人脸 | ||
| 414 | + if(clintType.intValue()== 18 || clintType.intValue()== 28){ | ||
| 415 | + //1.先删除人脸 | ||
| 416 | + if (cmsServer.getIsDeviceOnline(deviceId)) { | ||
| 417 | + String cardNo = Long.parseLong(baseService.getCard(cardNum),16) + ""; | ||
| 418 | + cmsServer.deleteCard(deviceId, cardNo,schoolId); | ||
| 419 | + }else{ | ||
| 420 | + //不在线,去253服务器上删除 | ||
| 421 | + HttpUtil.deleteCard(deviceId, cardNum); | ||
| 422 | + } | ||
| 423 | + //100服务器文件目录绝对路径 | ||
| 424 | + String path = "E:\\wwwhtdocs\\SmartCampus\\face17e50\\School" + schoolId + "\\" + typeName; | ||
| 425 | + String photo= userType==1?studentBean.getFace():studentBean.getPhoto(); | ||
| 426 | + if (StringUtils.isBlank(photo)){ | ||
| 427 | + continue; | ||
| 428 | + } | ||
| 429 | + if(photo.indexOf("f0i5l7e5")!=-1){ | ||
| 430 | + String afterStr = photo.split("f0i5l7e5/")[1].replace("/","\\"); | ||
| 431 | + filePath="E:\\wwwhtdocs\\SmartCampus\\f0i5l7e5\\" + afterStr; | ||
| 432 | + } else{ | ||
| 433 | + //以学籍号为名的文件名 | ||
| 434 | + String fileName = photo.split(typeName +"/")[1]; | ||
| 435 | + //100服务器上人脸照绝对路径 | ||
| 436 | + filePath = path+ "\\" + fileName; | ||
| 437 | + } | ||
| 438 | + log.info("卡号:{},人脸路径:{}, ",cardNum, filePath); | ||
| 439 | + File file = new File(filePath);//图片 | ||
| 440 | + String targetPath = FileUtils.picPathComp + file.getName(); | ||
| 441 | + try { | ||
| 442 | + CompressPic.CompressPic(file.getAbsolutePath(), targetPath); | ||
| 443 | + } catch (IOException e) { | ||
| 444 | + log.error("图片压缩失败",e); | ||
| 445 | + continue; | ||
| 446 | + } | ||
| 447 | + String userName= studentBean.getName(); | ||
| 448 | + baseService.sendImg(file.getAbsolutePath(), targetPath, deviceId, cardNum, userName, String.valueOf(userType), schoolId); | ||
| 449 | + } | ||
| 450 | + //下发大华人脸 | ||
| 451 | + if(clintType.intValue()== 22 || clintType.intValue()== 29){ | ||
| 452 | + HttpUtil.uploadDHImgForOne(filePath,schoolId,studentCode,clintType,deviceId); | ||
| 453 | + } | ||
| 454 | + }catch (Exception e){ | ||
| 455 | + log.error("下发失败表人脸失败,异常信息:{}",e); | ||
| 456 | + continue; | ||
| 457 | + } | ||
| 458 | + } | ||
| 459 | + } | ||
| 460 | + return ResultGenerator.genSuccessResult(); | ||
| 461 | + } | ||
| 275 | 462 | ||
| 276 | -// | ||
| 277 | -// // @Override | ||
| 278 | -//// public boolean sendUserPermission(PermissionBean permissionBean) { | ||
| 279 | -//// //设备ID,多设备户英文逗号,隔开 | ||
| 280 | -//// List<String> deviceIds = permissionBean.getDeviceIds(); | ||
| 281 | -//// if ((CollectionUtils.isEmpty(deviceIds))) { | ||
| 282 | -//// log.error("下发权限,设备ID为空"); | ||
| 283 | -//// return false; | ||
| 284 | -//// } | ||
| 285 | -//// //用户类型 | ||
| 286 | -//// String userType = permissionBean.getUserType(); | ||
| 287 | -//// //学校ID | ||
| 288 | -//// String schoolId = permissionBean.getSchoolId(); | ||
| 289 | -//// | ||
| 290 | -//// //用户iD,批量用户英文逗号,隔开 | ||
| 291 | -//// String userIds = permissionBean.getUserIds(); | ||
| 292 | -//// String[] userIdsStr = userIds.split(","); | ||
| 293 | -//// | ||
| 294 | -//// List<String> cardNumList = new ArrayList<>(); | ||
| 295 | -//// if (Integer.parseInt(userType) == EnumSzBusinessType.EnumUserType.TEACHER.code) { | ||
| 296 | -//// List<String> cardList = getTeacherUserNum(userIds,EnumSzBusinessType.EnumUserType.TEACHER.code); | ||
| 297 | -//// cardNumList.addAll(cardList); | ||
| 298 | -//// } | ||
| 299 | -//// if (Integer.parseInt(userType) == EnumSzBusinessType.EnumUserType.STUDENT.code) { | ||
| 300 | -//// for (String userId : userIdsStr) { | ||
| 301 | -//// String cardNum = userDao.getStudentCardWithUserId(schoolId,userId); | ||
| 302 | -//// if(StringUtils.isNotBlank(cardNum)){ | ||
| 303 | -//// cardNumList.add(cardNum); | ||
| 304 | -//// } | ||
| 305 | -//// } | ||
| 306 | -//// } | ||
| 307 | -//// for(String deviceId : deviceIds){ | ||
| 308 | -//// //权限周计划 | ||
| 309 | -//// List<WeekDay> weekDays = permissionBean.getWeekDays(); | ||
| 310 | -//// //存储周计划时段 | ||
| 311 | -//// Map<Integer, List<WeekTime>> map = new HashMap<>(); | ||
| 312 | -//// for (WeekDay weekDay : weekDays) { | ||
| 313 | -//// //整理周和时间段 | ||
| 314 | -//// initWeedayAndTimes(weekDay, map); | ||
| 315 | -//// //下发权限 | ||
| 316 | -//// cmsServer.(permissionBean, map, cardNumList,deviceId); | ||
| 317 | -//// } | ||
| 318 | -//// log.info("map{}", JSON.toJSONString(map)); | ||
| 319 | -//// } | ||
| 320 | -//// return true; | ||
| 321 | -//// } | ||
| 322 | -//// | ||
| 323 | -//// /** | ||
| 324 | -//// * 整理时间 | ||
| 325 | -//// * @param weekDay | ||
| 326 | -//// * @param map | ||
| 327 | -//// */ | ||
| 328 | -//// private void initWeedayAndTimes(WeekDay weekDay, Map<Integer, List<WeekTime>> map) { | ||
| 329 | -//// | ||
| 330 | -//// String weekDayStr = weekDay.getWeekDay(); | ||
| 331 | -//// String[] weekDays = weekDayStr.split(","); | ||
| 332 | -//// | ||
| 333 | -//// List<WeekTime> weekTimes = weekDay.getWeekTimes(); | ||
| 334 | -//// | ||
| 335 | -//// for (int i = 0; i < weekDays.length; i++) { | ||
| 336 | -//// int weekDayIndex = Integer.parseInt(weekDays[i]); | ||
| 337 | -//// if (map.containsKey(weekDayIndex)) {//周已经有时间段 | ||
| 338 | -//// List<WeekTime> weekTimeList = map.get(weekDayIndex); | ||
| 339 | -//// for (WeekTime wee : weekTimes) { | ||
| 340 | -//// weekTimeList.add(wee); | ||
| 341 | -//// } | ||
| 342 | -//// map.put(weekDayIndex, weekTimeList); | ||
| 343 | -//// } else { | ||
| 344 | -//// List<WeekTime> weekTimes1 = new ArrayList<>(); | ||
| 345 | -//// weekTimes1.addAll(weekTimes); | ||
| 346 | -//// map.put(weekDayIndex, weekTimes1); | ||
| 347 | -//// } | ||
| 348 | -//// } | ||
| 349 | -//// | ||
| 350 | -//// } | ||
| 351 | -//// | ||
| 352 | -//// /** | ||
| 353 | -//// * | ||
| 354 | -//// * @param userIds | ||
| 355 | -//// * @param userType | ||
| 356 | -//// * @return | ||
| 357 | -//// */ | ||
| 358 | -//// private List<String> getTeacherUserNum(String userIds, int userType) { | ||
| 359 | -//// List<String> cards = new ArrayList<>(); | ||
| 360 | -//// try { | ||
| 361 | -//// String[] userIdsStr = userIds.split(","); | ||
| 362 | -//// for (String userId : userIdsStr) { | ||
| 363 | -//// TeacherBean teacherBean = null; | ||
| 364 | -//// if (userType == EnumSzBusinessType.EnumUserType.TEACHER.code) {//教师 | ||
| 365 | -//// teacherBean = userDao.getTeacherWithUserId(userId); | ||
| 366 | -//// if (null != teacherBean) { | ||
| 367 | -//// String card = teacherBean.getTeacer_num(); | ||
| 368 | -//// if (!StringUtils.isEmpty(card)) { | ||
| 369 | -//// cards.add(card); | ||
| 370 | -//// } | ||
| 371 | -//// } else { | ||
| 372 | -//// log.error("教师用户不存在"); | ||
| 373 | -//// } | ||
| 374 | -//// } | ||
| 375 | -//// } | ||
| 376 | -//// | ||
| 377 | -//// } catch (Exception e) { | ||
| 378 | -//// e.printStackTrace(); | ||
| 379 | -//// } | ||
| 380 | -//// return cards; | ||
| 381 | -//// } | ||
| 382 | -//// | ||
| 383 | -//// /** | ||
| 384 | -//// * 把卡号和权限下发到对应的设备 | ||
| 385 | -//// * | ||
| 386 | -//// * @param permissionBean | ||
| 387 | -//// * @param map | ||
| 388 | -//// * @param cardNumList | ||
| 389 | -//// * @return | ||
| 390 | -//// */ | ||
| 391 | -//// private boolean sendPermission(PermissionBean permissionBean, Map<Integer, List<WeekTime>> map,List<String> cardNumList,String deviceId) { | ||
| 392 | -//// String userType = permissionBean.getUserType(); | ||
| 393 | -//// if (null == cardNumList || cardNumList.size() == 0) { | ||
| 394 | -//// log.error("卡号为空"); | ||
| 395 | -//// return false; | ||
| 396 | -//// } | ||
| 397 | -//// //设备在线 | ||
| 398 | -//// boolean onLine = cmsServer.getIsDeviceOnline(deviceId); | ||
| 399 | -//// if (onLine) { | ||
| 400 | -//// for (String cardNum : cardNumList) { | ||
| 401 | -//// //卡号取反 | ||
| 402 | -//// String newCardNum = getCardNo(cardNum); | ||
| 403 | -//// if (StringUtils.isBlank(newCardNum)) { | ||
| 404 | -//// continue; | ||
| 405 | -//// } | ||
| 406 | -//// //获取十进制卡 | ||
| 407 | -//// newCardNum = String.valueOf(NumConvertUtil.hex16To10(newCardNum)); | ||
| 408 | -//// //设置卡权限计划模板 | ||
| 409 | -//// if(cmsServer.SetCardWeekPlan(deviceId, HKXmlUtils.getInstance().SetCardTemplate())){ | ||
| 410 | -//// log.info("设置卡权限计划模板成功,成功卡号: {},设备ID: {},用户类型:{}",cardNum,deviceId,userType); | ||
| 411 | -//// }else{ | ||
| 412 | -//// log.error("设置卡权限计划模板失败,失败卡号: {},设备ID: {},用户类型:{}",cardNum,deviceId,userType); | ||
| 413 | -//// } | ||
| 414 | -//// //设置卡权限周计划 | ||
| 415 | -//// if(cmsServer.SetCardWeekPlan(deviceId, HKXmlUtils.getInstance().SetCardWeekPlan())){ | ||
| 416 | -//// log.info("设置卡权限周计划成功,成功卡号: {},设备ID: {},用户类型:{}",cardNum,deviceId,userType); | ||
| 417 | -//// }else{ | ||
| 418 | -//// log.error("设置卡权限周计划失败,失败卡号: {},设备ID: {},用户类型:{}",cardNum,deviceId,userType); | ||
| 419 | -//// } | ||
| 420 | -//// for (Map.Entry<Integer, List<WeekTime>> weeKdayMap : map.entrySet()) { | ||
| 421 | -//// int week = weeKdayMap.getKey(); | ||
| 422 | -//// List<WeekTime> weekTimes = weeKdayMap.getValue(); | ||
| 423 | -//// | ||
| 424 | -//// StringBuffer stringBuffer = new StringBuffer(); | ||
| 425 | -//// for (WeekTime weekTime : weekTimes) { | ||
| 426 | -//// //周计化时间段 | ||
| 427 | -//// String weekPlanTimes = HKXmlUtils.getInstance().SetCardWeekPlanTimes(weekTime.getStartTime(), weekTime.getEndTime()); | ||
| 428 | -//// stringBuffer.append(weekPlanTimes); | ||
| 429 | -//// } | ||
| 430 | -//// //卡权限周计划时间段 | ||
| 431 | -//// String weekPlanTime = HKXmlUtils.getInstance().SetCardWeekPlanTime(stringBuffer.toString(), "" + week); | ||
| 432 | -//// FileUtils.getInstance().writeLogs(weekPlanTime, "设置卡权限周计划时间.txt"); | ||
| 433 | -//// //设置卡权限 | ||
| 434 | -//// String serCardRightCfg = HKXmlUtils.getInstance().SetCardRightCfg(newCardNum); | ||
| 435 | -//// //设置卡权限周计划 | ||
| 436 | -//// if(cmsServer.SetCardWeekPlan(deviceId, weekPlanTime)){ | ||
| 437 | -//// log.info("设置卡权限计划模板成功,成功卡号: {},设备ID: {},用户类型:{}",cardNum,deviceId,userType); | ||
| 438 | -//// }else{ | ||
| 439 | -//// log.error("设置卡权限计划模板失败,失败卡号: {},设备ID: {},用户类型:{}",cardNum,deviceId,userType); | ||
| 440 | -//// } | ||
| 441 | -//// if(cmsServer.SetCardWeekPlan(deviceId, serCardRightCfg)){ | ||
| 442 | -//// log.info("设置卡权限周计划成功,成功卡号: {},设备ID: {},用户类型:{}",cardNum,deviceId,userType); | ||
| 443 | -//// }else{ | ||
| 444 | -//// log.error("设置卡权限周计划失败,失败卡号: {},设备ID: {},用户类型:{}",cardNum,deviceId,userType); | ||
| 445 | -//// } | ||
| 446 | -//// } | ||
| 447 | -//// } | ||
| 448 | -//// } else { | ||
| 449 | -//// //设备不在线 | ||
| 450 | -//// log.warn("设备: {},不在线.前往253服务器下发", deviceId); | ||
| 451 | -//// HttpUtil.sendPermission2HK(permissionBean); | ||
| 452 | -//// } | ||
| 453 | -//// return true; | ||
| 454 | -//// } | ||
| 455 | -//// | ||
| 456 | -//// | ||
| 457 | -//// /** | ||
| 458 | -//// * 卡号两两取反 | ||
| 459 | -//// * | ||
| 460 | -//// * @param cardDex | ||
| 461 | -//// * @return | ||
| 462 | -//// */ | ||
| 463 | -//// public static String getCardNo(String cardDex) { | ||
| 464 | -//// String cardR = ""; | ||
| 465 | -//// int length = cardDex.length(); | ||
| 466 | -//// if (length != 8) { | ||
| 467 | -//// log.error("卡号格式不正确: 位数有误" + cardDex); | ||
| 468 | -//// return cardDex; | ||
| 469 | -//// } | ||
| 470 | -//// while (length > 0) { | ||
| 471 | -//// length -= 2; | ||
| 472 | -//// cardR += cardDex.substring(length, length + 2); | ||
| 473 | -//// } | ||
| 474 | -//// return cardR; | ||
| 475 | -//// } | ||
| 476 | -//// | ||
| 477 | -//// @Override | ||
| 478 | -//// public boolean sendUserFace(String filePath, String schoolId,String userId, int userType, String deviceId) { | ||
| 479 | -//// File file = new File(filePath); | ||
| 480 | -//// if(file ==null){ | ||
| 481 | -//// log.error("用户人脸不存在"); | ||
| 482 | -//// sendRecoderUtils.sendFail(sendRecordDao, Long.parseLong(getCard(card), 16) + "", filePath, deviceId, userDao, "文件不存在", userType); | ||
| 483 | -//// return false; | ||
| 484 | -//// } | ||
| 485 | -//// String cardNum = userDao.getStudentCardWithUserId(schoolId,userId); | ||
| 486 | -//// String fileName = file.getName(); | ||
| 487 | -//// //文件相对路径 | ||
| 488 | -//// String targetPath = FileUtils.picPathComp + fileName; | ||
| 489 | -//// try { | ||
| 490 | -//// CompressPic.CompressPic(filePath, targetPath); | ||
| 491 | -//// } catch (Exception e) { | ||
| 492 | -//// log.error("人脸图片压缩失败.",e.getMessage()); | ||
| 493 | -//// return false; | ||
| 494 | -//// } | ||
| 495 | -//// return sendImg(filePath, targetPath, deviceId, card, name, userType); | ||
| 496 | -//// } | ||
| 497 | -//} | 463 | + @Override | 
| 464 | + public Result deleteFace(Integer schoolId,String cards,String deviceIds) { | ||
| 465 | + if(StringUtils.isBlank(cards)){ | ||
| 466 | + return ResultGenerator.genFailResult("删除人脸卡号"); | ||
| 467 | + } | ||
| 468 | + String[] cardArr = cards.split(","); | ||
| 469 | + List<String> cardList= new ArrayList<>(Arrays.asList(cardArr)); | ||
| 470 | + for(String card : cardList){ | ||
| 471 | + if(StringUtils.isNotBlank(deviceIds)){ | ||
| 472 | + //设备集合 | ||
| 473 | + String[] deviceArr = deviceIds.split(","); | ||
| 474 | + List<String> deviceList= new ArrayList<>(Arrays.asList(deviceArr)); | ||
| 475 | + for(String sno : deviceList){ | ||
| 476 | + try{ | ||
| 477 | + //设备类型 | ||
| 478 | + Integer clintType = userDao.getClintTypeByDeviceId(sno); | ||
| 479 | + if(clintType.intValue()== 18 || clintType.intValue()== 28){ | ||
| 480 | + //删除海康设备人脸 | ||
| 481 | + if (cmsServer.getIsDeviceOnline(sno)) { | ||
| 482 | + String cardNo = Long.parseLong(baseService.getCard(card),16) + ""; | ||
| 483 | + cmsServer.deleteCard(sno, cardNo,schoolId); | ||
| 484 | + }else{ | ||
| 485 | + HttpUtil.deleteCard(sno, card); | ||
| 486 | + } | ||
| 487 | + } | ||
| 488 | + if(clintType.intValue()== 22 || clintType.intValue()== 29){ | ||
| 489 | + //删除大华设备人脸 | ||
| 490 | + HttpUtil.deleteDHFace(schoolId,card,sno); | ||
| 491 | + } | ||
| 492 | + }catch (Exception e){ | ||
| 493 | + log.error("删除人脸失败,异常信息:{}",e); | ||
| 494 | + continue; | ||
| 495 | + } | ||
| 496 | + } | ||
| 497 | + }else{ | ||
| 498 | + List<String> clintIds = userDao.getDeviceIds(schoolId,null); | ||
| 499 | + if(clintIds.size()>0){ | ||
| 500 | + for(String sno : clintIds){ | ||
| 501 | + try{ | ||
| 502 | + //设备类型 | ||
| 503 | + Integer clintType = userDao.getClintTypeByDeviceId(sno); | ||
| 504 | + if(clintType.intValue()== 18 || clintType.intValue()== 28){ | ||
| 505 | + //删除海康设备人脸 | ||
| 506 | + if (cmsServer.getIsDeviceOnline(sno)) { | ||
| 507 | + String cardNo = Long.parseLong(baseService.getCard(card),16) + ""; | ||
| 508 | + cmsServer.deleteCard(sno, cardNo,schoolId); | ||
| 509 | + }else{ | ||
| 510 | + HttpUtil.deleteCard(sno, card); | ||
| 511 | + } | ||
| 512 | + } | ||
| 513 | + if(clintType.intValue()== 22 || clintType.intValue()== 29){ | ||
| 514 | + //删除大华设备人脸 | ||
| 515 | + HttpUtil.deleteDHFace(schoolId,card,sno); | ||
| 516 | + } | ||
| 517 | + }catch (Exception e){ | ||
| 518 | + log.error("删除人脸失败,异常信息:{}",e); | ||
| 519 | + continue; | ||
| 520 | + } | ||
| 521 | + } | ||
| 522 | + } | ||
| 523 | + } | ||
| 524 | + } | ||
| 525 | + return ResultGenerator.genSuccessResult(); | ||
| 526 | + } | ||
| 527 | + | ||
| 528 | + @Override | ||
| 529 | + public Result deleteFaceTest(Integer schoolId, String deviceIds) { | ||
| 530 | + List<StudentBean> list = baseService.getStudentList(schoolId,null,""); | ||
| 531 | + if(StringUtils.isBlank(deviceIds)){ | ||
| 532 | + log.warn("未选择下发设备"); | ||
| 533 | + return ResultGenerator.genFailResult("未选择下发设备"); | ||
| 534 | + } | ||
| 535 | + String[] deviceArr = deviceIds.split(","); | ||
| 536 | + List<String> idLists= new ArrayList<>(Arrays.asList(deviceArr)); | ||
| 537 | + for(StudentBean studentBean : list){ | ||
| 538 | + for(String sno : idLists){ | ||
| 539 | + List<SendRecordBean> bean = sendRecordDao.getRecordIsExit(sno,studentBean.getStudent_num(),studentBean.getUser_id()); | ||
| 540 | + if(bean.size()>0){ | ||
| 541 | + continue; | ||
| 542 | + } | ||
| 543 | + try{ | ||
| 544 | + String userName= studentBean.getName(); | ||
| 545 | + String photo = studentBean.getPhoto(); | ||
| 546 | + String cardNum =studentBean.getStudent_num(); | ||
| 547 | + String typeName="Student"; | ||
| 548 | + if (StringUtils.isBlank(photo) || StringUtils.isBlank(cardNum)){ | ||
| 549 | + continue; | ||
| 550 | + } | ||
| 551 | + String path = "E:\\wwwhtdocs\\SmartCampus\\face17e50\\School" + schoolId + "\\" + typeName; | ||
| 552 | + String filePath=""; | ||
| 553 | + if(photo.indexOf("f0i5l7e5")!=-1){ | ||
| 554 | + String afterStr = photo.split("f0i5l7e5/")[1].replace("/","\\"); | ||
| 555 | + filePath="E:\\wwwhtdocs\\SmartCampus\\f0i5l7e5\\" + afterStr; | ||
| 556 | + } else{ | ||
| 557 | + //以学籍号为名的文件名 | ||
| 558 | + String fileName = photo.split(typeName +"/")[1]; | ||
| 559 | + //100服务器上人脸照绝对路径 | ||
| 560 | + filePath = path+ "\\" + fileName; | ||
| 561 | + } | ||
| 562 | + log.info("卡号:{},人脸路径:{}, ",cardNum,filePath); | ||
| 563 | + File file = new File(filePath);//图片 | ||
| 564 | + if(file.exists()){ | ||
| 565 | + String targetPath = FileUtils.picPathComp + file.getName(); | ||
| 566 | + try { | ||
| 567 | + CompressPic.CompressPic(file.getAbsolutePath(), targetPath); | ||
| 568 | + } catch (Exception e) { | ||
| 569 | + log.error("压缩图片失败"); | ||
| 570 | + e.printStackTrace(); | ||
| 571 | + continue; | ||
| 572 | + } | ||
| 573 | + String startTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); | ||
| 574 | + Calendar calendar = Calendar.getInstance(); | ||
| 575 | + calendar.add(Calendar.YEAR, 10); | ||
| 576 | + String endTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(calendar.getTime()); | ||
| 577 | + if(!cmsServer.getIsDeviceOnline(sno)){ | ||
| 578 | + if(!StringUtils.isBlank(cardNum)){ | ||
| 579 | + //下发253服务器 | ||
| 580 | + sendUserAsync.uploadImgs(targetPath, cardNum, userName, sno, startTime, endTime, 1, "2"); | ||
| 581 | + } | ||
| 582 | + } | ||
| 583 | + } | ||
| 584 | + }catch (Exception e){ | ||
| 585 | + log.error("人脸下发失败"); | ||
| 586 | + e.printStackTrace(); | ||
| 587 | + continue; | ||
| 588 | + } | ||
| 589 | + } | ||
| 590 | + } | ||
| 591 | + return ResultGenerator.genSuccessResult(); | ||
| 592 | + } | ||
| 593 | +} | 
cloud/haikangface/src/main/java/com/sincere/haikangface/utils/AlarmUtils.java
| @@ -52,7 +52,6 @@ public class AlarmUtils { | @@ -52,7 +52,6 @@ public class AlarmUtils { | ||
| 52 | public void deleAlarm(String strXML) { | 52 | public void deleAlarm(String strXML) { | 
| 53 | //人脸抓拍机器 | 53 | //人脸抓拍机器 | 
| 54 | if (strXML.contains("FACESNAPREPORT")) { | 54 | if (strXML.contains("FACESNAPREPORT")) { | 
| 55 | -// System.out.println("人脸抓拍机:" + strXML); | ||
| 56 | BaiduFaceRecorder baiduFaceRecorder = new BaiduFaceRecorder(); | 55 | BaiduFaceRecorder baiduFaceRecorder = new BaiduFaceRecorder(); | 
| 57 | baiduFaceRecorder.setUploadImgUrl(strXML); | 56 | baiduFaceRecorder.setUploadImgUrl(strXML); | 
| 58 | baiduFaceRecorder.setTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); | 57 | baiduFaceRecorder.setTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); | 
| @@ -61,8 +60,6 @@ public class AlarmUtils { | @@ -61,8 +60,6 @@ public class AlarmUtils { | ||
| 61 | deviceId = deviceId.replace("DeviceID>",""); | 60 | deviceId = deviceId.replace("DeviceID>",""); | 
| 62 | deviceId = deviceId.replace("</",""); | 61 | deviceId = deviceId.replace("</",""); | 
| 63 | userDao.insertBaiduFaceRecorder(baiduFaceRecorder); | 62 | userDao.insertBaiduFaceRecorder(baiduFaceRecorder); | 
| 64 | -// if (null != alarmCallBack) | ||
| 65 | -// alarmCallBack.callBack(minorType, deviceID, cardNo, time, picDataUrlId, currTemperature); | ||
| 66 | } else {//人脸识别 | 63 | } else {//人脸识别 | 
| 67 | //主类型 | 64 | //主类型 | 
| 68 | String majirType = strXML.substring(strXML.indexOf("MajorType"), strXML.lastIndexOf("MajorType")).trim(); | 65 | String majirType = strXML.substring(strXML.indexOf("MajorType"), strXML.lastIndexOf("MajorType")).trim(); | 
cloud/haikangface/src/main/java/com/sincere/haikangface/utils/CompressPic.java
| @@ -22,10 +22,7 @@ public class CompressPic { | @@ -22,10 +22,7 @@ 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); | ||
| 27 | if ((fileLength / 1024) < 200) { | 25 | if ((fileLength / 1024) < 200) { | 
| 28 | -// System.out.println("小于200k压缩:" + "width:" + width + "--height:" + height); | ||
| 29 | writeImgToFile(bufferedImage, width, height, targetPath); | 26 | writeImgToFile(bufferedImage, width, height, targetPath); | 
| 30 | } else { | 27 | } else { | 
| 31 | while ((fileLength / 1024) >= 200) { | 28 | while ((fileLength / 1024) >= 200) { | 
| @@ -40,12 +37,9 @@ public class CompressPic { | @@ -40,12 +37,9 @@ public class CompressPic { | ||
| 40 | width = bufferedImage1.getWidth(null); | 37 | width = bufferedImage1.getWidth(null); | 
| 41 | height = bufferedImage1.getHeight(null); | 38 | height = bufferedImage1.getHeight(null); | 
| 42 | fileLength = file1.length(); | 39 | fileLength = file1.length(); | 
| 43 | -// System.out.println("最终宽高:" + "width:" + width + "--height:" + height); | ||
| 44 | -// System.out.println("fileLength1:" + fileLength); | ||
| 45 | fileInputStream.close(); | 40 | fileInputStream.close(); | 
| 46 | } | 41 | } | 
| 47 | } | 42 | } | 
| 48 | -// System.out.printf("图片大小:"+fileLength/1024); | ||
| 49 | fileInputStreamSrc.close(); | 43 | fileInputStreamSrc.close(); | 
| 50 | return targetPath; | 44 | return targetPath; | 
| 51 | } | 45 | } | 
| @@ -54,31 +48,18 @@ public class CompressPic { | @@ -54,31 +48,18 @@ public class CompressPic { | ||
| 54 | try { | 48 | try { | 
| 55 | File targetFile = new File(targetPath); | 49 | File targetFile = new File(targetPath); | 
| 56 | if (!targetFile.exists()) targetFile.createNewFile(); | 50 | if (!targetFile.exists()) targetFile.createNewFile(); | 
| 57 | - | ||
| 58 | if (width > height) { | 51 | if (width > height) { | 
| 59 | int width1 = width; | 52 | int width1 = width; | 
| 60 | width = height; | 53 | width = height; | 
| 61 | height = width1; | 54 | height = width1; | 
| 62 | } | 55 | } | 
| 63 | - | ||
| 64 | BufferedImage tag = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); | 56 | BufferedImage tag = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); | 
| 65 | tag.getGraphics().drawImage(bufferedImage, 0, 0, width, height, null); // 绘制缩小后的图 | 57 | tag.getGraphics().drawImage(bufferedImage, 0, 0, width, height, null); // 绘制缩小后的图 | 
| 66 | FileOutputStream deskImage = new FileOutputStream(targetPath); // 输出到文件流 | 58 | FileOutputStream deskImage = new FileOutputStream(targetPath); // 输出到文件流 | 
| 67 | JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(deskImage); | 59 | JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(deskImage); | 
| 68 | encoder.encode(tag); // 近JPEG编码 | 60 | encoder.encode(tag); // 近JPEG编码 | 
| 69 | -// boolean write = ImageIO.write(tag, "jpg", deskImage); | ||
| 70 | - /*if (write) { | ||
| 71 | - int angle = ImageUtils.getImgRotateAngle(targetPath); | ||
| 72 | - System.out.println("angle:" + angle); | ||
| 73 | - if (angle == 0) { | ||
| 74 | -// ImageUtils.rotatePhonePhoto(targetPath, 90); | ||
| 75 | - } | ||
| 76 | - | ||
| 77 | - }*/ | ||
| 78 | -// System.out.println("读写图片:" + write); | ||
| 79 | deskImage.close(); | 61 | deskImage.close(); | 
| 80 | } catch (Exception e) { | 62 | } catch (Exception e) { | 
| 81 | -// System.out.println("读写图片:" + e.toString()); | ||
| 82 | e.printStackTrace(); | 63 | e.printStackTrace(); | 
| 83 | } | 64 | } | 
| 84 | } | 65 | } | 
cloud/haikangface/src/main/java/com/sincere/haikangface/utils/HttpUtil.java
| @@ -3,12 +3,14 @@ package com.sincere.haikangface.utils; | @@ -3,12 +3,14 @@ package com.sincere.haikangface.utils; | ||
| 3 | import com.alibaba.fastjson.JSON; | 3 | import com.alibaba.fastjson.JSON; | 
| 4 | import com.alibaba.fastjson.JSONObject; | 4 | import com.alibaba.fastjson.JSONObject; | 
| 5 | import com.sincere.haikangface.bean.face.PermissionBean; | 5 | import com.sincere.haikangface.bean.face.PermissionBean; | 
| 6 | +import com.sincere.haikangface.bean.face.PermissionDHBean; | ||
| 6 | import lombok.extern.slf4j.Slf4j; | 7 | import lombok.extern.slf4j.Slf4j; | 
| 7 | import org.springframework.core.io.FileSystemResource; | 8 | import org.springframework.core.io.FileSystemResource; | 
| 8 | import org.springframework.http.HttpEntity; | 9 | import org.springframework.http.HttpEntity; | 
| 9 | import org.springframework.http.HttpHeaders; | 10 | import org.springframework.http.HttpHeaders; | 
| 10 | import org.springframework.http.MediaType; | 11 | import org.springframework.http.MediaType; | 
| 11 | import org.springframework.http.ResponseEntity; | 12 | import org.springframework.http.ResponseEntity; | 
| 13 | +import org.springframework.scheduling.annotation.Async; | ||
| 12 | import org.springframework.util.LinkedMultiValueMap; | 14 | import org.springframework.util.LinkedMultiValueMap; | 
| 13 | import org.springframework.util.MultiValueMap; | 15 | import org.springframework.util.MultiValueMap; | 
| 14 | import org.springframework.util.StringUtils; | 16 | import org.springframework.util.StringUtils; | 
| @@ -93,136 +95,111 @@ public class HttpUtil { | @@ -93,136 +95,111 @@ public class HttpUtil { | ||
| 93 | return result; | 95 | return result; | 
| 94 | } | 96 | } | 
| 95 | 97 | ||
| 96 | - public static boolean uploadImgs(String filePath, String card, String name, String deviceId, String startTime, | 98 | + /** | 
| 99 | + * 下发人脸值253服务设备 | ||
| 100 | + * @param filePath | ||
| 101 | + * @param card | ||
| 102 | + * @param name | ||
| 103 | + * @param deviceId | ||
| 104 | + * @param startTime | ||
| 105 | + * @param endTime | ||
| 106 | + * @param validTimeEnabled | ||
| 107 | + * @param userType | ||
| 108 | + */ | ||
| 109 | + public static void uploadImgs(String filePath, String card, String name, String deviceId, String startTime, | ||
| 97 | String endTime, int validTimeEnabled, String userType) { | 110 | String endTime, int validTimeEnabled, String userType) { | 
| 98 | - | ||
| 99 | if (!new File(filePath).exists()) { | 111 | if (!new File(filePath).exists()) { | 
| 100 | - System.out.println("图片不存在"); | ||
| 101 | - return false; | 112 | + log.error("图片不存在,图片路径:{}",filePath); | 
| 113 | + return; | ||
| 114 | + } | ||
| 115 | + try{ | ||
| 116 | + String url = "http://120.26.116.253:8089/file/uploadImg"; | ||
| 117 | + RestTemplate restTemplate = new RestTemplate(); | ||
| 118 | + HttpHeaders headers = new HttpHeaders(); | ||
| 119 | + MediaType mediaType = MediaType.parseMediaType(MediaType.MULTIPART_FORM_DATA_VALUE); | ||
| 120 | + headers.setContentType(mediaType); | ||
| 121 | + MultiValueMap<String, Object> multivaluedMap = new LinkedMultiValueMap<>(); | ||
| 122 | + FileSystemResource fileSystemResource = new FileSystemResource(filePath); | ||
| 123 | + multivaluedMap.add("file", fileSystemResource); | ||
| 124 | + multivaluedMap.add("deviceId", deviceId); | ||
| 125 | + multivaluedMap.add("card", card); | ||
| 126 | + multivaluedMap.add("name", name); | ||
| 127 | + multivaluedMap.add("startTime", startTime); | ||
| 128 | + multivaluedMap.add("endTime", endTime); | ||
| 129 | + multivaluedMap.add("validTimeEnabled", validTimeEnabled); | ||
| 130 | + multivaluedMap.add("userType", userType); | ||
| 131 | + HttpEntity<MultiValueMap<String, Object>> httpEntity = new HttpEntity<>(multivaluedMap, headers); | ||
| 132 | + ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, httpEntity, String.class); | ||
| 133 | + log.info("发送请求,下发人脸至253服务器海康设备,请求地址:{} ,下发用户名:{},返回信息:{}",url,name,responseEntity.getBody()); | ||
| 134 | + }catch (Exception e){ | ||
| 135 | + log.error("发送请求,下发人脸至253服务器海康设备,发生异常: {}",e); | ||
| 102 | } | 136 | } | 
| 103 | - | ||
| 104 | - String url = "http://120.26.116.253:8089/file/uploadImg"; | ||
| 105 | - | ||
| 106 | - RestTemplate restTemplate = new RestTemplate(); | ||
| 107 | - | ||
| 108 | - HttpHeaders headers = new HttpHeaders(); | ||
| 109 | - | ||
| 110 | - MediaType mediaType = MediaType.parseMediaType(MediaType.MULTIPART_FORM_DATA_VALUE); | ||
| 111 | - | ||
| 112 | - headers.setContentType(mediaType); | ||
| 113 | - | ||
| 114 | - MultiValueMap<String, Object> multivaluedMap = new LinkedMultiValueMap<>(); | ||
| 115 | - | ||
| 116 | - FileSystemResource fileSystemResource = new FileSystemResource(filePath); | ||
| 117 | - | ||
| 118 | - multivaluedMap.add("file", fileSystemResource); | ||
| 119 | - multivaluedMap.add("deviceId", deviceId); | ||
| 120 | - multivaluedMap.add("card", card); | ||
| 121 | - multivaluedMap.add("name", name); | ||
| 122 | - multivaluedMap.add("startTime", startTime); | ||
| 123 | - multivaluedMap.add("endTime", endTime); | ||
| 124 | - multivaluedMap.add("validTimeEnabled", validTimeEnabled); | ||
| 125 | - multivaluedMap.add("userType", userType); | ||
| 126 | - | ||
| 127 | - HttpEntity<MultiValueMap<String, Object>> httpEntity = new HttpEntity<>(multivaluedMap, headers); | ||
| 128 | - | ||
| 129 | - ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, httpEntity, String.class); | ||
| 130 | - | ||
| 131 | - System.out.println("responseEntity:" + responseEntity.getBody()+name); | ||
| 132 | - return responseEntity.getBody().equals("1"); | ||
| 133 | } | 137 | } | 
| 134 | 138 | ||
| 135 | 139 | ||
| 136 | public static boolean IsDeviceOnline(String deviceId) { | 140 | public static boolean IsDeviceOnline(String deviceId) { | 
| 137 | 141 | ||
| 138 | String url = "http://120.26.116.253:8089/file/IsDeviceOnline?deviceId=" + deviceId; | 142 | String url = "http://120.26.116.253:8089/file/IsDeviceOnline?deviceId=" + deviceId; | 
| 139 | - | ||
| 140 | RestTemplate restTemplate = new RestTemplate(); | 143 | RestTemplate restTemplate = new RestTemplate(); | 
| 141 | - | ||
| 142 | -// Map<String,Object> map = new HashMap<>(); | ||
| 143 | - | ||
| 144 | -// map.put("deviceId",deviceId); | ||
| 145 | - | ||
| 146 | String res = restTemplate.getForObject(url, String.class); | 144 | String res = restTemplate.getForObject(url, String.class); | 
| 147 | return res.equals("1"); | 145 | return res.equals("1"); | 
| 148 | } | 146 | } | 
| 149 | 147 | ||
| 148 | + /** | ||
| 149 | + * 删除海康设备卡信息 | ||
| 150 | + * @param deviceId | ||
| 151 | + * @param card | ||
| 152 | + * @return | ||
| 153 | + */ | ||
| 150 | public static boolean deleteCard(String deviceId, String card) { | 154 | public static boolean deleteCard(String deviceId, String card) { | 
| 151 | - | ||
| 152 | String url = "http://120.26.116.253:8089/file/DeleteCard?deviceId=" + deviceId + "&card=" + card; | 155 | String url = "http://120.26.116.253:8089/file/DeleteCard?deviceId=" + deviceId + "&card=" + card; | 
| 153 | - | ||
| 154 | RestTemplate restTemplate = new RestTemplate(); | 156 | RestTemplate restTemplate = new RestTemplate(); | 
| 155 | - | ||
| 156 | String res = restTemplate.getForObject(url, String.class); | 157 | String res = restTemplate.getForObject(url, String.class); | 
| 157 | - | ||
| 158 | return res.equals("1"); | 158 | return res.equals("1"); | 
| 159 | } | 159 | } | 
| 160 | 160 | ||
| 161 | + /** | ||
| 162 | + * 获取海康设备卡信息 | ||
| 163 | + * @param deviceId | ||
| 164 | + * @param card | ||
| 165 | + * @return | ||
| 166 | + */ | ||
| 161 | public static boolean getCard(String deviceId, String card) { | 167 | public static boolean getCard(String deviceId, String card) { | 
| 162 | - | ||
| 163 | String url = "http://120.26.116.253:8089/file/getCard?deviceId=" + deviceId + "&card=" + card; | 168 | String url = "http://120.26.116.253:8089/file/getCard?deviceId=" + deviceId + "&card=" + card; | 
| 164 | - | ||
| 165 | RestTemplate restTemplate = new RestTemplate(); | 169 | RestTemplate restTemplate = new RestTemplate(); | 
| 166 | - | ||
| 167 | -// String res = restTemplate.getForObject(url,String.class,map); | ||
| 168 | - return restTemplate.getForObject(url, String.class).equals("1"); | 170 | + String res = restTemplate.getForObject(url,String.class); | 
| 171 | + return res.equals("1"); | ||
| 169 | } | 172 | } | 
| 170 | 173 | ||
| 171 | - | 174 | + /** | 
| 175 | + * 下发权限至海康设备 | ||
| 176 | + * @param permissionBean | ||
| 177 | + */ | ||
| 172 | public static void sendPermission2HK(PermissionBean permissionBean) { | 178 | public static void sendPermission2HK(PermissionBean permissionBean) { | 
| 173 | try { | 179 | try { | 
| 174 | - | ||
| 175 | String url = "http://120.26.116.253:8089/file/sendPermiss"; | 180 | String url = "http://120.26.116.253:8089/file/sendPermiss"; | 
| 176 | - | ||
| 177 | if (null != permissionBean) { | 181 | if (null != permissionBean) { | 
| 178 | - | ||
| 179 | RestTemplate restTemplate = new RestTemplate(); | 182 | RestTemplate restTemplate = new RestTemplate(); | 
| 180 | - | ||
| 181 | HttpHeaders headers = new HttpHeaders(); | 183 | HttpHeaders headers = new HttpHeaders(); | 
| 182 | - | ||
| 183 | MediaType mediaType = MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE); | 184 | MediaType mediaType = MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE); | 
| 184 | - | ||
| 185 | headers.setContentType(mediaType); | 185 | headers.setContentType(mediaType); | 
| 186 | - | ||
| 187 | HttpEntity<PermissionBean> httpEntity = new HttpEntity<>(permissionBean, headers); | 186 | HttpEntity<PermissionBean> httpEntity = new HttpEntity<>(permissionBean, headers); | 
| 188 | - | ||
| 189 | - System.out.println("PermissionBean:" + JSON.toJSONString(permissionBean)); | ||
| 190 | - | ||
| 191 | ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, httpEntity, String.class); | 187 | ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, httpEntity, String.class); | 
| 192 | - | ||
| 193 | - System.out.println("responseEntity:" + responseEntity.getBody()); | ||
| 194 | - | 188 | + String reqJson= JSON.toJSONString(permissionBean); | 
| 189 | + log.info("发送请求,下发权限至海康设备,请求地址:{},请求参数:{},返回信息:{}",url,reqJson,responseEntity.getBody()); | ||
| 195 | } | 190 | } | 
| 196 | } catch (Exception e) { | 191 | } catch (Exception e) { | 
| 197 | - e.printStackTrace(); | ||
| 198 | - } | ||
| 199 | - } | ||
| 200 | - | ||
| 201 | - public static void uploadDHImgForOne(String filePath,Integer schoolId,String studentCode,int clintType,String deviceId) { | ||
| 202 | - String url = "http://114.55.30.100:8089/user/uploadImgAndUserInfo"; | ||
| 203 | - MultiValueMap<String, Object> multivaluedMap = new LinkedMultiValueMap<>(); | ||
| 204 | - HttpHeaders headers = new HttpHeaders(); | ||
| 205 | - RestTemplate restTemplate = new RestTemplate(); | ||
| 206 | - HttpEntity<MultiValueMap<String, Object>> httpEntity = null; | ||
| 207 | - ResponseEntity<String> responseEntity = null; | ||
| 208 | - try { | ||
| 209 | - MediaType mediaType = MediaType.parseMediaType(MediaType.APPLICATION_JSON_VALUE); | ||
| 210 | - headers.setContentType(mediaType); | ||
| 211 | - multivaluedMap.add("file", filePath); | ||
| 212 | - multivaluedMap.add("schoolId", schoolId); | ||
| 213 | - multivaluedMap.add("studentCode", studentCode); | ||
| 214 | - multivaluedMap.add("clint_type", clintType); | ||
| 215 | - multivaluedMap.add("deviceId", deviceId); | ||
| 216 | - httpEntity = new HttpEntity<>(multivaluedMap, headers); | ||
| 217 | - responseEntity = restTemplate.postForEntity(url, httpEntity, String.class); | ||
| 218 | - log.info("responseEntity:" + responseEntity.getBody()); | ||
| 219 | - } catch (Exception e) { | ||
| 220 | - e.printStackTrace(); | 192 | + log.error("发送请求,下发权限至海康设备,发生异常: {}",e); | 
| 221 | } | 193 | } | 
| 222 | } | 194 | } | 
| 223 | 195 | ||
| 196 | + /** | ||
| 197 | + * 百度人脸识别查询 | ||
| 198 | + * @param file | ||
| 199 | + * @param schoolId | ||
| 200 | + * @return | ||
| 201 | + */ | ||
| 224 | public static JSONObject sendToKB(File file,String schoolId) { | 202 | public static JSONObject sendToKB(File file,String schoolId) { | 
| 225 | - log.info("开始请求人脸识别查询....."); | ||
| 226 | String url = "http://120.26.116.253:9214/baiduapi/search/" + schoolId; | 203 | String url = "http://120.26.116.253:9214/baiduapi/search/" + schoolId; | 
| 227 | MultiValueMap<String, Object> multivaluedMap = new LinkedMultiValueMap<>(); | 204 | MultiValueMap<String, Object> multivaluedMap = new LinkedMultiValueMap<>(); | 
| 228 | HttpHeaders headers = new HttpHeaders(); | 205 | HttpHeaders headers = new HttpHeaders(); | 
| @@ -235,11 +212,108 @@ public class HttpUtil { | @@ -235,11 +212,108 @@ public class HttpUtil { | ||
| 235 | HttpEntity<MultiValueMap<String, Object>> httpEntity = new HttpEntity<>(multivaluedMap, headers); | 212 | HttpEntity<MultiValueMap<String, Object>> httpEntity = new HttpEntity<>(multivaluedMap, headers); | 
| 236 | ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, httpEntity, String.class); | 213 | ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, httpEntity, String.class); | 
| 237 | JSONObject jsonObject = JSON.parseObject(responseEntity.getBody()); | 214 | JSONObject jsonObject = JSON.parseObject(responseEntity.getBody()); | 
| 238 | - log.info("responseEntity:" + jsonObject.toJSONString()); | 215 | + log.info("发送请求,人脸识别查询,请求地址:{},返回信息:{}",url,jsonObject.toJSONString()); | 
| 239 | return jsonObject; | 216 | return jsonObject; | 
| 240 | } catch (Exception e) { | 217 | } catch (Exception e) { | 
| 241 | - log.info("人脸识别异常,异常信息:{}",e); | ||
| 242 | - return null; | 218 | + log.info("发送请求,百度人脸识别失败,异常信息:{}",e); | 
| 219 | + } | ||
| 220 | + return null; | ||
| 221 | + } | ||
| 222 | + | ||
| 223 | + /** | ||
| 224 | + * 下发单个人脸至大华设备 | ||
| 225 | + * @param filePath | ||
| 226 | + * @param schoolId | ||
| 227 | + * @param studentCode | ||
| 228 | + * @param clintType | ||
| 229 | + * @param deviceId | ||
| 230 | + * @return | ||
| 231 | + */ | ||
| 232 | + public static void uploadDHImgForOne(String filePath,Integer schoolId,String studentCode,int clintType,String deviceId) { | ||
| 233 | + String api = "http://114.55.30.100:8991/user/uploadImgAndUserInfo"; | ||
| 234 | + try { | ||
| 235 | + String url = String.format(api +"?schoolId=%s&studentCode=%s&deviceId=%s&clint_type=%s&file=%s",schoolId,studentCode,deviceId,clintType,filePath); | ||
| 236 | + RestTemplate restTemplate = new RestTemplate(); | ||
| 237 | + ResponseEntity<String> responseEntity = restTemplate.getForEntity(url, String.class); | ||
| 238 | + log.info("发送请求,下发单个人脸至大华设备,请求地址:{} ,返回信息:{}",url, responseEntity.getBody()); | ||
| 239 | + } catch (Exception e) { | ||
| 240 | + log.error("发送请求,下发单个人脸至大华,异常信息: {}",e); | ||
| 241 | + } | ||
| 242 | + } | ||
| 243 | + | ||
| 244 | + /** | ||
| 245 | + * 下发权限至大华设备 | ||
| 246 | + * @param permissionBean | ||
| 247 | + * @return | ||
| 248 | + */ | ||
| 249 | + public static void sendDHPermission(PermissionDHBean permissionBean) { | ||
| 250 | + try{ | ||
| 251 | +// String url = "http://121.40.109.21:8991/file/sendPermission"; | ||
| 252 | + String url = "http://localhost:8991/file/sendPermission"; | ||
| 253 | + RestTemplate restTemplate = new RestTemplate(); | ||
| 254 | + HttpHeaders headers = new HttpHeaders(); | ||
| 255 | + MediaType mediaType = MediaType.parseMediaType(MediaType.APPLICATION_JSON_UTF8_VALUE); | ||
| 256 | + headers.setContentType(mediaType); | ||
| 257 | + HttpEntity<PermissionDHBean> httpEntity = new HttpEntity<>(permissionBean, headers); | ||
| 258 | + ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, httpEntity, String.class); | ||
| 259 | + log.info("发送请求,下发权限至大华设备,请求地址:{} ,返回信息:{}",url, responseEntity.getBody()); | ||
| 260 | + }catch (Exception e){ | ||
| 261 | + log.error("发送请求,下发权限至大华设备,异常信息,{}",e); | ||
| 262 | + } | ||
| 263 | + } | ||
| 264 | + | ||
| 265 | + /** | ||
| 266 | + * 照片下发,发送海康设备 | ||
| 267 | + * @param schoolId | ||
| 268 | + * @param userType | ||
| 269 | + * @param deviceIds | ||
| 270 | + */ | ||
| 271 | + public static void uploadHkImg( String schoolId,int userType,String deviceIds) { | ||
| 272 | + String api = "http://114.55.30.100:8089/facereco/sendFaces"; | ||
| 273 | + try { | ||
| 274 | + String url = String.format(api +"?schoolId=%s&userType=%s&deviceIds=%s",schoolId,userType,deviceIds); | ||
| 275 | + RestTemplate restTemplate = new RestTemplate(); | ||
| 276 | + ResponseEntity<String> responseEntity = restTemplate.getForEntity(url, String.class); | ||
| 277 | + log.info("发送请求,照片下发至海康设备,请求地址:{},返回信息: {}",url,responseEntity.getBody()); | ||
| 278 | + } catch (Exception e) { | ||
| 279 | + log.error("发送请求,照片下发至海康设备,异常信息:{}",e); | ||
| 280 | + } | ||
| 281 | + } | ||
| 282 | + | ||
| 283 | + /** | ||
| 284 | + * 照片下发,发送大华设备 | ||
| 285 | + * @param schoolId | ||
| 286 | + * @param userType | ||
| 287 | + * @param deviceIds | ||
| 288 | + */ | ||
| 289 | + public static void uploadDHImg( String schoolId,int userType,String deviceIds) { | ||
| 290 | + String api = "http://114.55.30.100:8991/user/sendFaces"; | ||
| 291 | +// String api = "http://127.0.0.1:8991/user/sendFaces"; | ||
| 292 | + try { | ||
| 293 | + String url = String.format(api +"?schoolId=%s&userType=%s&deviceIds=%s",schoolId,userType,deviceIds); | ||
| 294 | + RestTemplate restTemplate = new RestTemplate(); | ||
| 295 | + ResponseEntity<String> responseEntity = restTemplate.getForEntity(url, String.class); | ||
| 296 | + log.info("发送请求,照片下发至大华设备,请求地址:{},返回信息: {}",url,responseEntity.getBody()); | ||
| 297 | + } catch (Exception e) { | ||
| 298 | + log.error("发送请求,照片下发至大华设备,异常信息:{}",e); | ||
| 299 | + } | ||
| 300 | + } | ||
| 301 | + | ||
| 302 | + /** | ||
| 303 | + * 删除大华设备人脸 | ||
| 304 | + * @param schoolId | ||
| 305 | + * @param cardNum | ||
| 306 | + * @param deviceId | ||
| 307 | + */ | ||
| 308 | + public static void deleteDHFace(Integer schoolId,String cardNum,String deviceId) { | ||
| 309 | + String api = "http://121.40.109.21:8991/operate/deleteFaceByCard"; | ||
| 310 | + try { | ||
| 311 | + String url = String.format(api +"?schoolId=%s&cardNum=%s&deviceId=%s",schoolId,cardNum,deviceId); | ||
| 312 | + RestTemplate restTemplate = new RestTemplate(); | ||
| 313 | + ResponseEntity<String> responseEntity = restTemplate.getForEntity(url, String.class); | ||
| 314 | + log.info("发送请求,删除大华设备人脸,请求地址:{},返回信息: {}",url,responseEntity.getBody()); | ||
| 315 | + } catch (Exception e) { | ||
| 316 | + log.error("发送请求,删除大华设备人脸,异常信息:{}",e); | ||
| 243 | } | 317 | } | 
| 244 | } | 318 | } | 
| 245 | } | 319 | } | 
cloud/haikangface/src/main/java/com/sincere/haikangface/xiananDao/SendRecordDao.java
| @@ -134,9 +134,12 @@ public interface SendRecordDao { | @@ -134,9 +134,12 @@ public interface SendRecordDao { | ||
| 134 | @Param("time") String time, @Param("schoolName") String schoolName, @Param("imgPath") String imgPath, @Param("schoolId") Integer schoolId, @Param("failContent") String failContent, | 134 | @Param("time") String time, @Param("schoolName") String schoolName, @Param("imgPath") String imgPath, @Param("schoolId") Integer schoolId, @Param("failContent") String failContent, | 
| 135 | @Param("failType") Integer failType, @Param("userType") Integer userType, @Param("deviceType") Integer deviceType,Integer status); | 135 | @Param("failType") Integer failType, @Param("userType") Integer userType, @Param("deviceType") Integer deviceType,Integer status); | 
| 136 | 136 | ||
| 137 | - @Update("update Face_SendRecord set time = #{time},failContent = #{content},imgPath= #{faceUrl},status = 2, where deviceID = #{deviceID} and Num =#{Num} and userId = #{userId}") | 137 | + @Update("update Face_SendRecord set time = #{time},failContent = #{content},imgPath= #{faceUrl},status = 2 where deviceID = #{deviceID} and Num =#{Num} and userId = #{userId}") | 
| 138 | void updateFaceFailRecord(@Param("deviceID") String deviceId, @Param("faceUrl") String faceUrl,@Param("Num") String card, @Param("time") String time, @Param("content") String content,@Param("userId") String userId); | 138 | void updateFaceFailRecord(@Param("deviceID") String deviceId, @Param("faceUrl") String faceUrl,@Param("Num") String card, @Param("time") String time, @Param("content") String content,@Param("userId") String userId); | 
| 139 | 139 | ||
| 140 | @Update("update Face_SendRecord set time = #{time},imgPath= #{faceUrl},Name = #{Name},status = 1, failType=null, failContent = null where deviceID = #{deviceID} and Num = #{Num}") | 140 | @Update("update Face_SendRecord set time = #{time},imgPath= #{faceUrl},Name = #{Name},status = 1, failType=null, failContent = null where deviceID = #{deviceID} and Num = #{Num}") | 
| 141 | void updateFaceSuccessRecord(@Param("deviceID") String deviceId, @Param("Num") String card, @Param("time") String time, @Param("faceUrl") String faceUrl, @Param("Name") String name, @Param("userId") String userId); | 141 | void updateFaceSuccessRecord(@Param("deviceID") String deviceId, @Param("Num") String card, @Param("time") String time, @Param("faceUrl") String faceUrl, @Param("Name") String name, @Param("userId") String userId); | 
| 142 | + | ||
| 143 | + @Select("select * from Face_SendRecord where schoolId = #{schoolId} and status =2") | ||
| 144 | + List<SendRecordBean> getFailRecord(@Param("schoolId") Integer schoolId); | ||
| 142 | } | 145 | } | 
cloud/haikangface/src/main/resources/application.yaml
| @@ -0,0 +1,54 @@ | @@ -0,0 +1,54 @@ | ||
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | +<configuration> | ||
| 3 | + <!-- | ||
| 4 | + SpringBoot下,默认会加载logback-spring.xml,其他项目建议文件名改为logback.xml | ||
| 5 | + 目录 org/springframework/boot/logging/logback/*.xml下有一些log的基础配置 | ||
| 6 | + 不是所有的项目都是Springboot,这里为了做成通用的logback.xml文件,对这里进行修改 | ||
| 7 | + --> | ||
| 8 | + <!--<include resource="org/springframework/boot/logging/logback/defaults.xml" />--> | ||
| 9 | + | ||
| 10 | + <!--日志文件存储的基础路径: ${user.home} 为当前服务器用户主目录--> | ||
| 11 | + <property name="LOG_PATH" value="D:/haikang-logs"/> | ||
| 12 | + | ||
| 13 | + <!--日志文件基础名称--> | ||
| 14 | + <property name="BASE_FILE_NAME" value="haikang"/> | ||
| 15 | + <property name="LOG_FILE_MAX_SIZE" value="10MB"/> | ||
| 16 | + <property name="LOG_FILE_MAX_HISTORY" value="3"/> | ||
| 17 | + | ||
| 18 | + <!--控制台的输出--> | ||
| 19 | + <appender name="console" class="ch.qos.logback.core.ConsoleAppender"> | ||
| 20 | + <!-- 设置输出格式--> | ||
| 21 | + <encoder> | ||
| 22 | + <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} \(L%line\) - %msg%n</pattern> | ||
| 23 | + </encoder> | ||
| 24 | + </appender> | ||
| 25 | + | ||
| 26 | + <!--文件输出--> | ||
| 27 | + <appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender"> | ||
| 28 | + <!--输出文件名--> | ||
| 29 | + <file>${LOG_PATH}/${BASE_FILE_NAME}.log</file> | ||
| 30 | + <!--日志文件格式--> | ||
| 31 | + <encoder> | ||
| 32 | + <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} \(L%line\) - %msg%n</pattern> | ||
| 33 | + </encoder> | ||
| 34 | + | ||
| 35 | + <!-- 日志文件滚动策略--> | ||
| 36 | + <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> | ||
| 37 | + <!--历史文件存放格式和路径:--> | ||
| 38 | + <fileNamePattern>${LOG_PATH}/history/${BASE_FILE_NAME}.%d{yyyy-MM-dd}.%i.gz</fileNamePattern> | ||
| 39 | + <!-- 文件最大的大小--> | ||
| 40 | + <maxFileSize>${LOG_FILE_MAX_SIZE}</maxFileSize> | ||
| 41 | + <!-- 日志文件保留天数 --> | ||
| 42 | + <maxHistory>${LOG_FILE_MAX_HISTORY}</maxHistory> | ||
| 43 | + </rollingPolicy> | ||
| 44 | + </appender> | ||
| 45 | + | ||
| 46 | + <!--测试环境和开发环境打印控制台输出--> | ||
| 47 | + <springProfile name="test,dev"> | ||
| 48 | + <root level="INFO"> | ||
| 49 | + <appender-ref ref="console" /> | ||
| 50 | + <appender-ref ref="file" /> | ||
| 51 | + </root> | ||
| 52 | + </springProfile> | ||
| 53 | + | ||
| 54 | +</configuration> | ||
| 0 | \ No newline at end of file | 55 | \ No newline at end of file | 
cloud/haikangface/src/main/resources/mapper/usermapper.xml
| @@ -47,6 +47,14 @@ | @@ -47,6 +47,14 @@ | ||
| 47 | select * from AC_DeviceAuthRecord where id = #{id} | 47 | select * from AC_DeviceAuthRecord where id = #{id} | 
| 48 | </select> | 48 | </select> | 
| 49 | 49 | ||
| 50 | + <select id="getAuthRecordBySchoolId" resultType="java.lang.Integer"> | ||
| 51 | + select top 1 ShiDuan from AC_DeviceAuthRecord where SchoolId = #{schoolId} and StudentType = #{studentType} | ||
| 52 | + <if test="status != null"> | ||
| 53 | + and State= #{status} | ||
| 54 | + </if> | ||
| 55 | + order by ShiDuan desc | ||
| 56 | + </select> | ||
| 57 | + | ||
| 50 | <update id="deleteAuthRecord"> | 58 | <update id="deleteAuthRecord"> | 
| 51 | update AC_DeviceAuthRecord set State = 0 where id = #{id} | 59 | update AC_DeviceAuthRecord set State = 0 where id = #{id} | 
| 52 | </update> | 60 | </update> | 
| @@ -62,4 +70,33 @@ | @@ -62,4 +70,33 @@ | ||
| 62 | <select id="getTeacherByUserId" resultType="com.sincere.haikangface.bean.StudentBean" parameterType="java.lang.String"> | 70 | <select id="getTeacherByUserId" resultType="com.sincere.haikangface.bean.StudentBean" parameterType="java.lang.String"> | 
| 63 | select Top(1) * from SZ_V_School_Teacher where user_id = #{userId} | 71 | select Top(1) * from SZ_V_School_Teacher where user_id = #{userId} | 
| 64 | </select> | 72 | </select> | 
| 73 | + | ||
| 74 | + <select id="getStudentList" resultType="com.sincere.haikangface.bean.StudentBean"> | ||
| 75 | + select * from SZ_V_School_Student where school_id = #{schoolId} | ||
| 76 | + <if test="studentType != null"> | ||
| 77 | + and student_type = #{studentType} | ||
| 78 | + </if> | ||
| 79 | + <if test="sex != null and sex.size() >0"> | ||
| 80 | + and sex in | ||
| 81 | + <foreach item="item" collection="sex" separator="," open="(" close=")" index=""> | ||
| 82 | + #{item} | ||
| 83 | + </foreach> | ||
| 84 | + </if> | ||
| 85 | + and (student_num is not null or student_num != '') and (photo is not null or photo !='') | ||
| 86 | + </select> | ||
| 87 | + | ||
| 88 | + <select id="getTeacherList" resultType="com.sincere.haikangface.bean.StudentBean"> | ||
| 89 | + select * from SZ_V_School_Teacher where school_id = #{schoolId} | ||
| 90 | + and (teacher_num is not null or teacher_num !='') | ||
| 91 | + and (face is not null or face !='') | ||
| 92 | + </select> | ||
| 93 | + | ||
| 94 | + <select id="getDeviceIds" resultType="java.lang.String"> | ||
| 95 | + select clint_id from SZ_Attendance where clint_type in(22,18,28,29) and school_id = #{schoolId} | ||
| 96 | + <if test="deviceId != null and deviceId.trim() != ''"> | ||
| 97 | + and clint_id = #{deviceId} | ||
| 98 | + </if> | ||
| 99 | + </select> | ||
| 100 | + | ||
| 101 | + | ||
| 65 | </mapper> | 102 | </mapper> |