update code

dev_xd
lijun 2024-10-11 00:29:35 +08:00
parent 7fcd920b52
commit 953f85ffc8
5 changed files with 68 additions and 25 deletions

View File

@ -78,5 +78,5 @@ public class CacheConstants
*/ */
public static final String PRO_PROJECT = "pro_project:"; public static final String PRO_PROJECT = "pro_project:";
public static final String UNI_AUTH = "pro_project_uni_auth2:"; public static final String UNI_AUTH = "pro_project_uni_auth3:";
} }

View File

@ -30,7 +30,7 @@ public interface IUniService {
* @param data * @param data
* @return * @return
*/ */
public boolean admitUpdate(JSONObject data); public String admitUpdate(JSONObject data);
/** /**
* - * -
@ -133,5 +133,5 @@ public interface IUniService {
* @param userId * @param userId
* @param projectId * @param projectId
*/ */
public Long syncUniUser(Long userId, ProProjectInfoSubdeptsUsers proProjectInfoSubdeptsUsers); public Long syncUniUser(Long userId, Long projectId);
} }

View File

@ -74,7 +74,7 @@ public class ProProjectInfoSubdeptsUsersServiceImpl implements IProProjectInfoSu
}else{ }else{
remoteUserService.updateUserInfo(user,SecurityConstants.INNER).getData(); remoteUserService.updateUserInfo(user,SecurityConstants.INNER).getData();
} }
uniService.syncUniUser(user.getUserId(),proProjectInfoSubdeptsUsers); uniService.syncUniUser(user.getUserId(),proProjectInfoSubdeptsUsers.getProjectId());
return proProjectInfoSubdeptsUsersMapper.insertProProjectInfoSubdeptsUsers(proProjectInfoSubdeptsUsers); return proProjectInfoSubdeptsUsersMapper.insertProProjectInfoSubdeptsUsers(proProjectInfoSubdeptsUsers);
} }
@ -97,7 +97,7 @@ public class ProProjectInfoSubdeptsUsersServiceImpl implements IProProjectInfoSu
}else{ }else{
remoteUserService.updateUserInfo(user,SecurityConstants.INNER).getData(); remoteUserService.updateUserInfo(user,SecurityConstants.INNER).getData();
} }
uniService.syncUniUser(user.getUserId(),proProjectInfoSubdeptsUsers); uniService.syncUniUser(user.getUserId(),proProjectInfoSubdeptsUsers.getProjectId());
return proProjectInfoSubdeptsUsersMapper.updateProProjectInfoSubdeptsUsers(proProjectInfoSubdeptsUsers); return proProjectInfoSubdeptsUsersMapper.updateProProjectInfoSubdeptsUsers(proProjectInfoSubdeptsUsers);
} }

View File

@ -42,6 +42,10 @@ public class UniServiceImpl implements IUniService{
@Autowired @Autowired
private RemoteUserService remoteUserService; private RemoteUserService remoteUserService;
private void clearAuthCache(long projectId){
String cacheKey=CacheConstants.UNI_AUTH+projectId;
redisService.deleteObject(cacheKey);
}
@Override @Override
public Map<String,String> auth(long projectId) { public Map<String,String> auth(long projectId) {
@ -102,11 +106,15 @@ public class UniServiceImpl implements IUniService{
if(jo.getLong("result").intValue()==1){ if(jo.getLong("result").intValue()==1){
return jo.getJSONObject("data").getString("admitGuid"); return jo.getJSONObject("data").getString("admitGuid");
} }
if("token is illegal".equals(jo.getString("msg"))){
clearAuthCache(projectId);
return admitCreate(data);
}
return null; return null;
} }
@Override @Override
public boolean admitUpdate(JSONObject data) { public String admitUpdate(JSONObject data) {
long projectId=data.getLong("projectId"); long projectId=data.getLong("projectId");
data.remove("projectId"); data.remove("projectId");
Request request=new Request.Builder() Request request=new Request.Builder()
@ -116,7 +124,12 @@ public class UniServiceImpl implements IUniService{
.build(); .build();
String res=UniUtils.getResult(request); String res=UniUtils.getResult(request);
JSONObject jo=JSON.parseObject(res); JSONObject jo=JSON.parseObject(res);
return jo.getLong("result").intValue()==1; if("token is illegal".equals(jo.getString("msg"))){
clearAuthCache(projectId);
return admitUpdate(data);
}
return jo.getString("msg");
} }
@Override @Override
@ -130,6 +143,10 @@ public class UniServiceImpl implements IUniService{
.build(); .build();
String res=UniUtils.getResult(request); String res=UniUtils.getResult(request);
JSONObject jo=JSON.parseObject(res); JSONObject jo=JSON.parseObject(res);
if("token is illegal".equals(jo.getString("msg"))){
clearAuthCache(projectId);
return admitDeletee(data);
}
return jo.getLong("result").intValue()==1; return jo.getLong("result").intValue()==1;
} }
@ -157,6 +174,10 @@ public class UniServiceImpl implements IUniService{
if(jo.getLong("result").intValue()==1){ if(jo.getLong("result").intValue()==1){
return jo.getJSONObject("data"); return jo.getJSONObject("data");
} }
if("token is illegal".equals(jo.getString("msg"))){
clearAuthCache(projectId);
return faceRegister(data);
}
return null; return null;
} }
@ -171,6 +192,10 @@ public class UniServiceImpl implements IUniService{
.build(); .build();
String res=UniUtils.getResult(request); String res=UniUtils.getResult(request);
JSONObject jo=JSON.parseObject(res); JSONObject jo=JSON.parseObject(res);
if("token is illegal".equals(jo.getString("msg"))){
clearAuthCache(projectId);
return faceDelete(data);
}
return jo.getLong("result").intValue()==1; return jo.getLong("result").intValue()==1;
} }
@ -215,15 +240,16 @@ public class UniServiceImpl implements IUniService{
} }
@Override @Override
public Long syncUniUser(Long userId, ProProjectInfoSubdeptsUsers prjUser) { public Long syncUniUser(Long userId, Long projectId) {
SysUser user=remoteUserService.getSysUserInfo(userId, SecurityConstants.INNER).getData(); SysUser user=remoteUserService.getSysUserInfo(userId, SecurityConstants.INNER).getData();
JSONObject jo=JSON.parseObject(user.getUserInfos()); JSONObject jo=JSON.parseObject(user.getUserInfos());
String admitGuid=jo.getString("admitGuid"); String admitGuid=jo.getString("admitGuid");
String faceGuid=jo.getString("faceGuid");
JSONObject userJo=new JSONObject(); JSONObject userJo=new JSONObject();
userJo.put("projectId",prjUser.getProjectId()); userJo.put("projectId",projectId);
userJo.put("name",user.getUserName()); userJo.put("name",user.getUserName());
userJo.put("phone",user.getPhonenumber()); userJo.put("phone",user.getPhonenumber());
userJo.put("tag",prjUser.getActiveProjectName()); userJo.put("tag",user.getNickName());
userJo.put("cardNo",user.getUserId()); userJo.put("cardNo",user.getUserId());
userJo.put("idCardNo",user.getCardCode()); userJo.put("idCardNo",user.getCardCode());
userJo.put("password","123456"); userJo.put("password","123456");
@ -236,16 +262,32 @@ public class UniServiceImpl implements IUniService{
hasUpdate=true; hasUpdate=true;
}else{ }else{
//已注册 //已注册
admitUpdate(userJo); userJo.put("admitGuid",admitGuid);
String upMsg= admitUpdate(userJo);
if("admit not exist".equals(upMsg)){
userJo.remove("admitGuid");
userJo.put("projectId",projectId);
admitGuid=admitCreate(userJo);
jo.put("admitGuid",admitGuid);
hasUpdate=true;
}
} }
JSONObject faceJo=new JSONObject(); JSONObject faceJo=new JSONObject();
faceJo.put("projectId",prjUser.getProjectId()); faceJo.put("projectId",projectId);
faceJo.put("base64",""); faceJo.put("base64","");
faceJo.put("admitGuid",admitGuid); faceJo.put("admitGuid",admitGuid);
faceJo.put("url",user.getUserPicture()); //faceJo.put("url",user.getUserPicture());
faceJo.put("url","https://uniubi-aiot.oss-cn-hangzhou.aliyuncs.com/detect/20241007/211204-71D9BCBE526C4F57B8D31ECAE03AEBFB");
faceJo.put("faceTag",""); faceJo.put("faceTag","");
HttpServletRequest request =((ServletRequestAttributes)RequestContextHolder.currentRequestAttributes()).getRequest(); HttpServletRequest request =((ServletRequestAttributes)RequestContextHolder.currentRequestAttributes()).getRequest();
String url= request.getRemoteAddr(); String url= request.getRemoteAddr();
if(StringUtils.isNotEmpty(faceGuid)){
JSONObject faceDel=new JSONObject();
faceDel.put("projectId",projectId);
faceDel.put("admitGuid",admitGuid);
faceDel.put("faceGuid",faceGuid);
faceDelete(faceDel);
}
//注册图像 //注册图像
JSONObject faceRes= faceRegister(faceJo); JSONObject faceRes= faceRegister(faceJo);
if(faceRes!=null) { if(faceRes!=null) {

View File

@ -600,6 +600,18 @@ function submitForm() {
proxy.$refs["proProjectInfoSubdeptsUsersRef"].validate(valid => { proxy.$refs["proProjectInfoSubdeptsUsersRef"].validate(valid => {
if (valid) { if (valid) {
let depts = data.subdepts.filter(d => d.id == form.value.subDeptId); let depts = data.subdepts.filter(d => d.id == form.value.subDeptId);
let info=form.value.info;
info.nation=form.value.nation;
info.educationalType=form.value.educationalType;
info.birthDay=form.value.birthDay;
info.nativePlace=form.value.nativePlace;
info.address=form.value.address;
info.emergencyContact=form.value.emergencyContact;
info.emergencyContact= form.value.emergencyContact;
info.contactPhone=form.value.contactPhone;
info.bankName=form.value.bankName;
info.bankCardNo= form.value.bankCardNo;
info.bankOffice= form.value.bankOffice;
form.value.subDeptName = depts.length > 0 ? depts[0].subDeptName : ''; form.value.subDeptName = depts.length > 0 ? depts[0].subDeptName : '';
form.value.comId = depts.length > 0 ? depts[0].comId : ''; form.value.comId = depts.length > 0 ? depts[0].comId : '';
let groups = data.deptGroups.filter(d => d.id == form.value.subDeptGroup); let groups = data.deptGroups.filter(d => d.id == form.value.subDeptGroup);
@ -617,18 +629,7 @@ function submitForm() {
userPicture: imgUrl(form.value.faceImage), userPicture: imgUrl(form.value.faceImage),
cardImgPos: form.value.certificatePhoto1, cardImgPos: form.value.certificatePhoto1,
cardImgInv: form.value.certificatePhoto2, cardImgInv: form.value.certificatePhoto2,
userInfos: JSON.stringify({ userInfos: JSON.stringify(info),
nation: form.value.nation,
educationalType: form.value.educationalType,
birthDay: form.value.birthDay,
nativePlace: form.value.nativePlace,
address: form.value.address,
emergencyContact: form.value.emergencyContact,
contactPhone: form.value.contactPhone,
bankName: form.value.bankName,
bankCardNo: form.value.bankCardNo,
bankOffice: form.value.bankOffice
}),
phonenumber: form.value.userPhone, phonenumber: form.value.userPhone,
sex: form.value.sex, sex: form.value.sex,
avatar: form.value.faceImage avatar: form.value.faceImage