瀏覽代碼

fix digiman

digital-human
yk 2 年之前
父節點
當前提交
9e0030d1fb
共有 9 個檔案被更改,包括 135 行新增31 行删除
  1. +9
    -0
      src/main/java/com/lecoo/kjg/web/sys/entity/AuthMapping.java
  2. +42
    -16
      src/main/java/com/lecoo/kjg/web/sys/service/support/EmpServiceSupport.java
  3. +2
    -1
      src/main/java/com/lecoo/kjg/web/sys/utils/ImageUtil.java
  4. +37
    -0
      src/main/java/com/lecoo/kjg/web/sys/utils/StringUtils.java
  5. +31
    -0
      src/main/java/com/lecoo/kjg/web/sys/web/Account2Controller.java
  6. +1
    -1
      src/main/java/com/lecoo/kjg/web/sys/web/EmployeeController.java
  7. +4
    -4
      src/main/resources/config/application-dev.yml
  8. +4
    -4
      src/main/resources/config/application.yml
  9. +5
    -5
      src/main/resources/views/themes/default/modules/sys/account/registerEmp.html

+ 9
- 0
src/main/java/com/lecoo/kjg/web/sys/entity/AuthMapping.java 查看文件

@@ -104,4 +104,13 @@ public class AuthMapping extends DataEntity<AuthMapping> {
String empStr = emp.getRealName()+emp.getCardNo()+feature;
return DigestUtils.md5DigestAsHex(empStr.getBytes());
}
public String getExactDevId(){
if (this.devId.contains("PAD")){
return this.devId;
} else {
return this.devId.substring(3)+"_PAD1";
}
}
}

+ 42
- 16
src/main/java/com/lecoo/kjg/web/sys/service/support/EmpServiceSupport.java 查看文件

@@ -956,21 +956,33 @@ public class EmpServiceSupport
ods.setOfficeId(officeCode);
Office o = officeDao.get(emp.getOffice());
List<String> ids = Arrays.asList(StringUtils.split(o.getParentCodes(), ","));
List<String> ids = new ArrayList<>();
ids.addAll(Arrays.asList(StringUtils.split(o.getParentCodes(), ",")));
ids.add(o.getOfficeCode());
List<AccessControl> list = accessControlService.getAccessControlsByOfficeCodes(ids);
System.err.println(list.size()+" "+ids);
if (list.size()>0) {
String mis = DateUtils.getMillsSecondsDouble();
for (AccessControl od : list) {
AuthMapping authMapping = new AuthMapping();
String empId = emp.getId();
authMapping.setEmpId(empId);
authMapping.setIsUpdFace(1);//新增记录默认脸已被改
authMapping.setDevId(od.getAccessControlId());
authMapping.setHasAuth(0);
authMapping.setHasAuth(1);
authMapping.setIsNewRecord(true);
authMapping.setUpdatedAt("0");//新增记录设置update_at为0
authMapping.setUpdatedAt(mis);//新增记录设置update_at为0
authMappingDao.insert(authMapping);
System.err.println("=======---====");
System.err.println("devId=="+od.getDeviceId());
System.err.println("=======---====");
if (od.getDeviceId().endsWith("_PAD1")){
redisUtils.setGroupString(od.getDeviceId()+":face-latest-ts", mis);
} else {
redisUtils.setGroupString(od.getDeviceId()+"_PAD1"+":face-latest-ts", mis);
}
}
}
}
@@ -981,7 +993,12 @@ public class EmpServiceSupport
}
public void updAuthMapping(Emp emp, int hasAuth){
System.err.println("emp----id===111");
System.err.println(emp.getId());
List<AuthMapping> list = authMappingDao.getByEmp(emp.getId());
System.err.println(list.size());
System.err.println("emp----id===222");
if (list.size()>0) {
String mis = DateUtils.getMillsSecondsDouble();
for (AuthMapping am : list) {
@@ -989,9 +1006,12 @@ public class EmpServiceSupport
am.setHasAuth(hasAuth);
am.setIsUpdFace(1);
authMappingDao.update(am);
Device device = deviceService.findByDevId(am.getDevId());
if (ObjectUtils.anyNotNull(device) && Emp.STATUS_NORMAL.equals(emp.getStatus())) {
redisUtils.setGroupString(am.getDevId()+":face-latest-ts", mis);
System.err.println("=======---===="+am.getDevId());
System.err.println("=======---===="+am.getExactDevId());
redisUtils.setGroupString(am.getExactDevId()+":face-latest-ts", mis);
Device device = deviceService.findByDevId(am.getExactDevId());
if (ObjectUtils.anyNotNull(device)) {
device.setLatestAuthTs(new BigDecimal(mis));
deviceService.update(device);
}
@@ -1025,17 +1045,17 @@ public class EmpServiceSupport
public void reg(User user, Emp emp){
this.save(emp);
userExtraDao.insert(user);
OfficeDevice od = new OfficeDevice();
OfficeAccessControl od = new OfficeAccessControl();
od.setOfficeId(emp.getOffice().getOfficeCode());
List<OfficeDevice> list = officeDeviceService.findList(od);
List<EmpDevice> edList = Lists.newLinkedList();
list.forEach(officeDevice -> {
EmpDevice ed = new EmpDevice();
ed.setDeviceId(officeDevice.getDeviceId());
List<OfficeAccessControl> list = officeAccessControlService.findList(od);
List<EmpAccessControl> edList = Lists.newLinkedList();
list.forEach(officeAccessControl -> {
EmpAccessControl ed = new EmpAccessControl();
ed.setAccessControlId(officeAccessControl.getAccessControlId());
ed.setEmpId(emp.getId());
edList.add(ed);
});
empDeviceDao.insertBatch(edList);
empAccessControlDao.insertBatch(edList);
addAuthMapping(emp);//根据部门添加权限
}
@@ -1091,7 +1111,7 @@ public class EmpServiceSupport
u.setStatus(User.STATUS_NORMAL);
u.setUserCode(u.getLoginCode());
Extend extend = new Extend();
extend.setExtendS1(User.STATUS_AUDIT);
extend.setExtendS1(User.STATUS_NORMAL);
u.setExtend(extend);
if (!StringUtils.isNotEmpty(o.getOfficeCode())) {
@@ -1106,7 +1126,7 @@ public class EmpServiceSupport
emp.setPhoneNumber(u.getMobile());
emp.setIsNewRecord(true);
emp.setEmpType("1");
emp.setStatus(Emp.STATUS_AUDIT);
emp.setStatus(Emp.STATUS_NORMAL);
emp.setOffice(office);
emp.setRegisterTime(new Date());
emp.setDepartment(office.getOfficeName());
@@ -1121,6 +1141,9 @@ 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();
@@ -1145,6 +1168,9 @@ public class EmpServiceSupport
empFaceFeature.setFaceFeature(array.toJSONString());
empFaceFeatureDao.insert(empFaceFeature);
emp.setEmpFaceFeature(empFaceFeature);
} else {
System.err.println("image stored failed");
System.err.println(json.toJSONString());
}
}
return "";


+ 2
- 1
src/main/java/com/lecoo/kjg/web/sys/utils/ImageUtil.java 查看文件

@@ -234,13 +234,14 @@ public class ImageUtil {
String newFileName = getNewFileName("jpg");
ByteArrayInputStream fileStream = new ByteArrayInputStream(bytes);
Boolean checkRes = ImageUtil.checkPixel(fileStream, 2000, 2000);
Boolean checkRes = ImageUtil.checkPixel(fileStream, 5000, 5000);
String path = "";
if (isReg) {
path = faceFileRegisterPath;
} else {
path = faceFilePassRecordPath;
}
if (checkRes) {
FileCopyUtils.copy(bytes, new File(path + "/" + newFileName));


+ 37
- 0
src/main/java/com/lecoo/kjg/web/sys/utils/StringUtils.java 查看文件

@@ -0,0 +1,37 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.lecoo.kjg.web.sys.utils;

public class StringUtils extends com.jeesite.common.lang.StringUtils {
public StringUtils() {
}

/**
* @Author yangkai
* @Description 全角转半角
* @Date 2023/3/2
* @Param
* @return
**/
public static String fullWidth2halfWidth(String fullWidthStr) {
if (null == fullWidthStr || fullWidthStr.length() <= 0) {
return "";
}
char[] charArray = fullWidthStr.toCharArray();
//对全角字符转换的char数组遍历
for (int i = 0; i < charArray.length; ++i) {
int charIntValue = (int) charArray[i];
//如果符合转换关系,将对应下标之间减掉偏移量65248;如果是空格的话,直接做转换
if (charIntValue >= 65281 && charIntValue <= 65374) {
charArray[i] = (char) (charIntValue - 65248);
} else if (charIntValue == 12288) {
charArray[i] = (char) 32;
}
}
return new String(charArray);
}

}

+ 31
- 0
src/main/java/com/lecoo/kjg/web/sys/web/Account2Controller.java 查看文件

@@ -438,6 +438,37 @@ public class Account2Controller extends WxBaseController {
}
/**
* 用户注册
* @param u 对应用户
* @param emp 对应员工
* @param o 注册员工所属公司
* @param model
* @return
*/
@RequestMapping(value = "/account2/reg2")
@Transactional
@ResponseBody
public String reg2(User u, Emp emp, Office o, Model model) {
empService.regInit(emp, u, o);
String msg = empService.faceReg(emp);
if (StringUtils.isNotEmpty(msg)) {
return this.renderResult("false", msg);
}
u.setAvatar(emp.getFaceImageName());
empService.reg(u, emp);
LogUtils.saveLog(u, null, emp.getRealName()+"注册成功", "register");
//清除redis
redisUtils.delKey("regOrLogin:phone:"+u.getMobile());
model.addAttribute("msg", "恭喜你,您的账号 " + emp.getRealName() + " 注册成功!");
return this.renderResult("true", "恭喜你,您的账号 " + emp.getRealName() + " 注册成功!");
}
@RequestMapping(value = "/account2/regUser")
public String reg(@RequestParam Map map, Model model, HttpServletResponse response){


+ 1
- 1
src/main/java/com/lecoo/kjg/web/sys/web/EmployeeController.java 查看文件

@@ -230,7 +230,7 @@ public class EmployeeController extends BaseController {
empService.delete(emp);
empService.delMappingByEmp(emp);
// empService.delMappingByEmp(emp);
User user = UserUtils.getByLoginCode(emp.getJobNumber());
if (ObjectUtils.anyNotNull(user)) {


+ 4
- 4
src/main/resources/config/application-dev.yml 查看文件

@@ -33,11 +33,11 @@ mysql:
# host: ${DB_HOST:8.131.78.156}
# port: ${DB_PORT:23306}
host: ${DB_HOST:39.105.85.176}
port: ${DB_PORT:3306}
database: ${DB_NAME:lecoo-hj}
host: ${DB_HOST:127.0.0.1}
port: ${DB_PORT:3308}
database: ${DB_NAME:lecoo}
username: ${DB_USER:root}
password: ${DB_PASSWORD:Lecooai@2021}
password: ${DB_PASSWORD:Digimeta@123}
# 业务相关配置
biz:


+ 4
- 4
src/main/resources/config/application.yml 查看文件

@@ -393,11 +393,11 @@ wx:
host: 127.0.0.1
port: 6379
configs:
# - appId: wx80dc26b645077e97 # 第一个公众号的appid
- appId: wx80dc26b645077e97 # 第一个公众号的appid
# - appId: wxcea6b4840efb906e # 第一个公众号的appid
- appId: ENC(5ZzYjATZAQK3mSkZKTPuHEqgIQRv8ADix8SsVZdfeAg=) # 第一个公众号的appid
# secret: 5fea919f2cb1b320cebdb9896f697361 # 公众号的appsecret
secret: ENC(XHPy8rxb7MlPaeBbmPjHZGu9bqRGWY8IKWCmG3NSwygAMXqcqcFNUksMKukd5eHH) # 公众号的appsecret
# - appId: ENC(5ZzYjATZAQK3mSkZKTPuHEqgIQRv8ADix8SsVZdfeAg=) # 第一个公众号的appid
secret: 5fea919f2cb1b320cebdb9896f697361 # 公众号的appsecret
# secret: ENC(XHPy8rxb7MlPaeBbmPjHZGu9bqRGWY8IKWCmG3NSwygAMXqcqcFNUksMKukd5eHH) # 公众号的appsecret
token: 83u4h # 接口配置里的Token值
templateSendUrl: http://www.hjkjg.top:49180/sendMsg
auditTemplateId: Y1qGJ7SjY4GFky9V101dV8rYQzDR1uZ8g3e6d16M1Ts


+ 5
- 5
src/main/resources/views/themes/default/modules/sys/account/registerEmp.html 查看文件

@@ -26,7 +26,7 @@
</style>
<div class="login-box">
<div class="login-logo" style="font-size: 28px;">
<b>${@Global.getConfig('productName')}</b>
<b>人脸面部信息注册</b>
</div>
<div class="login-box-body">
<form id="registerForm" class="layui-form" action="${ctxPath}/account2/reg" method="post" >
@@ -44,7 +44,7 @@
</a>
</div>
<div class="form-group has-feedback">
<div class="form-group has-feedback" style="display: none;">
<select name="officeCode" id="officeCode" class="required">
<option selected="selected" value="" style="display: none;">-----请选择所属公司-----</option>
<%
@@ -58,15 +58,15 @@
<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>
<!-- <span class="text-red" style="font-size: 12px;">* 姓名提交后不可修改,请谨慎填写,以免无法过审</span>-->
</div>
<div class="layui-form-item has-feedback">
<div class="layui-form-item has-feedback" style="display: none;">
<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;">
<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="男" >


Loading…
取消
儲存