| @@ -293,12 +293,6 @@ | |||
| <artifactId>spring-boot-starter-batch</artifactId> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>org.springframework.boot</groupId> | |||
| <artifactId>spring-boot-devtools</artifactId> | |||
| <scope>runtime</scope> | |||
| <optional>true</optional> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>com.auth0</groupId> | |||
| @@ -313,6 +307,12 @@ | |||
| <version>3.0.0</version> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>com.squareup.okhttp3</groupId> | |||
| <artifactId>okhttp</artifactId> | |||
| <version>3.14.9</version> | |||
| </dependency> | |||
| </dependencies> | |||
| @@ -27,14 +27,6 @@ public class AuthMappingItemProcessorService implements ItemProcessor<AuthMappin | |||
| @Autowired | |||
| private EmpDao empDao; | |||
| @Autowired | |||
| private AuthMappingDao authMappingDao; | |||
| @Autowired | |||
| private DeviceServiceSupport deviceService; | |||
| @Autowired | |||
| private RedisUtils redisUtils; | |||
| @Override | |||
| public AuthMapping process(AuthMapping authMapping) throws Exception { | |||
| @@ -52,24 +44,7 @@ public class AuthMappingItemProcessorService implements ItemProcessor<AuthMappin | |||
| int status = jsonObject.getInteger("status"); | |||
| if (status == 0) { | |||
| String mis = DateUtils.getMillsSecondsDouble(); | |||
| authMappingDao.updateTsByEmp(authMapping.getEmpId(), mis); | |||
| List<AuthMapping> authMappings = authMappingDao.getByEmp(authMapping.getEmpId()); | |||
| List<String> list = Lists.newArrayList(); | |||
| authMappings.forEach(am->{ | |||
| list.add(am.getDevId()); | |||
| }); | |||
| deviceService.updateAuthTs(list, mis); | |||
| for (String a : list) { | |||
| if (StringUtils.isNotEmpty(a) && Emp.STATUS_NORMAL.equals(emp.getStatus())) { | |||
| redisUtils.setGroupString(a+":face-latest-ts", mis); | |||
| } | |||
| } | |||
| empService.updAuthMapping(emp); | |||
| } | |||
| } | |||
| return null; | |||
| @@ -629,21 +629,18 @@ public class EmpServiceSupport | |||
| return new ResponseInfo(ResponseCode.FACE_FETCH_FAIL, hasObj.getString("errMsg")); | |||
| } | |||
| JSONObject obj = faceServiceSupport.hasface(token, id, base64Image); | |||
| JSONObject faceRectangle = obj.getJSONObject("data"); | |||
| int status = obj.getInteger("status"); | |||
| JSONObject obj = faceServiceSupport.getFaceExtraction(token, id, base64Image); | |||
| if (status != 0) { | |||
| return new ResponseInfo(ResponseCode.FACE_FETCH_FAIL, obj.getString("errMsg")); | |||
| } | |||
| if (!ObjectUtils.anyNotNull(faceRectangle) || faceRectangle.getJSONObject("faceRectangle").isEmpty()) { | |||
| return new ResponseInfo(ResponseCode.CW_FACE_IMG_NO_FACE, "no face"); | |||
| if (!obj.containsKey("feature")) { | |||
| return new ResponseInfo(ResponseCode.FACE_FETCH_FAIL, obj.getString("errorMessage")); | |||
| } | |||
| Date date = new Date(); | |||
| emp.setUpdateTime(date); | |||
| emp.setFaceImageName(newFileName); | |||
| JSONArray array = faceRectangle.getJSONArray("feature"); | |||
| JSONArray array = obj.getJSONArray("feature"); | |||
| EmpFaceFeature empFaceFeature = new EmpFaceFeature(); | |||
| empFaceFeature.setEmpId(id); | |||
| @@ -671,8 +668,6 @@ public class EmpServiceSupport | |||
| } | |||
| this.updAuthMapping(emp); | |||
| // } | |||
| return new ResponseInfo(auditStatus); | |||
| } catch (UnsupportedFormatException e){ | |||
| @@ -680,6 +675,8 @@ public class EmpServiceSupport | |||
| } catch (IOException e) { | |||
| e.printStackTrace(); | |||
| return new ResponseInfo(ResponseCode.FILE_UPLOAD_FAIL); | |||
| } catch (Exception e) { | |||
| throw new RuntimeException(e); | |||
| } | |||
| } | |||
| @@ -1140,19 +1137,15 @@ public class EmpServiceSupport | |||
| faceImage = faceImage.replaceAll("data:image/jpeg;base64,", ""); | |||
| JSONObject faceRectangle = faceServiceSupport.hasface("", emp.getId(), faceImage); | |||
| System.err.println("======face===REG---ssss"); | |||
| System.err.println(faceRectangle.toJSONString()); | |||
| System.err.println("======face===REG---eeee"); | |||
| int status = faceRectangle.getInteger("status"); | |||
| faceRectangle = faceRectangle.getJSONObject("data"); | |||
| String userName = emp.getRealName(); | |||
| if (status != 0) { | |||
| return "抱歉,您的账号 " + userName + " 注册失败,"+faceRectangle.getString("errMsg"); | |||
| JSONObject faceRectangle = null; | |||
| try { | |||
| faceRectangle = faceServiceSupport.getFaceExtraction("", emp.getId(), faceImage); | |||
| } catch (Exception e) { | |||
| return e.getMessage(); | |||
| } | |||
| if (!ObjectUtils.anyNotNull(faceRectangle) || faceRectangle.getJSONObject("faceRectangle").isEmpty()) { | |||
| return "抱歉,您的账号 " + userName + " 注册失败,上传的头像未找到人脸!"; | |||
| String userName = emp.getRealName(); | |||
| if (!faceRectangle.containsKey("feature")) { | |||
| return "抱歉,您的账号 " + userName + " 注册失败,"+faceRectangle.getString("errorMessage"); | |||
| } | |||
| JSONObject json = imageUtil.base64ToStorage(faceImage, true); | |||
| @@ -1219,7 +1212,7 @@ public class EmpServiceSupport | |||
| int status = getJson.getInteger("status"); | |||
| String featureStr = ""; | |||
| if (0 == status) { | |||
| featureStr = getJson.getString("feature"); | |||
| featureStr = getJson.getJSONArray("feature").toJSONString(); | |||
| } else { | |||
| return getJson; | |||
| } | |||
| @@ -1253,11 +1246,15 @@ public class EmpServiceSupport | |||
| faceImage = faceImage.replaceAll("data:image/jpeg;base64,", ""); | |||
| JSONObject faceRectangle = faceServiceSupport.hasface("", emp.getId(), faceImage); | |||
| faceRectangle = faceRectangle.getJSONObject("data"); | |||
| JSONObject faceRectangle = null; | |||
| try { | |||
| faceRectangle = faceServiceSupport.getFaceExtraction("", emp.getId(), faceImage); | |||
| } catch (Exception e) { | |||
| throw new RuntimeException(e); | |||
| } | |||
| JSONObject json = imageUtil.base64ToStorage(faceImage, true); | |||
| if (json.getBoolean("ok")) { | |||
| if (faceRectangle.containsKey("feature")) { | |||
| String imgUrl = json.getString("imgUrl"); | |||
| emp.setFaceImageName(imgUrl); | |||
| @@ -5,7 +5,9 @@ import com.alibaba.fastjson.JSON; | |||
| import com.alibaba.fastjson.JSONArray; | |||
| import com.alibaba.fastjson.JSONObject; | |||
| import com.jeesite.common.config.Global; | |||
| import com.jeesite.common.lang.StringUtils; | |||
| import com.lecoo.kjg.web.sys.utils.ImageUtil; | |||
| import com.lecoo.kjg.web.utils.OkHttpUtil; | |||
| import kong.unirest.HttpResponse; | |||
| import kong.unirest.Unirest; | |||
| import lombok.extern.slf4j.Slf4j; | |||
| @@ -24,6 +26,7 @@ import java.io.BufferedReader; | |||
| import java.io.IOException; | |||
| import java.io.InputStreamReader; | |||
| import java.util.Map; | |||
| import java.util.UUID; | |||
| @Slf4j | |||
| @Component | |||
| @@ -132,189 +135,55 @@ public class FaceServiceSupport { | |||
| return token;*/ | |||
| } | |||
| public JSONObject getFaceExtraction(String token, String imageId, String imgBase64) { | |||
| /********CURL 请求方式********/ | |||
| /*JSONObject paramJson = new JSONObject(); | |||
| paramJson.put("imageId", imageId); | |||
| paramJson.put("base64Data", imgBase64); | |||
| paramJson.put("detect", 1); | |||
| String content = paramJson.toJSONString(); | |||
| String[] cmds = {"curl", "--location", "--request", "POST", faceServer + extractionPath, "--header", "Authorization: Bearer "+token, "--header", "Content-Type: application/json", "--data", content}; | |||
| String res = execCurl(cmds); | |||
| log.info("----------------"); | |||
| log.info(faceServer); | |||
| log.info("----------------"); | |||
| log.info("Face Engine-detectFace return >> " + res); | |||
| JSONObject json = JSONObject.parseObject(res); | |||
| JSONObject data = json.getJSONArray("result").getJSONObject(0); | |||
| return data;*/ | |||
| public JSONObject getFaceExtraction(String token, String imageId, String imgBase64) throws Exception { | |||
| imgBase64 = imgBase64.replace("data:image/jpeg;base64,", ""); | |||
| JSONObject j1 = new JSONObject().fluentPut("faceName","faceName").fluentPut("base64Data", imgBase64).fluentPut("detect", true).fluentPut("quality", true); | |||
| JSONArray jsonArray = new JSONArray().fluentAdd(j1); | |||
| System.out.println("获取特征值地址:"+faceServer + extractionPath); | |||
| System.out.println("获取特征值地址参数:"+jsonArray.toJSONString()); | |||
| String result = OkHttpUtil.postCvJson(faceServer+extractionPath, new JSONObject().fluentPut("images", jsonArray)); | |||
| System.err.println("获取特征值结果:"+result); | |||
| /********restTemplate 请求方式*************/ | |||
| HttpHeaders headers = new HttpHeaders(); | |||
| headers.setContentType(MediaType.APPLICATION_JSON); | |||
| headers.set("Authorization", "Bearer "+token); | |||
| MultiValueMap<String, Object> map = new LinkedMultiValueMap<String, Object>(); | |||
| map.add("imageId", imageId); | |||
| map.add("base64Data", imgBase64); | |||
| map.add("detect", true); | |||
| map.add("quality", true); | |||
| HttpEntity<Map<String, Object>> entity = new HttpEntity<>(map.toSingleValueMap(), headers); | |||
| // System.err.println(faceServer + extractionPath); | |||
| String emps = Global.getConfig("face.modeUpdEmps"); | |||
| String path = faceServer; | |||
| System.err.println("emps==========1111"); | |||
| System.err.println(emps); | |||
| System.err.println(imageId); | |||
| if (emps.contains(imageId)) { | |||
| System.err.println("---------------uuuuuuuuu"); | |||
| path = updFaceServer; | |||
| } | |||
| System.err.println(faceServer); | |||
| System.err.println(updFaceServer); | |||
| System.err.println(path); | |||
| System.err.println(path + extractionPath); | |||
| System.err.println("emps==========2222"); | |||
| String result = restTemplate.postForObject(path + extractionPath, entity, String.class, "face-detection"); | |||
| // log.info("Face Engine-detectFace return >> " + result); | |||
| JSONObject resultJson = JSON.parseObject(result); | |||
| if (!resultJson.containsKey("errorCode") && 0==resultJson.getInteger("status")) { | |||
| return resultJson.getJSONArray("result").getJSONObject(0).getJSONArray("faces").getJSONObject(0); | |||
| } else { | |||
| return resultJson; | |||
| } | |||
| // System.err.println(resultJson.toJSONString()); | |||
| return resultJson.getJSONArray("result").getJSONObject(0); | |||
| /*****Unirest 请求方式*****/ | |||
| /*JSONObject paramJson = new JSONObject(); | |||
| paramJson.put("imageId", imageId); | |||
| paramJson.put("base64Data", imgBase64); | |||
| paramJson.put("detect", 1); | |||
| String content = paramJson.toJSONString(); | |||
| HttpResponse<String> response = Unirest.post(faceServer + extractionPath) | |||
| .header("Authorization", "Bearer "+token) | |||
| .header("Content-Type", "application/json") | |||
| .body(content) | |||
| .asString(); | |||
| String result = response.getBody(); | |||
| log.info("Face Engine-detectFace return >> " + result); | |||
| JSONObject resultJson = JSON.parseObject(result); | |||
| return resultJson.getJSONArray("result").getJSONObject(0);*/ | |||
| } | |||
| public JSONObject getFaceCheck(String token, String imageId, String imgBase64) throws Exception{ | |||
| /********CURL 请求方式********/ | |||
| /*JSONObject paramJson = new JSONObject(); | |||
| paramJson.put("imageId", imageId); | |||
| paramJson.put("base64Data", imgBase64); | |||
| paramJson.put("detect", 1); | |||
| String content = paramJson.toJSONString(); | |||
| String[] cmds = {"curl", "--location", "--request", "POST", faceServer + extractionPath, "--header", "Authorization: Bearer "+token, "--header", "Content-Type: application/json", "--data", content}; | |||
| String res = execCurl(cmds); | |||
| log.info("----------------"); | |||
| log.info(faceServer); | |||
| log.info("----------------"); | |||
| log.info("Face Engine-detectFace return >> " + res); | |||
| JSONObject json = JSONObject.parseObject(res); | |||
| JSONObject data = json.getJSONArray("result").getJSONObject(0); | |||
| return data;*/ | |||
| /********restTemplate 请求方式*************/ | |||
| try { | |||
| imgBase64 = imgBase64.replaceAll("data:image/jpeg;base64,", ""); | |||
| HttpHeaders headers = new HttpHeaders(); | |||
| headers.setContentType(MediaType.APPLICATION_JSON); | |||
| headers.set("Authorization", "Bearer "+token); | |||
| MultiValueMap<String, Object> map = new LinkedMultiValueMap<String, Object>(); | |||
| // map.add("imageId", imageId); | |||
| // map.add("base64Data", imgBase64); | |||
| JSONArray jsonArray = new JSONArray(); | |||
| JSONObject jsonObject = new JSONObject(); | |||
| jsonObject.put("imageId",imageId); | |||
| jsonObject.put("base64Data",imgBase64); | |||
| jsonArray.add(jsonObject); | |||
| map.add("detect", true); | |||
| map.add("images", jsonArray); | |||
| HttpEntity<Map<String, Object>> entity = new HttpEntity<>(map.toSingleValueMap(), headers); | |||
| System.err.println(faceServer + qualityPath); | |||
| String result = restTemplate.postForObject(faceServer + qualityPath, entity, String.class, "face-detection"); | |||
| // log.info("Face Engine-detectFace return >> " + result); | |||
| JSONObject resultJson = JSON.parseObject(result); | |||
| return resultJson.getJSONArray("result").getJSONObject(0); | |||
| } catch (Exception e) { | |||
| System.err.println("8888err"); | |||
| e.printStackTrace(); | |||
| throw e; | |||
| } | |||
| /*****Unirest 请求方式*****/ | |||
| /*JSONObject paramJson = new JSONObject(); | |||
| paramJson.put("imageId", imageId); | |||
| paramJson.put("base64Data", imgBase64); | |||
| paramJson.put("detect", 1); | |||
| String content = paramJson.toJSONString(); | |||
| HttpResponse<String> response = Unirest.post(faceServer + extractionPath) | |||
| .header("Authorization", "Bearer "+token) | |||
| .header("Content-Type", "application/json") | |||
| .body(content) | |||
| .asString(); | |||
| String result = response.getBody(); | |||
| log.info("Face Engine-detectFace return >> " + result); | |||
| imgBase64 = imgBase64.replace("data:image/jpeg;base64,", ""); | |||
| JSONObject jsonObject = new JSONObject(); | |||
| jsonObject.put("imageId", StringUtils.isEmpty(imageId)? UUID.randomUUID().toString():imageId); | |||
| jsonObject.put("base64Data",imgBase64); | |||
| jsonObject.put("detect", true); | |||
| JSONArray jsonArray = new JSONArray().fluentAdd(jsonObject); | |||
| System.out.println("获取特征值参数:"+jsonArray.toJSONString()); | |||
| System.out.println("获取特征值地址:"+faceServer + qualityPath); | |||
| String result = OkHttpUtil.postCvJson(faceServer+qualityPath, new JSONObject().fluentPut("images", jsonArray)); | |||
| System.err.println("人脸检测结果:"+result); | |||
| JSONObject resultJson = JSON.parseObject(result); | |||
| return resultJson.getJSONArray("result").getJSONObject(0);*/ | |||
| return resultJson.getJSONArray("result").getJSONObject(0); | |||
| } | |||
| public JSONObject hasface(String token, String imageId, String imgBase64) { | |||
| /********CURL 请求方式********/ | |||
| /*JSONObject paramJson = new JSONObject(); | |||
| paramJson.put("imageId", imageId); | |||
| paramJson.put("base64Data", imgBase64); | |||
| paramJson.put("detect", 1); | |||
| String content = paramJson.toJSONString(); | |||
| String[] cmds = {"curl", "--location", "--request", "POST", faceServer + extractionPath, "--header", "Authorization: Bearer "+token, "--header", "Content-Type: application/json", "--data", content}; | |||
| String res = execCurl(cmds); | |||
| log.info("----------------"); | |||
| log.info(faceServer); | |||
| log.info("----------------"); | |||
| log.info("Face Engine-detectFace return >> " + res); | |||
| JSONObject json = JSONObject.parseObject(res); | |||
| JSONObject data = json.getJSONArray("result").getJSONObject(0); | |||
| return data;*/ | |||
| JSONObject json = new JSONObject(); | |||
| try { | |||
| imgBase64 = imgBase64.replaceAll("data:image/jpeg;base64,", ""); | |||
| JSONObject res = this.getFaceExtraction(token, imageId, imgBase64); | |||
| JSONObject obj = res.getJSONArray("faces").getJSONObject(0); | |||
| imgBase64 = imgBase64.replace("data:image/jpeg;base64,", ""); | |||
| JSONObject res = this.getFaceCheck(token, imageId, imgBase64); | |||
| if (!obj.isEmpty()) { | |||
| if (res != null && res.getBoolean("passed")){ | |||
| json.put("status", 0); | |||
| json.put("data", obj); | |||
| json.put("data", res); | |||
| return json; | |||
| } else { | |||
| json.put("status", 500); | |||
| @@ -332,62 +201,17 @@ public class FaceServiceSupport { | |||
| } | |||
| /*****Unirest 请求方式*****/ | |||
| /*JSONObject paramJson = new JSONObject(); | |||
| paramJson.put("imageId", imageId); | |||
| paramJson.put("base64Data", imgBase64); | |||
| paramJson.put("detect", 1); | |||
| String content = paramJson.toJSONString(); | |||
| HttpResponse<String> response = Unirest.post(faceServer + extractionPath) | |||
| .header("Authorization", "Bearer "+token) | |||
| .header("Content-Type", "application/json") | |||
| .body(content) | |||
| .asString(); | |||
| String result = response.getBody(); | |||
| log.info("Face Engine-detectFace return >> " + result); | |||
| JSONObject resultJson = JSON.parseObject(result); | |||
| return resultJson.getJSONArray("result").getJSONObject(0);*/ | |||
| } | |||
| public JSONObject regCheckFace(String token, String imageId, String imgBase64) { | |||
| /********CURL 请求方式********/ | |||
| /*JSONObject paramJson = new JSONObject(); | |||
| paramJson.put("imageId", imageId); | |||
| paramJson.put("base64Data", imgBase64); | |||
| paramJson.put("detect", 1); | |||
| String content = paramJson.toJSONString(); | |||
| String[] cmds = {"curl", "--location", "--request", "POST", faceServer + extractionPath, "--header", "Authorization: Bearer "+token, "--header", "Content-Type: application/json", "--data", content}; | |||
| String res = execCurl(cmds); | |||
| log.info("----------------"); | |||
| log.info(faceServer); | |||
| log.info("----------------"); | |||
| log.info("Face Engine-detectFace return >> " + res); | |||
| JSONObject json = JSONObject.parseObject(res); | |||
| JSONObject data = json.getJSONArray("result").getJSONObject(0); | |||
| return data;*/ | |||
| JSONObject json = new JSONObject(); | |||
| try { | |||
| imgBase64 = imgBase64.replaceAll("data:image/jpeg;base64,", ""); | |||
| imgBase64 = imgBase64.replace("data:image/jpeg;base64,", ""); | |||
| JSONObject res = this.getFaceCheck(token, imageId, imgBase64); | |||
| Boolean passed = res.getBoolean("passed"); | |||
| if (!ObjectUtils.anyNotNull(passed)) { | |||
| json.put("status", 500); | |||
| json.put("data", null); | |||
| json.put("errMsg", "所拍摄的照片重人脸不存在"); | |||
| return json; | |||
| } | |||
| if (!passed) { | |||
| json.put("status", 500); | |||
| json.put("data", res); | |||
| if (res == null || !res.getBoolean("passed")){ | |||
| json.fluentPut("status", 500).fluentPut("data", res); | |||
| double blur = res.getDouble("blur"); | |||
| double pose = res.getDouble("pose"); | |||
| double occ = res.getDouble("occ"); | |||
| @@ -404,17 +228,12 @@ public class FaceServiceSupport { | |||
| errMsg = "人脸检测失败,光线太暗,请到明亮点的地方重新拍摄"; | |||
| } | |||
| json.put("errMsg", errMsg); | |||
| json.put("data", res); | |||
| json.fluentPut("errMsg", errMsg).fluentPut("data", res); | |||
| } else { | |||
| json.put("status", 0); | |||
| json.put("data", res); | |||
| json.put("errMsg", ""); | |||
| json.fluentPut("status", 0).fluentPut("data", res).fluentPut("errMsg", ""); | |||
| } | |||
| return json; | |||
| } catch (Exception e) { | |||
| e.printStackTrace(); | |||
| json.put("status", 500); | |||
| @@ -422,26 +241,6 @@ public class FaceServiceSupport { | |||
| json.put("errMsg", e.getMessage()); | |||
| return json; | |||
| } | |||
| /*****Unirest 请求方式*****/ | |||
| /*JSONObject paramJson = new JSONObject(); | |||
| paramJson.put("imageId", imageId); | |||
| paramJson.put("base64Data", imgBase64); | |||
| paramJson.put("detect", 1); | |||
| String content = paramJson.toJSONString(); | |||
| HttpResponse<String> response = Unirest.post(faceServer + extractionPath) | |||
| .header("Authorization", "Bearer "+token) | |||
| .header("Content-Type", "application/json") | |||
| .body(content) | |||
| .asString(); | |||
| String result = response.getBody(); | |||
| log.info("Face Engine-detectFace return >> " + result); | |||
| JSONObject resultJson = JSON.parseObject(result); | |||
| return resultJson.getJSONArray("result").getJSONObject(0);*/ | |||
| } | |||
| @@ -456,17 +255,18 @@ public class FaceServiceSupport { | |||
| json.put("errMsg", "imagePath不能为空"); | |||
| return json; | |||
| } | |||
| JSONObject faceRectangle = this.hasface("", empId, base64Image); | |||
| int status = faceRectangle.getInteger("status"); | |||
| faceRectangle = faceRectangle.getJSONObject("data"); | |||
| if (status != 0) { | |||
| json.put("status",status); | |||
| json.put("errMsg"," 特征值提取失败,"+faceRectangle.getString("errMsg")); | |||
| JSONObject faceRectangle = null; | |||
| try { | |||
| faceRectangle = this.getFaceExtraction("", empId, base64Image); | |||
| } catch (Exception e) { | |||
| json.put("status",504); | |||
| json.put("errMsg",e.getMessage()); | |||
| return json; | |||
| } | |||
| if (!ObjectUtils.anyNotNull(faceRectangle) || faceRectangle.getJSONObject("faceRectangle").isEmpty()) { | |||
| json.put("status",504); | |||
| json.put("errMsg"," 特征值提取失败,上传的头像未找到人脸!"); | |||
| if (!faceRectangle.containsKey("feature")) { | |||
| json.put("status",500); | |||
| json.put("errMsg"," 特征值提取失败,"+faceRectangle.getString("errorMessage")); | |||
| return json; | |||
| } | |||
| @@ -19,6 +19,7 @@ import sun.misc.BASE64Encoder; | |||
| import javax.imageio.ImageIO; | |||
| import java.awt.image.BufferedImage; | |||
| import java.io.*; | |||
| import java.nio.file.Files; | |||
| import java.util.Base64; | |||
| import java.util.Map; | |||
| import java.util.UUID; | |||
| @@ -200,11 +201,23 @@ public class ImageUtil { | |||
| */ | |||
| public static String convertFileToBase64(String imgPath) { | |||
| String base64Str = ""; | |||
| // 读取图片字节数组 | |||
| /*// 读取图片字节数组 | |||
| try { | |||
| InputStream in = new FileInputStream(imgPath); | |||
| base64Str = convertToBase64(in); | |||
| in.close(); | |||
| } catch (IOException e) { | |||
| e.printStackTrace(); | |||
| }*/ | |||
| File imageFile = new File(imgPath); | |||
| try { | |||
| // 读取图片文件 | |||
| byte[] imageBytes = Files.readAllBytes(imageFile.toPath()); | |||
| // 将图片数据编码为Base64 | |||
| base64Str = Base64.getEncoder().encodeToString(imageBytes); | |||
| } catch (IOException e) { | |||
| e.printStackTrace(); | |||
| } | |||
| @@ -505,7 +505,8 @@ public class Account2Controller extends WxBaseController { | |||
| response.addCookie(cookie); | |||
| return "themes/default/modules/sys/account/registerEmp"; | |||
| return "themes/default/modules/sys/account/registerUser"; | |||
| // return "themes/default/modules/sys/account/registerEmp"; | |||
| } | |||
| @@ -980,8 +981,6 @@ public class Account2Controller extends WxBaseController { | |||
| userCode = DesUtils.decode(userCode, secretKey); | |||
| User user = UserUtils.get(userCode); | |||
| if (null == user) { | |||
| return outputError(1, "绑定失败,未找到对应账户!"); | |||
| } | |||
| @@ -306,20 +306,23 @@ public class CommonApiController extends BaseController { | |||
| public Object syncFace(@RequestBody JSONObject map, HttpServletRequest request) { | |||
| String deviceId = map.getString("devId"); | |||
| String timestamp = map.getString("timestamp"); | |||
| String nowTs = map.getString("now_ts"); | |||
| Double timestamp = map.getDouble("timestamp"); | |||
| NumberFormat nf = NumberFormat.getInstance(); | |||
| nf.setGroupingUsed(false); | |||
| String formatTs = org.apache.commons.lang3.StringUtils.rightPad(nf.format(timestamp), 13, '0'); | |||
| System.out.println("syncFace: timestamp==" + formatTs); | |||
| Double nowTs = map.getDouble("now_ts"); | |||
| String ts = org.apache.commons.lang3.StringUtils.rightPad(nf.format(nowTs), 13, '0'); | |||
| int maxCnt = map.getInteger("max_cnt"); | |||
| String sign = map.getString("sign"); | |||
| MyResponse myResponse = commonCheck(deviceId, timestamp, sign); | |||
| MyResponse myResponse = commonCheck(deviceId, formatTs, sign); | |||
| if (myResponse.getStatus() != 0) { | |||
| return myResponse; | |||
| } | |||
| NumberFormat nf = NumberFormat.getInstance(); | |||
| nf.setGroupingUsed(false); | |||
| System.err.println(nowTs); | |||
| String ts = nf.format(Double.parseDouble(nowTs)); | |||
| AccessControl ac = accessControlDao.findAccessControlByDev(deviceId); | |||
| List<AuthMapping> list = authMappingDao.getByDevAndTime(ac.getAccessControlId(), ts, maxCnt); | |||
| @@ -379,7 +382,10 @@ public class CommonApiController extends BaseController { | |||
| String imgbase64 = map.getString("imgbase64"); | |||
| String sign = map.getString("sign"); | |||
| MyResponse myResponse = commonCheck(deviceId, timestamp, sign); | |||
| NumberFormat nf = NumberFormat.getInstance(); | |||
| nf.setGroupingUsed(false); | |||
| MyResponse myResponse = commonCheck(deviceId, nf.format(Double.parseDouble(timestamp)), sign); | |||
| if (myResponse.getStatus() != 0) { | |||
| return myResponse; | |||
| } | |||
| @@ -445,7 +451,11 @@ public class CommonApiController extends BaseController { | |||
| return myResponse; | |||
| } | |||
| myResponse = commonCheck(devId, timestamp, sign); | |||
| NumberFormat nf = NumberFormat.getInstance(); | |||
| nf.setGroupingUsed(false); | |||
| myResponse = commonCheck(devId, nf.format(Double.parseDouble(timestamp)), sign); | |||
| if (myResponse.getStatus() != 0) { | |||
| return myResponse; | |||
| } | |||
| @@ -1335,8 +1345,41 @@ public class CommonApiController extends BaseController { | |||
| @PostMapping(value = "remoteHandle") | |||
| @ResponseBody | |||
| @Transactional | |||
| public String remoteHandle(@RequestParam(value = "devs[]") List<String> devs, @RequestParam(value = "act") String act) { | |||
| public MyResponse remoteHandle(@RequestParam(value = "devs[]") List<String> devs, @RequestParam(value = "act") String act, HttpServletRequest request) { | |||
| //将devs拼接成字符串,按逗号分割开 | |||
| String sign = request.getHeader("sign"); | |||
| String ts = request.getHeader("ts"); | |||
| System.err.println("----------sign check start----------"); | |||
| if (ts == null || ts.isEmpty()) { | |||
| return new MyResponse(400, "ts is null"); | |||
| } | |||
| if (sign == null || sign.isEmpty()) { | |||
| return new MyResponse(400, "sign is null"); | |||
| } | |||
| ts.replace(".", ""); | |||
| Long tsVal = Long.parseLong(ts); | |||
| if (ts.length() == 10) { | |||
| // 将10位时间戳转为13位 | |||
| tsVal *= 1000; | |||
| } | |||
| Long currentTs = System.currentTimeMillis(); | |||
| System.err.println(currentTs); | |||
| System.err.println(tsVal); | |||
| if (currentTs - tsVal > 1000 * 60 || tsVal - currentTs > 1000 * 60){//时间误差正负1分钟内为合法 | |||
| return new MyResponse(400, "请求时间戳ts非法"); | |||
| } | |||
| devs.sort(null); | |||
| String singStr = String.join("_", devs) + act + ts; | |||
| System.err.println(singStr); | |||
| String signStr = DigestUtils.md5DigestAsHex(singStr.getBytes()); | |||
| System.err.println(signStr); | |||
| System.err.println(sign); | |||
| System.err.println("----------sign check end----------"); | |||
| if (!sign.equals(signStr)) { | |||
| return output(ResponseCode.AUTH_NOT_PASS); | |||
| } | |||
| String act_code = ""; | |||
| switch (act) { | |||
| case "enterOpen": | |||
| @@ -1362,11 +1405,11 @@ public class CommonApiController extends BaseController { | |||
| break; | |||
| } | |||
| List<String> successDev = com.google.common.collect.Lists.newArrayList(); | |||
| List<String> failMsg = com.google.common.collect.Lists.newArrayList(); | |||
| List<String> successDev = com.beust.jcommander.internal.Lists.newArrayList(); | |||
| List<String> failMsg = com.beust.jcommander.internal.Lists.newArrayList(); | |||
| for (String deviceId : devs) { | |||
| Device gate = deviceDao.findByDevId(deviceId); | |||
| List<Device> lists = Lists.newArrayList(); | |||
| List<Device> lists = com.beust.jcommander.internal.Lists.newArrayList(); | |||
| if (act_code.equals("netAdbOpen") || act_code.equals("netAdbClose")) { | |||
| lists = deviceService.getPads(gate); | |||
| } else { | |||
| @@ -1409,11 +1452,9 @@ public class CommonApiController extends BaseController { | |||
| } | |||
| if (StringUtils.isEmpty(endMsg)) { | |||
| return renderResult(Global.TRUE, "指令发送成功"); | |||
| return outputSuccess("指令发送成功"); | |||
| } | |||
| return renderResult(Global.TRUE, endMsg); | |||
| return outputSuccess(endMsg); | |||
| } | |||
| @PostMapping(value = "remoteDev") | |||
| @@ -84,7 +84,6 @@ public class FaceApiController extends BaseController { | |||
| String base64Image = ""; | |||
| JSONObject json; | |||
| JSONArray obj = new JSONArray(); | |||
| JSONObject faceRectangle = new JSONObject(); | |||
| EmpFaceFeature empFaceFeature = emp.getEmpFaceFeature(); | |||
| if (!(ObjectUtils.anyNotNull(empFaceFeature) && StringUtils.isNotEmpty(empFaceFeature.getFaceFeature()))){ | |||
| @@ -103,11 +102,12 @@ public class FaceApiController extends BaseController { | |||
| json = faceServiceSupport.getFaceExtraction(token, empId, base64Image); | |||
| obj = json.getJSONArray("faces").getJSONObject(0).getJSONArray("feature"); | |||
| faceRectangle = json.getJSONArray("faces").getJSONObject(0).getJSONObject("faceRectangle"); | |||
| if (!faceRectangle.isEmpty()) { | |||
| if (json.containsKey("feature")) { | |||
| obj = json.getJSONArray("feature"); | |||
| faceFlag = true; | |||
| } else { | |||
| return "人脸特征值提取失败!"; | |||
| } | |||
| } catch (Exception e) { | |||
| e.printStackTrace(); | |||
| @@ -0,0 +1,332 @@ | |||
| package com.lecoo.kjg.web.utils; | |||
| /** | |||
| * @author yk | |||
| * @description | |||
| * @date 2024-05-07 18:08 | |||
| */ | |||
| import com.alibaba.fastjson.JSON; | |||
| import com.alibaba.fastjson.JSONObject; | |||
| import okhttp3.Call; | |||
| import okhttp3.Callback; | |||
| import okhttp3.FormBody; | |||
| import okhttp3.MediaType; | |||
| import okhttp3.OkHttpClient; | |||
| import okhttp3.Request; | |||
| import okhttp3.RequestBody; | |||
| import okhttp3.Response; | |||
| import javax.net.ssl.SSLContext; | |||
| import javax.net.ssl.SSLSocketFactory; | |||
| import javax.net.ssl.TrustManager; | |||
| import javax.net.ssl.X509TrustManager; | |||
| import java.io.IOException; | |||
| import java.net.URLEncoder; | |||
| import java.security.SecureRandom; | |||
| import java.security.cert.X509Certificate; | |||
| import java.util.LinkedHashMap; | |||
| import java.util.Map; | |||
| import java.util.concurrent.Semaphore; | |||
| import java.util.concurrent.TimeUnit; | |||
| public class OkHttpUtil { | |||
| private static volatile OkHttpClient okHttpClient = null; | |||
| private static volatile Semaphore semaphore = null; | |||
| private Map<String, String> headerMap; | |||
| private Map<String, String> paramMap; | |||
| private String url; | |||
| private Request.Builder request; | |||
| /** | |||
| * 初始化okHttpClient,并且允许https访问 | |||
| */ | |||
| private OkHttpUtil() { | |||
| if (okHttpClient == null) { | |||
| synchronized (OkHttpUtil.class) { | |||
| if (okHttpClient == null) { | |||
| TrustManager[] trustManagers = buildTrustManagers(); | |||
| okHttpClient = new OkHttpClient.Builder() | |||
| .connectTimeout(15, TimeUnit.SECONDS) | |||
| .writeTimeout(20, TimeUnit.SECONDS) | |||
| .readTimeout(20, TimeUnit.SECONDS) | |||
| .sslSocketFactory(createSSLSocketFactory(trustManagers), (X509TrustManager) trustManagers[0]) | |||
| .hostnameVerifier((hostName, session) -> true) | |||
| .retryOnConnectionFailure(true) | |||
| .build(); | |||
| addHeader("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36"); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| /** | |||
| * 用于异步请求时,控制访问线程数,返回结果 | |||
| * | |||
| * @return | |||
| */ | |||
| private static Semaphore getSemaphoreInstance() { | |||
| //只能1个线程同时访问 | |||
| synchronized (OkHttpUtil.class) { | |||
| if (semaphore == null) { | |||
| semaphore = new Semaphore(0); | |||
| } | |||
| } | |||
| return semaphore; | |||
| } | |||
| /** | |||
| * 创建OkHttpUtil | |||
| * | |||
| * @return | |||
| */ | |||
| public static OkHttpUtil builder() { | |||
| return new OkHttpUtil(); | |||
| } | |||
| /** | |||
| * 添加url | |||
| * | |||
| * @param url | |||
| * @return | |||
| */ | |||
| public OkHttpUtil url(String url) { | |||
| this.url = url; | |||
| return this; | |||
| } | |||
| /** | |||
| * 添加参数 | |||
| * | |||
| * @param key 参数名 | |||
| * @param value 参数值 | |||
| * @return | |||
| */ | |||
| public OkHttpUtil addParam(String key, String value) { | |||
| if (paramMap == null) { | |||
| paramMap = new LinkedHashMap<>(16); | |||
| } | |||
| paramMap.put(key, value); | |||
| return this; | |||
| } | |||
| /** | |||
| * 添加请求头 | |||
| * | |||
| * @param key 参数名 | |||
| * @param value 参数值 | |||
| * @return | |||
| */ | |||
| public OkHttpUtil addHeader(String key, String value) { | |||
| if (headerMap == null) { | |||
| headerMap = new LinkedHashMap<>(16); | |||
| } | |||
| headerMap.put(key, value); | |||
| return this; | |||
| } | |||
| /** | |||
| * 初始化get方法 | |||
| * | |||
| * @return | |||
| */ | |||
| public OkHttpUtil get() { | |||
| request = new Request.Builder().get(); | |||
| StringBuilder urlBuilder = new StringBuilder(url); | |||
| if (paramMap != null) { | |||
| urlBuilder.append("?"); | |||
| try { | |||
| for (Map.Entry<String, String> entry : paramMap.entrySet()) { | |||
| urlBuilder.append(URLEncoder.encode(entry.getKey(), "utf-8")). | |||
| append("="). | |||
| append(URLEncoder.encode(entry.getValue(), "utf-8")). | |||
| append("&"); | |||
| } | |||
| } catch (Exception e) { | |||
| e.printStackTrace(); | |||
| } | |||
| urlBuilder.deleteCharAt(urlBuilder.length() - 1); | |||
| } | |||
| request.url(urlBuilder.toString()); | |||
| return this; | |||
| } | |||
| /** | |||
| * 初始化post方法 | |||
| * | |||
| * @param isJsonPost true等于json的方式提交数据,类似postman里post方法的raw | |||
| * false等于普通的表单提交 | |||
| * @return | |||
| */ | |||
| public OkHttpUtil post(boolean isJsonPost) { | |||
| RequestBody requestBody; | |||
| if (isJsonPost) { | |||
| String json = ""; | |||
| if (paramMap != null) { | |||
| json = JSON.toJSONString(paramMap); | |||
| } | |||
| requestBody = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), json); | |||
| } else { | |||
| FormBody.Builder formBody = new FormBody.Builder(); | |||
| if (paramMap != null) { | |||
| paramMap.forEach(formBody::add); | |||
| } | |||
| requestBody = formBody.build(); | |||
| } | |||
| request = new Request.Builder().post(requestBody).url(url); | |||
| return this; | |||
| } | |||
| /** | |||
| * 同步请求 | |||
| * | |||
| * @return | |||
| */ | |||
| public String sync() { | |||
| setHeader(request); | |||
| try { | |||
| Response response = okHttpClient.newCall(request.build()).execute(); | |||
| assert response.body() != null; | |||
| return response.body().string(); | |||
| } catch (IOException e) { | |||
| e.printStackTrace(); | |||
| return "请求失败:" + e.getMessage(); | |||
| } | |||
| } | |||
| /** | |||
| * 异步请求,有返回值 | |||
| */ | |||
| public String async() { | |||
| StringBuilder buffer = new StringBuilder(""); | |||
| setHeader(request); | |||
| okHttpClient.newCall(request.build()).enqueue(new Callback() { | |||
| @Override | |||
| public void onFailure(Call call, IOException e) { | |||
| buffer.append("请求出错:").append(e.getMessage()); | |||
| } | |||
| @Override | |||
| public void onResponse(Call call, Response response) throws IOException { | |||
| assert response.body() != null; | |||
| buffer.append(response.body().string()); | |||
| getSemaphoreInstance().release(); | |||
| } | |||
| }); | |||
| try { | |||
| getSemaphoreInstance().acquire(); | |||
| } catch (InterruptedException e) { | |||
| e.printStackTrace(); | |||
| } | |||
| return buffer.toString(); | |||
| } | |||
| /** | |||
| * 异步请求,带有接口回调 | |||
| * | |||
| * @param callBack | |||
| */ | |||
| public void async(ICallBack callBack) { | |||
| setHeader(request); | |||
| okHttpClient.newCall(request.build()).enqueue(new Callback() { | |||
| @Override | |||
| public void onFailure(Call call, IOException e) { | |||
| callBack.onFailure(call, e.getMessage()); | |||
| } | |||
| @Override | |||
| public void onResponse(Call call, Response response) throws IOException { | |||
| assert response.body() != null; | |||
| callBack.onSuccessful(call, response.body().string()); | |||
| } | |||
| }); | |||
| } | |||
| /** | |||
| * 为request添加请求头 | |||
| * | |||
| * @param request | |||
| */ | |||
| private void setHeader(Request.Builder request) { | |||
| if (headerMap != null) { | |||
| try { | |||
| for (Map.Entry<String, String> entry : headerMap.entrySet()) { | |||
| request.addHeader(entry.getKey(), entry.getValue()); | |||
| } | |||
| } catch (Exception e) { | |||
| e.printStackTrace(); | |||
| } | |||
| } | |||
| } | |||
| /** | |||
| * 生成安全套接字工厂,用于https请求的证书跳过 | |||
| * | |||
| * @return | |||
| */ | |||
| private static SSLSocketFactory createSSLSocketFactory(TrustManager[] trustAllCerts) { | |||
| SSLSocketFactory ssfFactory = null; | |||
| try { | |||
| SSLContext sc = SSLContext.getInstance("SSL"); | |||
| sc.init(null, trustAllCerts, new SecureRandom()); | |||
| ssfFactory = sc.getSocketFactory(); | |||
| } catch (Exception e) { | |||
| e.printStackTrace(); | |||
| } | |||
| return ssfFactory; | |||
| } | |||
| private static TrustManager[] buildTrustManagers() { | |||
| return new TrustManager[]{ | |||
| new X509TrustManager() { | |||
| @Override | |||
| public void checkClientTrusted(X509Certificate[] chain, String authType) { | |||
| } | |||
| @Override | |||
| public void checkServerTrusted(X509Certificate[] chain, String authType) { | |||
| } | |||
| @Override | |||
| public X509Certificate[] getAcceptedIssuers() { | |||
| return new X509Certificate[]{}; | |||
| } | |||
| } | |||
| }; | |||
| } | |||
| /** | |||
| * 自定义一个接口回调 | |||
| */ | |||
| public interface ICallBack { | |||
| void onSuccessful(Call call, String data); | |||
| void onFailure(Call call, String errorMsg); | |||
| } | |||
| /** | |||
| * @Author yangkai | |||
| * @Description 联想研究院新算法,请求模版 | |||
| * @Date 2024/5/8 | |||
| * @Param [url, json] | |||
| * @return java.lang.String | |||
| **/ | |||
| public static String postCvJson(String url, JSONObject json) throws Exception{ | |||
| OkHttpClient client = new OkHttpClient().newBuilder() | |||
| .build(); | |||
| MediaType mediaType = MediaType.parse("application/json"); | |||
| RequestBody body = RequestBody.create(mediaType, json.toJSONString()); | |||
| Request request = new Request.Builder() | |||
| .url(url) | |||
| .method("POST", body) | |||
| .addHeader("Content-Type", "application/json") | |||
| .addHeader("Authorization", "Basic ZmFjZS1tYW5hZ2VtZW50OmZhY2UtbWFuYWdlbWVudA==") | |||
| .build(); | |||
| Response response = client.newCall(request).execute(); | |||
| return response.body().string(); | |||
| } | |||
| } | |||
| @@ -202,15 +202,16 @@ mqttClient: | |||
| serverPort: 1883 | |||
| clientId: mqtt_clientid_dev_2002 | |||
| faceServerII: | |||
| ip: 8.131.78.156 | |||
| ip: 39.105.51.226 | |||
| port: 5000 | |||
| user: lecooai_hw01 | |||
| password: lecooai@2021 | |||
| hasAuthorize: false | |||
| faceServerI: | |||
| ip: 39.105.51.226 | |||
| port: 5000 | |||
| ip: 123.56.73.158 | |||
| port: 30306 | |||
| user: lecooai_hw01 | |||
| password: lecooai@2021 | |||
| hasAuthorize: false | |||
| @@ -36,7 +36,7 @@ spring: | |||
| devtools: | |||
| restart: | |||
| enabled: true | |||
| enabled: false | |||
| # # 缓存配置 | |||
| # redis: | |||
| # # 缓存及会话共享(专业版) | |||
| @@ -48,7 +48,7 @@ spring: | |||
| redis: | |||
| #host: 39.105.85.176 | |||
| host: 127.0.0.1 | |||
| port: 6379 | |||
| port: 6381 | |||
| ssl: false | |||
| database: 0 | |||
| #password: lecooai-redis | |||
| @@ -393,10 +393,12 @@ wx: | |||
| host: 127.0.0.1 | |||
| port: 6379 | |||
| configs: | |||
| - appId: wx80dc26b645077e97 # 第一个公众号的appid | |||
| - appId: wx225662102fc5f39a # 第一个公众号的appid | |||
| # - appId: wx80dc26b645077e97 # 第一个公众号的appid | |||
| # - appId: wxcea6b4840efb906e # 第一个公众号的appid | |||
| # - appId: ENC(5ZzYjATZAQK3mSkZKTPuHEqgIQRv8ADix8SsVZdfeAg=) # 第一个公众号的appid | |||
| secret: 5fea919f2cb1b320cebdb9896f697361 # 公众号的appsecret | |||
| # secret: 5fea919f2cb1b320cebdb9896f697361 # 公众号的appsecret | |||
| secret: ff4080ff5a16a378bd8804acd507d468 # 公众号的appsecret | |||
| # secret: ENC(XHPy8rxb7MlPaeBbmPjHZGu9bqRGWY8IKWCmG3NSwygAMXqcqcFNUksMKukd5eHH) # 公众号的appsecret | |||
| token: 83u4h # 接口配置里的Token值 | |||
| templateSendUrl: http://www.hjkjg.top:49180/sendMsg | |||
| @@ -459,7 +461,7 @@ mqtt: | |||
| # 心跳 | |||
| keepalive: 30 | |||
| httpServer: http://39.105.85.176:8008 | |||
| httpServer: http://172.17.0.1:8008 | |||
| devCmdPath: /api/mqtt_dev_cmd | |||
| @@ -467,9 +469,8 @@ face: | |||
| server: http://${faceServerI.ip}:${faceServerI.port} | |||
| updServer: http://${faceServerII.ip}:${faceServerII.port} | |||
| authorizePath: /authorize | |||
| # extractionPath: /apps/v1/function/cv/face-extraction | |||
| extractionPath: /cv/feature-extraction-service/1.7 | |||
| qualityPath: /cv/quality/1.7 | |||
| extractionPath: /apps/v1/solution/cv/face-extraction | |||
| qualityPath: /apps/v1/solution/cv/face-quality | |||
| modeUpdate: true | |||
| modeUpdEmps: "'beeefac44ef94daca475ff85a5c720cd','65f061754e204484a955aba8154eec14','a0a0f615ec374d9bb1e1ace496e586d7','e83e30d959144a65b83beb3b841c10b5','0601b9fc00204224a671bcd47040be30','7cabfde922354b41ae66841e3d0cc4d3'" | |||
| @@ -0,0 +1,361 @@ | |||
| <% layout('/layouts/default.html', {title: '账号注册', libs: ['validate'], bodyClass: 'login-page'}){ %> | |||
| <% include('/include/upgrade.html'){} // 如果客户浏览器版本过低,则显示浏览器升级提示。 %> | |||
| <link rel="stylesheet" href="${ctxStatic}/icheck/1.0/square/blue.css?${_version}"> | |||
| <link rel="stylesheet" href="${ctxStatic}/jquery-toastr/2.0/toastr.min.css?${_version}"> | |||
| <link rel="stylesheet" href="${ctxStatic}/jquery-plugins/jquery.strength.css?${_version}"> | |||
| <link rel="stylesheet" href="${ctxStatic}/modules/sys/sysLogin.css?${_version}"> | |||
| <style> | |||
| .fa-check{ | |||
| color: #0BB20C !important; | |||
| } | |||
| body .demo-class .layui-layer-btn0{ | |||
| border-color: #E6E3E6; | |||
| background-color: #FFF; | |||
| color: black; | |||
| } | |||
| body .demo-class .layui-layer-btn1{ | |||
| border-color: #4898d5; | |||
| background-color: #2e8ded; | |||
| color: #fff; | |||
| } | |||
| img { | |||
| object-fit: cover !important; | |||
| } | |||
| </style> | |||
| <div class="login-box"> | |||
| <div class="login-logo" style="font-size: 28px;"> | |||
| <b>人脸面部信息注册</b> | |||
| </div> | |||
| <div class="login-box-body"> | |||
| <form id="registerForm" class="layui-form" action="${ctxPath}/account2/reg" method="post" > | |||
| <input type="hidden" id="ipt-openid" name="wxOpenid" value="${openid}"/> | |||
| <input type="hidden" id="avatarImg" name="base64" value=""/> | |||
| <div class="text-center" style="padding-top: 10px;"> | |||
| <a id="upload-img" style="text-decoration: none;display: inline-grid;"> | |||
| <img id="imgObj" src=${isNotEmpty(emp.faceImageName)?"/face01/compress/"+emp.faceImageName:"data:image/jpeg;base64,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"} style="width:120px;height:120px;border-radius: 120px;" onclick="" > | |||
| <% if (isEmpty(emp.faceImageName)) {%> | |||
| <div style="position:relative;display:inline-block;width: 120px;background-color: rgb(0 0 0 / 20%);color: #ff0000;top: -69px;">点击添加人脸照片</div> | |||
| <% } %> | |||
| </a> | |||
| </div> | |||
| <div class="form-group has-feedback"> | |||
| <select name="officeCode" id="officeCode" class="required"> | |||
| <option selected="selected" value="" style="display: none;">-----请选择所属公司-----</option> | |||
| <% | |||
| for(office in offices){ | |||
| print('<option value="' + office.officeCode + '">' + office.officeName + '</option>'); | |||
| } | |||
| %> | |||
| </select> | |||
| </div> | |||
| <div class="layui-form-item has-feedback"> | |||
| <span class="fa fa-user form-control-feedback"></span> | |||
| <input type="text" id="reg_loginCode" name="loginCode" class="layui-input form-control required" lay-verify="" data-msg-required="请填写姓名." placeholder="姓名" /> | |||
| <!-- <span class="text-red" style="font-size: 12px;">* 姓名提交后不可修改,请谨慎填写,以免无法过审</span>--> | |||
| </div> | |||
| <div class="layui-form-item has-feedback"> | |||
| <span class="fa fa-phone-square form-control-feedback"></span> | |||
| <input type="text" id="mobile" name="mobile" class="layui-input form-control required isMobile isExsitPhone" lay-verify="" data-msg-required="请填写手机号." placeholder="手机号" /> | |||
| </div> | |||
| <div class="layui-form-item" style="border: 1px solid #e8e8e8;display: none;"> | |||
| <label class="layui-form-label" style="text-align: left;padding-left: 9px;color: #a1a1a1;">性别</label> | |||
| <div class="layui-input-block" style="text-align: right;"> | |||
| <input type="radio" name="gender" checked=true id="gender" value="1" title="男" > | |||
| <input type="radio" name="gender" id="gender" value="2" title="女"> | |||
| </div> | |||
| </div> | |||
| <!--<div class="form-group has-feedback"> | |||
| <span class="fa fa-lock form-control-feedback"></span> | |||
| <input type="password" autocomplete="off" id="reg_password" name="password" | |||
| class="form-control required" data-msg-required="请填写登录密码." | |||
| rangelength="1,50" data-msg-rangelength="登录密码长度不能小于1并大于50个字符." | |||
| placeholder="登录密码" /> | |||
| </div> | |||
| <div class="form-group has-feedback"> | |||
| <span class="fa fa-lock form-control-feedback"></span> | |||
| <input type="password" autocomplete="off" id="reg_confirmPassword" name="confirmPassword" | |||
| class="form-control required" data-msg-required="请再填一次登录密码." | |||
| rangelength="3,50" data-msg-rangelength="登录密码长度不能小于3并大于50个字符." | |||
| equalTo="#reg_password" data-msg-equalTo="填写的密码与登录密码不同." | |||
| placeholder="再填一次登录密码" /> | |||
| </div>--> | |||
| <div class="row"> | |||
| <div class="col-xs-12"> | |||
| <button type="button" class="btn btn-primary btn-block btn-flat layui-btn" lay-submit="" id="btnSubmit" onclick="checkOk();">${text('提交')}</button> | |||
| </div> | |||
| </div> | |||
| <div class="clearfix"></div> | |||
| </form> | |||
| </div> | |||
| <!--<iframe id="myFrame" name="myFrame" scrolling="yes" frameborder="0" style="width:100%;height:6.6rem;"></iframe>--> | |||
| </div> | |||
| <div id="new_person_layer" class="layui_pop" style="display: none;" > | |||
| <div class="layui-form-item layui_pop_header" style="margin-bottom: 10px !important;"> | |||
| <div class="layui_header_title">确认账户</div> | |||
| <div class="layui_header_close"></div> | |||
| </div> | |||
| <form class="layui-form" action="" style="padding: 0 15px 0px 15px;"> | |||
| <div class="layui-form-item text-center"><p>系统检测到您注册的部门中存在同名账户,这是您吗?</p></div> | |||
| <div class="layui-form-item text-center"><img id="avtar-img" src=${isNotEmpty(emp.faceImageName)?"/face01/compress/"+emp.faceImageName:"data:image/jpeg;base64,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"} style="width:120px;height:120px;border-radius: 120px;" onclick="" ></div> | |||
| </form> | |||
| </div> | |||
| <style> | |||
| .layui_pop_header { | |||
| margin-bottom: 10px !important; | |||
| } | |||
| .layui_pop .layui-form { | |||
| padding: 0 15px 0px 15px; | |||
| } | |||
| </style> | |||
| <% } %> | |||
| <script>var secretKey = '${@Global.getConfig("shiro.loginSubmit.secretKey")}';</script> | |||
| <script src="${ctxStatic}/js/jweixin-1.4.0.js?${_version}"></script> | |||
| <script src="${ctxStatic}/common/des.js?${_version}"></script> | |||
| <script src="${ctxStatic}/jquery-toastr/2.0/toastr.min.js?${_version}"></script> | |||
| <script src="${ctxStatic}/jquery-plugins/jquery.strength.js?${_version}"></script> | |||
| <script src="${ctxStatic}/modules/sys/registerUser.js?${_version}"></script> | |||
| <script> | |||
| function checkOk(){ | |||
| var name = $("#reg_loginCode").val(); | |||
| var base64 = $("#avatarImg").val(); | |||
| var phone = $("#mobile").val(); | |||
| var officeCode = $("#officeCode option:selected").val(); | |||
| console.log(officeCode==""); | |||
| if ($("#registerForm").valid() && name && officeCode) { | |||
| $.ajax('/api/v1/emp/getByName',{ | |||
| method: "get", dataType: "json", | |||
| data: { | |||
| "name": name, | |||
| "officeCode": officeCode, | |||
| }, | |||
| async:false, | |||
| success: function (res) { | |||
| if(res.data.length<1) { | |||
| $("#registerForm").submit(); | |||
| } else { | |||
| layerIndex = layer.open({ | |||
| type: 1 | |||
| ,title: false | |||
| ,area: ['90%', '40%'] | |||
| ,shade: 0.5 | |||
| ,maxmin: false | |||
| ,scrollbar: false | |||
| ,closeBtn: 0 | |||
| ,content: $('#new_person_layer') | |||
| ,btn: ["是我", "不是我,继续注册"] | |||
| ,yes: function (index) { | |||
| // if ("${openid}" != null && "${openid}" != "") { | |||
| $.ajax("/account2/updateEmp",{method: "post", dataType: "json", data: {"userCode":DesUtils.encode(res.data[0].jobNumber, secretKey), "openid":"${openid}", "phone":phone,"base64":base64}, success:function (data){ | |||
| layer.closeAll(); | |||
| parent.layer.closeAll(); | |||
| if (data.status == 0) { | |||
| layer.msg("更新成功", {icon: 6, time: 2000}); | |||
| setTimeout(function (){ | |||
| window.location.reload(); | |||
| }, 2000) | |||
| } else { | |||
| layer.msg(data.errMsg, {icon: 5, time: 2000}); | |||
| } | |||
| },error:function (err){ | |||
| console.log(err); | |||
| }}, | |||
| ) | |||
| /*} else { | |||
| layer.closeAll(); | |||
| parent.layer.closeAll(); | |||
| }*/ | |||
| }, | |||
| btn2: function (index){ | |||
| parent.$("#registerForm").submit(); | |||
| }, | |||
| success:function () { | |||
| console.log(res.data); | |||
| $("#avtar-img").attr("src","/face01/compress/"+res.data[0].faceImageName) | |||
| } | |||
| }); | |||
| } | |||
| }, | |||
| error:function (){ | |||
| } | |||
| }) | |||
| } else { | |||
| layer.msg("信息填写不全或有误,请检查", {icon: 5, time: 2000}); | |||
| } | |||
| // $("#registerForm").submit(); | |||
| return (false); | |||
| } | |||
| function openDiv(){ | |||
| var secretKey = "${@Global.getConfig('shiro.loginSubmit.secretKey')}"; | |||
| var openid = DesUtils.encode($("#ipt-openid").val(), secretKey); | |||
| layer.open({ | |||
| type: 2 | |||
| , skin: 'demo-class' | |||
| , title: "新增人脸底库" | |||
| , area: ['100%', '100%'] | |||
| , shade: 0.8 | |||
| , skin: 'layui-layer-lan' | |||
| , id: 'LAY_layuipro' //设定一个id,防止重复弹出 | |||
| // , btn: ['提交', '取消'] | |||
| // , btnAlign: 'c' | |||
| , close : 0 | |||
| , moveType: 1 //拖拽模式,0或者1 | |||
| , content: "${ctxPath}/account2/photo/0/"+openid | |||
| /*, yes: function () { | |||
| }*/ | |||
| }); | |||
| } | |||
| function photoCompress(file, w, objDiv) { | |||
| var ready = new FileReader(); | |||
| /*开始读取指定的Blob对象或File对象中的内容. 当读取操作完成时,readyState属性的值会成为DONE,如果设置了onloadend事件处理程序,则调用之.同时,result属性中将包含一个data: URL格式的字符串以表示所读取文件的内容.*/ | |||
| ready.readAsDataURL(file); | |||
| ready.onload = function() { | |||
| var re = this.result; | |||
| canvasDataURL(re, w, objDiv); | |||
| } | |||
| }; | |||
| function canvasDataURL(path, obj, callback) { | |||
| var img = new Image(); | |||
| img.src = path; | |||
| img.onload = function() { | |||
| var that = this; | |||
| // 默认按比例压缩 | |||
| var w = that.width, | |||
| h = that.height, | |||
| scale = w / h; | |||
| w = obj.width || w; | |||
| h = obj.height || (w / scale); | |||
| var quality = 0.5; // 默认图片质量为0.7 | |||
| //生成canvas | |||
| var canvas = document.createElement('canvas'); | |||
| var ctx = canvas.getContext('2d'); | |||
| // 创建属性节点 | |||
| var anw = document.createAttribute("width"); | |||
| anw.nodeValue = w; | |||
| var anh = document.createAttribute("height"); | |||
| anh.nodeValue = h; | |||
| canvas.setAttributeNode(anw); | |||
| canvas.setAttributeNode(anh); | |||
| ctx.drawImage(that, 0, 0, w, h); | |||
| // 图像质量 | |||
| if(obj.quality && obj.quality <= 1 && obj.quality > 0) { | |||
| quality = obj.quality; | |||
| } | |||
| // quality值越小,所绘制出的图像越模糊 | |||
| var base64 = canvas.toDataURL('image/jpeg', quality); | |||
| // 回调函数返回base64的值 | |||
| callback(base64); | |||
| } | |||
| } | |||
| function convertBase64UrlToBlob(urlData) { | |||
| var arr = urlData.split(','), | |||
| mime = arr[0].match(/:(.*?);/)[1], | |||
| bstr = atob(arr[1]), | |||
| n = bstr.length, | |||
| u8arr = new Uint8Array(n); | |||
| while(n--) { | |||
| u8arr[n] = bstr.charCodeAt(n); | |||
| } | |||
| return new Blob([u8arr], { | |||
| type: mime | |||
| }); | |||
| } | |||
| layui.use('upload', function() { | |||
| var dialog = null; | |||
| var upload = layui.upload; | |||
| //执行实例 | |||
| upload.render({ | |||
| elem : '#upload-img', | |||
| // url : '${ctx}/sys/emp/update-face', | |||
| url : '', | |||
| data:{}, | |||
| accept: 'images', | |||
| acceptMime: 'image/*', | |||
| field : 'face', | |||
| number : 1, | |||
| size: 5100, | |||
| auto: false , | |||
| multiple : false, | |||
| choose: function(obj){ | |||
| dialog = layer.msg('正在上传', | |||
| { | |||
| icon: 16 | |||
| ,shade: 0.01 | |||
| }); | |||
| obj.preview(function (index, file, result) { | |||
| photoCompress(file, { | |||
| quality: 0.5, | |||
| }, function(base64Codes) { | |||
| $.ajax('/api/reg-check-face',{ | |||
| method: "post", dataType: "json", | |||
| data: { | |||
| "faceImage": base64Codes, | |||
| }, | |||
| async:false, | |||
| success: function (res) { | |||
| layer.close(dialog); | |||
| if ( 0 != res.status ) { | |||
| layer.msg('<p class="text-red">'+res.errMsg+'</p>', {icon: 5, time: 5000}); | |||
| } else { | |||
| console.log(base64Codes); | |||
| $("#avatarImg").val(base64Codes); | |||
| $("#imgObj").attr("src", base64Codes); | |||
| $("#imgObj").next("div").css("display", "none"); | |||
| } | |||
| },error:function (e){ | |||
| layer.close(dialog); | |||
| layer.msg('<p class="text-red">'+e.message+'</p>', {icon: 5, time: 5000}); | |||
| } | |||
| } | |||
| ); | |||
| }); | |||
| }); | |||
| return; | |||
| } | |||
| }); | |||
| }); | |||
| $(function(){ | |||
| if(2 == ${type}){ | |||
| location.href = "/account2/login?type="+${type}; | |||
| } | |||
| $(".layui_header_close").on('click',function(){ | |||
| layer.close(layerIndex); | |||
| }); | |||
| }) | |||
| </script> | |||