icc的劳务人员同步提交
This commit is contained in:
parent
3212f171f5
commit
a8b76fd788
@ -19,6 +19,10 @@ public class OpenAlertException extends OpenException {
|
||||
super(code, msg);
|
||||
}
|
||||
|
||||
public OpenAlertException(String msg, Throwable cause) {
|
||||
super(msg, cause);
|
||||
}
|
||||
|
||||
public OpenAlertException(int code, String msg, Throwable cause) {
|
||||
super(code, msg, cause);
|
||||
}
|
||||
|
||||
@ -25,6 +25,10 @@ public class OpenException extends RuntimeException {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public OpenException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public OpenException(int code, String msg, Throwable cause) {
|
||||
super(msg, cause);
|
||||
this.code = code;
|
||||
|
||||
@ -1,443 +0,0 @@
|
||||
package com.zhgd.xmgl.call;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.dahuatech.icc.brm.model.v202010.SDK.*;
|
||||
import com.dahuatech.icc.brm.model.v202010.department.*;
|
||||
import com.dahuatech.icc.oauth.http.AbstractIccRequest;
|
||||
import com.dahuatech.icc.oauth.http.IccResponse;
|
||||
import com.dahuatech.icc.oauth.model.v202010.OauthConfigUserPwdInfo;
|
||||
import com.gexin.fastjson.JSON;
|
||||
import com.zhgd.jeecg.common.execption.OpenAlertException;
|
||||
import com.zhgd.xmgl.call.api.WorkerCarManufacturer;
|
||||
import com.zhgd.xmgl.modules.basicdata.service.impl.NoticeServiceImpl;
|
||||
import com.zhgd.xmgl.modules.project.entity.Project;
|
||||
import com.zhgd.xmgl.modules.project.entity.ProjectEnterprise;
|
||||
import com.zhgd.xmgl.modules.project.service.IProjectEnterpriseService;
|
||||
import com.zhgd.xmgl.modules.project.service.IProjectService;
|
||||
import com.zhgd.xmgl.modules.worker.entity.DepartmentInfo;
|
||||
import com.zhgd.xmgl.modules.worker.entity.EnterpriseInfo;
|
||||
import com.zhgd.xmgl.modules.worker.entity.TeamInfo;
|
||||
import com.zhgd.xmgl.modules.worker.service.IDepartmentInfoService;
|
||||
import com.zhgd.xmgl.modules.worker.service.ITeamInfoService;
|
||||
import com.zhgd.xmgl.modules.worker.service.impl.EnterpriseInfoServiceImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
public class IccCall implements WorkerCarManufacturer {
|
||||
/**
|
||||
* 打印的
|
||||
*/
|
||||
private static final ThreadLocal<String> printSubject = new ThreadLocal<>();
|
||||
public static final String DELETE = "删除";
|
||||
public static final String SAVE = "保存";
|
||||
@Lazy
|
||||
@Autowired
|
||||
private IProjectService projectService;
|
||||
private Long noticeUser;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private EnterpriseInfoServiceImpl enterpriseInfoService;
|
||||
private Project project;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private IProjectEnterpriseService projectEnterpriseService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private IDepartmentInfoService departmentInfoService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private ITeamInfoService teamInfoService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private NoticeServiceImpl noticeService;
|
||||
|
||||
@Override
|
||||
public void setConfig(Project project) {
|
||||
this.project = project;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNoticeUser(Long noticeUser) {
|
||||
this.noticeUser = noticeUser;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Async("doubleCarbonExecutor")
|
||||
public void saveEnterpriseInfo(EnterpriseInfo enterpriseInfo) {
|
||||
String subject = getAndSetSubject("单位");
|
||||
if (project.getIccId() == null) {
|
||||
//保存项目的部门
|
||||
saveProject(project);
|
||||
}
|
||||
if (enterpriseInfo.getIccId() == null) {
|
||||
EnterpriseInfo enterprise = enterpriseInfoService.getEnterpriseByProjectSnAndEnterpriseId(project.getProjectSn(), enterpriseInfo.getId());
|
||||
enterpriseInfo.setIccId(enterprise.getIccId());
|
||||
}
|
||||
try {
|
||||
saveIccDepartment(iccId1 -> {
|
||||
projectEnterpriseService.update(null, new LambdaUpdateWrapper<ProjectEnterprise>()
|
||||
.set(ProjectEnterprise::getIccId, iccId1)
|
||||
.eq(ProjectEnterprise::getProjectSn, project.getProjectSn())
|
||||
.eq(ProjectEnterprise::getEnterpriseId, enterpriseInfo.getId())
|
||||
);
|
||||
}, project.getIccId(), enterpriseInfo.getIccId(), enterpriseInfo.getEnterpriseName());
|
||||
noticeSuccess(SAVE, subject, enterpriseInfo.getEnterpriseName());
|
||||
} catch (Exception e) {
|
||||
log.error("err", e);
|
||||
noticeFailed(SAVE, subject, enterpriseInfo.getEnterpriseName(), e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取并设置(不存在)subject
|
||||
* @param subject
|
||||
* @return
|
||||
*/
|
||||
private String getAndSetSubject(String subject) {
|
||||
if (printSubject.get() == null) {
|
||||
printSubject.set(subject);
|
||||
}
|
||||
return subject;
|
||||
}
|
||||
|
||||
/**
|
||||
* 发成功通知
|
||||
*
|
||||
* @param action
|
||||
* @param subject
|
||||
* @param name
|
||||
*/
|
||||
private void noticeSuccess(String action, String subject, String name) {
|
||||
if (subject.equals(printSubject.get())) {
|
||||
noticeService.addUserNotice(noticeUser, action + subject + "到ICC通知", action + name + "到ICC成功", "1");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发失败通知
|
||||
*
|
||||
* @param action
|
||||
* @param subject
|
||||
* @param name
|
||||
* @param failedMsg
|
||||
*/
|
||||
private void noticeFailed(String action, String subject, String name, String failedMsg) {
|
||||
if (subject.equals(printSubject.get())) {
|
||||
noticeService.addUserNotice(noticeUser, action + subject + "到ICC通知", action + name + "到ICC失败,失败原因:" + failedMsg, "1");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Async("doubleCarbonExecutor")
|
||||
public void deleteEnterpriseInfo(EnterpriseInfo enterpriseInfo) {
|
||||
try {
|
||||
deleteIccDepartmentByIccId(enterpriseInfo.getIccId());
|
||||
noticeSuccess(DELETE, "单位", enterpriseInfo.getEnterpriseName());
|
||||
} catch (Exception e) {
|
||||
log.error("err", e);
|
||||
noticeFailed(DELETE, "单位", enterpriseInfo.getEnterpriseName(), e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Async("doubleCarbonExecutor")
|
||||
public void saveDepartmentInfo(DepartmentInfo departmentInfo) {
|
||||
String subject = getAndSetSubject("部门");
|
||||
try {
|
||||
saveProject(project);
|
||||
EnterpriseInfo enterpriseInfo = enterpriseInfoService.getEnterpriseByProjectSnAndEnterpriseId(project.getProjectSn(), departmentInfo.getEnterpriseId());
|
||||
saveEnterpriseInfo(enterpriseInfo);
|
||||
saveIccDepartment(iccId1 -> {
|
||||
departmentInfo.setIccId(iccId1);
|
||||
departmentInfoService.updateById(departmentInfo);
|
||||
}, enterpriseInfo.getIccId(), departmentInfo.getIccId(), departmentInfo.getDepartmentName() + "(部门)");
|
||||
noticeSuccess(SAVE, subject, departmentInfo.getDepartmentName());
|
||||
} catch (Exception e) {
|
||||
log.error("err", e);
|
||||
noticeFailed(SAVE, subject, departmentInfo.getDepartmentName(), e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存icc部门
|
||||
*
|
||||
* @param updateConsumer
|
||||
* @param pid
|
||||
* @param iccId
|
||||
* @param name
|
||||
*/
|
||||
private void saveIccDepartment(Consumer<Long> updateConsumer, Long pid, Long iccId, String name) {
|
||||
BrmDeptQueryResponse.DeptPageData data = IccHttpUtil.getDepartmentById(iccId, project);
|
||||
if (data == null) {
|
||||
BrmDeptAddResponse response = IccHttpUtil.addDepartment(pid, name, project);
|
||||
if (response.isSuccess()) {
|
||||
updateConsumer.accept(response.getData().getId());
|
||||
} else if (response.getCode().equals("28170001")) {
|
||||
//名称已存在,mysql保存里面的iccId
|
||||
BrmDeptPageRequest request = new BrmDeptPageRequest();
|
||||
request.setParentId(pid);
|
||||
request.setPageNum(1);
|
||||
request.setPageSize(1000);
|
||||
request.setSearchKey(name);
|
||||
BrmDeptPageResponse pageResp = IccHttpUtil.getDepartmentPage(request, project);
|
||||
if (pageResp.isSuccess()) {
|
||||
Long qid = pageResp.getData().getPageData().stream().filter(dp -> dp.getName().equals(name)).findFirst().map(BrmDeptPageResponse.DeptPageList::getId).orElse(null);
|
||||
updateConsumer.accept(qid);
|
||||
} else {
|
||||
IccHttpUtil.throwErrIf(pageResp);
|
||||
}
|
||||
} else {
|
||||
IccHttpUtil.throwErrIf(response);
|
||||
}
|
||||
} else {
|
||||
if (!Objects.equals(data.getName(), name)) {
|
||||
BrmDeptUpdateResponse response = IccHttpUtil.updateDepartment(pid, iccId, name, project);
|
||||
IccHttpUtil.throwErrIf(response);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Async("doubleCarbonExecutor")
|
||||
public void deleteDepartmentInfo(DepartmentInfo departmentInfo) {
|
||||
try {
|
||||
deleteIccDepartmentByIccId(departmentInfo.getIccId());
|
||||
noticeSuccess(DELETE, "部门", departmentInfo.getDepartmentName());
|
||||
} catch (Exception e) {
|
||||
log.error("err", e);
|
||||
noticeFailed(DELETE, "部门", departmentInfo.getDepartmentName(), e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除icc部门通过iccId
|
||||
*
|
||||
* @param iccId
|
||||
*/
|
||||
private void deleteIccDepartmentByIccId(Long iccId) {
|
||||
if (iccId == null) {
|
||||
return;
|
||||
}
|
||||
BrmDeptDeleteResponse response = IccHttpUtil.deleteDepartment(iccId, project);
|
||||
if (response.isSuccess() || response.getCode().equals("28170002")) {
|
||||
//28170002:部门不存在
|
||||
} else {
|
||||
IccHttpUtil.throwErrIf(response);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Async("doubleCarbonExecutor")
|
||||
public void saveTeamInfo(TeamInfo teamInfo) {
|
||||
String subject = getAndSetSubject("班组");
|
||||
try {
|
||||
saveProject(project);
|
||||
EnterpriseInfo enterpriseInfo = enterpriseInfoService.getEnterpriseByProjectSnAndEnterpriseId(project.getProjectSn(), teamInfo.getEnterpriseId());
|
||||
saveEnterpriseInfo(enterpriseInfo);
|
||||
saveIccDepartment(iccId -> {
|
||||
teamInfo.setIccId(iccId);
|
||||
teamInfoService.updateById(teamInfo);
|
||||
}, enterpriseInfo.getIccId(), teamInfo.getIccId(), teamInfo.getTeamName() + "(班组)");
|
||||
noticeSuccess(SAVE, subject, teamInfo.getTeamName());
|
||||
} catch (Exception e) {
|
||||
log.error("err", e);
|
||||
noticeFailed(SAVE, subject, teamInfo.getTeamName(), e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Async("doubleCarbonExecutor")
|
||||
public void deleteTeamInfo(TeamInfo teamInfo) {
|
||||
try {
|
||||
deleteIccDepartmentByIccId(teamInfo.getIccId());
|
||||
noticeSuccess(DELETE, "班组", teamInfo.getTeamName());
|
||||
} catch (Exception e) {
|
||||
log.error("err", e);
|
||||
noticeFailed(DELETE, "班组", teamInfo.getTeamName(), e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Async("doubleCarbonExecutor")
|
||||
public void saveProject(Project newProject) {
|
||||
String subject = getAndSetSubject("项目");
|
||||
try {
|
||||
saveIccDepartment(iccId -> {
|
||||
project.setIccId(iccId);
|
||||
projectService.updateById(project);
|
||||
//同级部门名称不能重复
|
||||
project = projectService.getOne(new LambdaQueryWrapper<Project>()
|
||||
.eq(Project::getProjectSn, project.getProjectSn())
|
||||
);
|
||||
}, 1L, newProject.getIccId(), newProject.getProjectName());
|
||||
noticeSuccess(SAVE, subject, newProject.getProjectName());
|
||||
} catch (Exception e) {
|
||||
log.error("err", e);
|
||||
noticeFailed(SAVE, subject, newProject.getProjectName(), e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public static class IccHttpUtil {
|
||||
/**
|
||||
* 部门新增
|
||||
*
|
||||
* @param parentId
|
||||
* @param name
|
||||
* @param project
|
||||
* @return
|
||||
*/
|
||||
public static BrmDeptAddResponse addDepartment(long parentId, String name, Project project) {
|
||||
BrmDeptAddSDK adk = new BrmDeptAddSDK();
|
||||
BrmDeptAddRequest request = new BrmDeptAddRequest();
|
||||
request.setParentId(parentId);
|
||||
request.setName(name);
|
||||
request.setOauthConfigBaseInfo(getOauthConfig(project));
|
||||
printReq(request, "部门新增");
|
||||
BrmDeptAddResponse response = adk.brmDeptAdd(request);
|
||||
printResp(response, "部门新增");
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 部门更新
|
||||
*
|
||||
* @param parentId
|
||||
* @param id
|
||||
* @param name
|
||||
* @param project
|
||||
* @return
|
||||
*/
|
||||
public static BrmDeptUpdateResponse updateDepartment(long parentId, long id, String name, Project project) {
|
||||
BrmDeptUpdateSDK adk = new BrmDeptUpdateSDK();
|
||||
BrmDeptUpdateRequest request = new BrmDeptUpdateRequest();
|
||||
request.setId(id);
|
||||
request.setParentId(parentId);
|
||||
request.setName(name);
|
||||
request.setOauthConfigBaseInfo(getOauthConfig(project));
|
||||
printReq(request, "部门更新");
|
||||
BrmDeptUpdateResponse response = adk.brmDeptUpdate(request);
|
||||
printResp(response, "部门更新");
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 部门删除
|
||||
*
|
||||
* @param id
|
||||
* @param project
|
||||
* @return
|
||||
*/
|
||||
public static BrmDeptDeleteResponse deleteDepartment(Long id, Project project) {
|
||||
BrmDeptDeleteSDK sdk = new BrmDeptDeleteSDK();
|
||||
BrmDeptDeleteRequest request = new BrmDeptDeleteRequest();
|
||||
request.setId(id);
|
||||
request.setOauthConfigBaseInfo(getOauthConfig(project));
|
||||
printReq(request, "部门删除");
|
||||
BrmDeptDeleteResponse response = sdk.brmDeptDelete(request);
|
||||
printResp(response, "部门删除");
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 部门详情查询
|
||||
*
|
||||
* @param iccId
|
||||
* @param project
|
||||
* @return
|
||||
*/
|
||||
public static BrmDeptQueryResponse.DeptPageData getDepartmentById(Long iccId, Project project) {
|
||||
if (iccId == null) {
|
||||
return null;
|
||||
}
|
||||
BrmDeptQuerySDK querySDK = new BrmDeptQuerySDK();
|
||||
BrmDeptQueryRequest request = new BrmDeptQueryRequest(iccId);
|
||||
request.setOauthConfigBaseInfo(getOauthConfig(project));
|
||||
printReq(request, "部门详情查询");
|
||||
BrmDeptQueryResponse response = querySDK.brmDeptPage(request);
|
||||
printResp(response, "部门详情查询");
|
||||
if (response.getCode().equals("28170002")) {
|
||||
//部门不存在
|
||||
return null;
|
||||
}
|
||||
if (!response.isSuccess()) {
|
||||
throwErrIf(response);
|
||||
}
|
||||
return response.getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* 打印响应
|
||||
*
|
||||
* @param response
|
||||
* @param name
|
||||
*/
|
||||
private static void printResp(IccResponse response, String name) {
|
||||
log.info("调用icc<<" + name + ">>结果:{}", JSON.toJSONString(response));
|
||||
}
|
||||
|
||||
/**
|
||||
* 打印请求
|
||||
*
|
||||
* @param request
|
||||
* @param name
|
||||
*/
|
||||
private static void printReq(AbstractIccRequest request, String name) {
|
||||
log.info("调用icc<<" + name + ">>请求:{}", JSON.toJSONString(request));
|
||||
}
|
||||
|
||||
/**
|
||||
* 抛出异常错误提示
|
||||
*
|
||||
* @param response
|
||||
*/
|
||||
public static void throwErrIf(IccResponse response) {
|
||||
if (!response.isSuccess()) {
|
||||
throw new OpenAlertException(StrUtil.format("调用icc报错,请联系管理员。code:{},errMsg:{}", response.getCode(), response.getErrMsg()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取大华ICC的配置
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private static OauthConfigUserPwdInfo getOauthConfig(Project project) {
|
||||
OauthConfigUserPwdInfo oauthConfigBaseInfo = new OauthConfigUserPwdInfo(project.getIccIp(), project.getIccClientId(),
|
||||
project.getIccClientSecret(), project.getIccUserName(), project.getIccPassword(), false, project.getIccPort(), project.getIccPort());
|
||||
|
||||
return oauthConfigBaseInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 部门分页查询
|
||||
*
|
||||
* @param request
|
||||
* @param project
|
||||
* @return
|
||||
*/
|
||||
public static BrmDeptPageResponse getDepartmentPage(BrmDeptPageRequest request, Project project) {
|
||||
BrmDeptPageSDK sdk = new BrmDeptPageSDK();
|
||||
request.setOauthConfigBaseInfo(getOauthConfig(project));
|
||||
printReq(request, "部门分页查询");
|
||||
BrmDeptPageResponse response = sdk.brmDeptPage(request);
|
||||
printResp(response, "部门分页查询");
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
926
src/main/java/com/zhgd/xmgl/call/IccWorkerCall.java
Normal file
926
src/main/java/com/zhgd/xmgl/call/IccWorkerCall.java
Normal file
@ -0,0 +1,926 @@
|
||||
package com.zhgd.xmgl.call;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.dahuatech.hutool.http.HttpRequest;
|
||||
import com.dahuatech.hutool.http.Method;
|
||||
import com.dahuatech.hutool.json.JSONUtil;
|
||||
import com.dahuatech.icc.brm.model.v202010.SDK.*;
|
||||
import com.dahuatech.icc.brm.model.v202010.department.*;
|
||||
import com.dahuatech.icc.brm.model.v202010.person.BrmPersonDelRequest;
|
||||
import com.dahuatech.icc.brm.model.v202010.person.BrmPersonDelResponse;
|
||||
import com.dahuatech.icc.brm.model.v202010.person.BrmPersonQueryByIdCardRequest;
|
||||
import com.dahuatech.icc.brm.model.v202010.person.BrmPersonQueryByIdCardResponse;
|
||||
import com.dahuatech.icc.config.OauthConfigUtil;
|
||||
import com.dahuatech.icc.exception.ClientException;
|
||||
import com.dahuatech.icc.model.brm.department.DepartmentUpdateResponse;
|
||||
import com.dahuatech.icc.model.brm.person.*;
|
||||
import com.dahuatech.icc.oauth.http.IccResponse;
|
||||
import com.dahuatech.icc.oauth.http.IccTokenResponse;
|
||||
import com.dahuatech.icc.oauth.model.v202010.OauthConfigUserPwdInfo;
|
||||
import com.dahuatech.icc.oauth.utils.HttpUtils;
|
||||
import com.gexin.fastjson.JSON;
|
||||
import com.zhgd.jeecg.common.execption.OpenAlertException;
|
||||
import com.zhgd.xmgl.call.api.WorkerManufacturer;
|
||||
import com.zhgd.xmgl.modules.basicdata.service.impl.NoticeServiceImpl;
|
||||
import com.zhgd.xmgl.modules.project.entity.Project;
|
||||
import com.zhgd.xmgl.modules.project.entity.ProjectEnterprise;
|
||||
import com.zhgd.xmgl.modules.project.entity.ProjectUfaceConfig;
|
||||
import com.zhgd.xmgl.modules.project.service.IProjectEnterpriseService;
|
||||
import com.zhgd.xmgl.modules.project.service.IProjectService;
|
||||
import com.zhgd.xmgl.modules.worker.entity.DepartmentInfo;
|
||||
import com.zhgd.xmgl.modules.worker.entity.EnterpriseInfo;
|
||||
import com.zhgd.xmgl.modules.worker.entity.TeamInfo;
|
||||
import com.zhgd.xmgl.modules.worker.entity.WorkerInfo;
|
||||
import com.zhgd.xmgl.modules.worker.service.IDepartmentInfoService;
|
||||
import com.zhgd.xmgl.modules.worker.service.ITeamInfoService;
|
||||
import com.zhgd.xmgl.modules.worker.service.impl.EnterpriseInfoServiceImpl;
|
||||
import com.zhgd.xmgl.modules.worker.service.impl.WorkerInfoServiceImpl;
|
||||
import com.zhgd.xmgl.modules.xz.service.impl.XzHikvisionSyncServiceImpl;
|
||||
import com.zhgd.xmgl.util.Base64Util;
|
||||
import com.zhgd.xmgl.util.PathUtil;
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
public class IccWorkerCall implements WorkerManufacturer {
|
||||
/**
|
||||
* 打印的
|
||||
*/
|
||||
private static final ThreadLocal<String> printSubject = new ThreadLocal<>();
|
||||
@Autowired
|
||||
@Lazy
|
||||
public WorkerInfoServiceImpl workerInfoService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
XzHikvisionSyncServiceImpl xzHikvisionSyncService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private IProjectService projectService;
|
||||
private Long noticeUser;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private EnterpriseInfoServiceImpl enterpriseInfoService;
|
||||
private ProjectUfaceConfig config;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private IProjectEnterpriseService projectEnterpriseService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private IDepartmentInfoService departmentInfoService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private ITeamInfoService teamInfoService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private NoticeServiceImpl noticeService;
|
||||
@Value("${basePath}")
|
||||
private String basePath;
|
||||
|
||||
public static void main(String[] args) throws ClientException {
|
||||
IccTokenResponse.IccToken accessToken = HttpUtils.getToken(OauthConfigUtil.getOauthConfig());
|
||||
System.out.println(accessToken.getToken_type() + " " + accessToken.getAccess_token());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setConfig(ProjectUfaceConfig config) {
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNoticeUser(Long noticeUser) {
|
||||
this.noticeUser = noticeUser;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveEnterpriseInfo(EnterpriseInfo enterpriseInfo) {
|
||||
String subject = getAndSetSubjectIfNotExist("保存单位");
|
||||
try {
|
||||
Project project = projectService.getOne(new LambdaQueryWrapper<Project>()
|
||||
.eq(Project::getProjectSn, enterpriseInfo.getProjectSn()));
|
||||
if (project.getIccId() == null) {
|
||||
//保存项目的部门
|
||||
saveProject(project);
|
||||
}
|
||||
if (enterpriseInfo.getIccId() == null) {
|
||||
EnterpriseInfo enterprise = enterpriseInfoService.getEnterpriseByProjectSnAndEnterpriseId(config.getProjectSn(), enterpriseInfo.getId());
|
||||
enterpriseInfo.setIccId(enterprise.getIccId());
|
||||
}
|
||||
saveIccDepartment(iccId1 -> {
|
||||
projectEnterpriseService.update(null, new LambdaUpdateWrapper<ProjectEnterprise>()
|
||||
.set(ProjectEnterprise::getIccId, iccId1)
|
||||
.eq(ProjectEnterprise::getProjectSn, config.getProjectSn())
|
||||
.eq(ProjectEnterprise::getEnterpriseId, enterpriseInfo.getId())
|
||||
);
|
||||
}, project.getIccId(), enterpriseInfo.getIccId(), enterpriseInfo.getEnterpriseName());
|
||||
noticeSuccess(subject, enterpriseInfo.getEnterpriseName());
|
||||
} catch (Exception e) {
|
||||
log.error("err", e);
|
||||
noticeFailed(subject, enterpriseInfo.getEnterpriseName(), e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取并设置(不存在)subject
|
||||
*
|
||||
* @param subject
|
||||
* @return
|
||||
*/
|
||||
private String getAndSetSubjectIfNotExist(String subject) {
|
||||
if (printSubject.get() == null) {
|
||||
printSubject.set(subject);
|
||||
}
|
||||
return subject;
|
||||
}
|
||||
|
||||
/**
|
||||
* 发成功通知
|
||||
*
|
||||
* @param subject
|
||||
* @param name
|
||||
*/
|
||||
private void noticeSuccess(String subject, String name) {
|
||||
if (subject.equals(printSubject.get())) {
|
||||
noticeService.addUserNotice(noticeUser, subject + "到ICC通知", subject + "<<" + name + ">>到ICC成功", "1");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发失败通知
|
||||
*
|
||||
* @param subject
|
||||
* @param name
|
||||
* @param failedMsg
|
||||
*/
|
||||
private void noticeFailed(String subject, String name, String failedMsg) {
|
||||
if (subject.equals(printSubject.get())) {
|
||||
noticeService.addUserNotice(noticeUser, subject + "到ICC通知", subject + "<<" + name + ">>到ICC失败,失败原因:" + failedMsg, "1");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteEnterpriseInfo(EnterpriseInfo enterpriseInfo) {
|
||||
String subject = getAndSetSubjectIfNotExist("删除单位");
|
||||
try {
|
||||
deleteIccDepartmentByIccId(enterpriseInfo.getIccId());
|
||||
noticeSuccess(subject, enterpriseInfo.getEnterpriseName());
|
||||
} catch (Exception e) {
|
||||
log.error("err", e);
|
||||
noticeFailed(subject, enterpriseInfo.getEnterpriseName(), e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveDepartmentInfo(DepartmentInfo departmentInfo) {
|
||||
String subject = getAndSetSubjectIfNotExist("保存部门");
|
||||
try {
|
||||
EnterpriseInfo enterpriseInfo = enterpriseInfoService.getEnterpriseByProjectSnAndEnterpriseId(config.getProjectSn(), departmentInfo.getEnterpriseId());
|
||||
saveEnterpriseInfo(enterpriseInfo);
|
||||
saveIccDepartment(iccId1 -> {
|
||||
departmentInfo.setIccId(iccId1);
|
||||
departmentInfoService.updateById(departmentInfo);
|
||||
}, enterpriseInfo.getIccId(), departmentInfo.getIccId(), departmentInfo.getDepartmentName() + "(部门)");
|
||||
noticeSuccess(subject, departmentInfo.getDepartmentName());
|
||||
} catch (Exception e) {
|
||||
log.error("err", e);
|
||||
noticeFailed(subject, departmentInfo.getDepartmentName(), e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存icc部门
|
||||
*
|
||||
* @param updateConsumer
|
||||
* @param pid
|
||||
* @param iccId
|
||||
* @param name
|
||||
*/
|
||||
private void saveIccDepartment(Consumer<Long> updateConsumer, Long pid, Long iccId, String name) {
|
||||
BrmDeptQueryResponse.DeptPageData data = IccHttpUtil.getDepartmentById(iccId, config);
|
||||
if (data == null) {
|
||||
BrmDeptAddResponse response = IccHttpUtil.addDepartment(pid, name, config);
|
||||
if (response.isSuccess()) {
|
||||
updateConsumer.accept(response.getData().getId());
|
||||
} else if (response.getCode().equals("28170001")) {
|
||||
//名称已存在,mysql保存里面的iccId
|
||||
BrmDeptPageRequest request = new BrmDeptPageRequest();
|
||||
request.setParentId(pid);
|
||||
request.setPageNum(1);
|
||||
request.setPageSize(1000);
|
||||
request.setSearchKey(name);
|
||||
BrmDeptPageResponse pageResp = IccHttpUtil.getDepartmentPage(request, config);
|
||||
if (pageResp.isSuccess()) {
|
||||
Long qid = pageResp.getData().getPageData().stream().filter(dp -> dp.getName().equals(name)).findFirst().map(BrmDeptPageResponse.DeptPageList::getId).orElse(null);
|
||||
updateConsumer.accept(qid);
|
||||
} else {
|
||||
IccHttpUtil.throwErrIf(pageResp);
|
||||
}
|
||||
} else {
|
||||
IccHttpUtil.throwErrIf(response);
|
||||
}
|
||||
} else {
|
||||
if (!Objects.equals(data.getName(), name)) {
|
||||
BrmDeptUpdateResponse response = IccHttpUtil.updateDepartment(pid, iccId, name, config);
|
||||
IccHttpUtil.throwErrIf(response);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteDepartmentInfo(DepartmentInfo departmentInfo) {
|
||||
String subject = getAndSetSubjectIfNotExist("删除部门");
|
||||
try {
|
||||
deleteIccDepartmentByIccId(departmentInfo.getIccId());
|
||||
noticeSuccess(subject, departmentInfo.getDepartmentName());
|
||||
} catch (Exception e) {
|
||||
log.error("err", e);
|
||||
noticeFailed(subject, departmentInfo.getDepartmentName(), e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除icc部门通过iccId
|
||||
*
|
||||
* @param iccId
|
||||
*/
|
||||
private void deleteIccDepartmentByIccId(Long iccId) {
|
||||
if (iccId == null) {
|
||||
return;
|
||||
}
|
||||
DepartmentUpdateResponse response = IccHttpUtil.deleteDepartment(iccId, config);
|
||||
if (response.isSuccess() || response.getCode().equals("28170002")) {
|
||||
//28170002:部门不存在
|
||||
} else {
|
||||
IccHttpUtil.throwErrIf(response);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveTeamInfo(TeamInfo teamInfo) {
|
||||
String subject = getAndSetSubjectIfNotExist("保存班组");
|
||||
try {
|
||||
EnterpriseInfo enterpriseInfo = enterpriseInfoService.getEnterpriseByProjectSnAndEnterpriseId(config.getProjectSn(), teamInfo.getEnterpriseId());
|
||||
saveEnterpriseInfo(enterpriseInfo);
|
||||
saveIccDepartment(iccId -> {
|
||||
teamInfo.setIccId(iccId);
|
||||
teamInfoService.updateById(teamInfo);
|
||||
}, enterpriseInfo.getIccId(), teamInfo.getIccId(), teamInfo.getTeamName() + "(班组)");
|
||||
noticeSuccess(subject, teamInfo.getTeamName());
|
||||
} catch (Exception e) {
|
||||
log.error("err", e);
|
||||
noticeFailed(subject, teamInfo.getTeamName(), e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteTeamInfo(TeamInfo teamInfo) {
|
||||
String subject = getAndSetSubjectIfNotExist("删除班组");
|
||||
try {
|
||||
deleteIccDepartmentByIccId(teamInfo.getIccId());
|
||||
noticeSuccess(subject, teamInfo.getTeamName());
|
||||
} catch (Exception e) {
|
||||
log.error("err", e);
|
||||
noticeFailed(subject, teamInfo.getTeamName(), e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveProject(Project newProject) {
|
||||
String subject = getAndSetSubjectIfNotExist("保存项目");
|
||||
try {
|
||||
saveIccDepartment(iccId -> {
|
||||
Project project = new Project();
|
||||
project.setProjectId(newProject.getProjectId());
|
||||
project.setIccId(iccId);
|
||||
projectService.updateById(project);
|
||||
}, 1L, newProject.getIccId(), newProject.getProjectName());
|
||||
noticeSuccess(subject, newProject.getProjectName());
|
||||
} catch (Exception e) {
|
||||
log.error("err", e);
|
||||
noticeFailed(subject, newProject.getProjectName(), e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveWorkerInfo(WorkerInfo workerInfo) {
|
||||
String subject = getAndSetSubjectIfNotExist("保存劳务人员");
|
||||
try {
|
||||
BrmPersonQueryByIdCardResponse idCardResponse = IccHttpUtil.getByPaperNumber(workerInfo.getIdCard(), config);
|
||||
WorkerInfoExt workerInfoExt = new WorkerInfoExt();
|
||||
BeanUtil.copyProperties(workerInfo, workerInfoExt);
|
||||
workerInfoExt.setIccDepartmentId(getIccDepartmentId(workerInfo));
|
||||
if (idCardResponse.getData() == null || idCardResponse.getData().getId() == null) {
|
||||
PersonAddResponse response = IccHttpUtil.addPerson(workerInfoExt, config);
|
||||
if (response.isSuccess()) {
|
||||
workerInfo.setIccId(response.getData().getId());
|
||||
workerInfoService.updateById(workerInfo);
|
||||
} else {
|
||||
IccHttpUtil.throwErrIf(response);
|
||||
}
|
||||
} else {
|
||||
if (!Objects.equals(idCardResponse.getData().getId(), workerInfo.getIccId())) {
|
||||
workerInfo.setIccId(idCardResponse.getData().getId());
|
||||
workerInfoService.updateById(workerInfo);
|
||||
}
|
||||
PersonAddResponse response = IccHttpUtil.updatePerson(workerInfoExt, config);
|
||||
IccHttpUtil.throwErrIf(response);
|
||||
}
|
||||
noticeSuccess(subject, workerInfo.getWorkerName());
|
||||
} catch (Exception e) {
|
||||
log.error("err", e);
|
||||
noticeFailed(subject, workerInfo.getWorkerName(), e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveWorkerInfoStatus(WorkerInfo workerInfo) {
|
||||
// xzHikvisionSyncService.saveBatch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取icc部门id
|
||||
*
|
||||
* @param workerInfo
|
||||
* @return
|
||||
*/
|
||||
private Long getIccDepartmentId(WorkerInfo workerInfo) {
|
||||
Long iccId;
|
||||
if (Objects.equals(workerInfo.getPersonType(), 1)) {
|
||||
TeamInfo teamInfo = teamInfoService.getById(workerInfo.getTeamId());
|
||||
if (teamInfo.getIccId() == null) {
|
||||
saveTeamInfo(teamInfo);
|
||||
}
|
||||
iccId = teamInfo.getIccId();
|
||||
} else {
|
||||
DepartmentInfo departmentInfo = departmentInfoService.getById(workerInfo.getDepartmentId());
|
||||
if (departmentInfo.getIccId() == null) {
|
||||
saveDepartmentInfo(departmentInfo);
|
||||
}
|
||||
iccId = departmentInfo.getIccId();
|
||||
}
|
||||
return iccId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveWorkerUFaceAuth(WorkerInfo workerInfo) {
|
||||
String subject = getAndSetSubjectIfNotExist("保存劳务人员门禁权限");
|
||||
try {
|
||||
|
||||
noticeSuccess(subject, workerInfo.getWorkerName());
|
||||
} catch (Exception e) {
|
||||
log.error("err", e);
|
||||
noticeFailed(subject, workerInfo.getWorkerName(), e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteWorkerInfo(WorkerInfo workerInfo) {
|
||||
String subject = getAndSetSubjectIfNotExist("删除劳务人员");
|
||||
try {
|
||||
List<Long> iccIds = new ArrayList<>();
|
||||
iccIds.add(workerInfo.getIccId());
|
||||
BrmPersonDelResponse response = IccHttpUtil.deletePerson(iccIds, config);
|
||||
if (response.isSuccess()) {
|
||||
|
||||
} else {
|
||||
IccHttpUtil.throwErrIf(response);
|
||||
}
|
||||
noticeSuccess(subject, workerInfo.getWorkerName());
|
||||
} catch (Exception e) {
|
||||
log.error("err", e);
|
||||
noticeFailed(subject, workerInfo.getWorkerName(), e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IccWorkerCall.CheckFaceResp checkFace(File file) {
|
||||
return IccHttpUtil.checkFace(Base64Util.convertFileToBase64WithPrefix(file.getAbsolutePath()), config);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测人脸响应response
|
||||
*/
|
||||
@lombok.Data
|
||||
public static class CheckFaceResp {
|
||||
private Boolean success;
|
||||
private Data data;
|
||||
private String code;
|
||||
private String errMsg;
|
||||
|
||||
|
||||
@lombok.Data
|
||||
public static class Data {
|
||||
private String fileUrl;
|
||||
private String result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* icc的http请求封装
|
||||
*/
|
||||
private static class IccHttpUtil {
|
||||
// 使用静态 final Map 来存储民族名称到数字的映射
|
||||
// 这样Map只会在类加载时初始化一次,提高效率
|
||||
private static final Map<String, Integer> NATION_MAP;
|
||||
|
||||
static {
|
||||
NATION_MAP = new HashMap<>();
|
||||
NATION_MAP.put("汉族", 1);
|
||||
NATION_MAP.put("蒙古族", 2);
|
||||
NATION_MAP.put("回族", 3);
|
||||
NATION_MAP.put("藏族", 4);
|
||||
NATION_MAP.put("维吾尔族", 5);
|
||||
NATION_MAP.put("苗族", 6);
|
||||
NATION_MAP.put("彝族", 7);
|
||||
NATION_MAP.put("壮族", 8);
|
||||
NATION_MAP.put("布依族", 9);
|
||||
NATION_MAP.put("朝鲜族", 10);
|
||||
NATION_MAP.put("满族", 11);
|
||||
NATION_MAP.put("侗族", 12);
|
||||
NATION_MAP.put("瑶族", 13);
|
||||
NATION_MAP.put("白族", 14);
|
||||
NATION_MAP.put("土家族", 15);
|
||||
NATION_MAP.put("哈尼族", 16);
|
||||
NATION_MAP.put("哈萨克族", 17);
|
||||
NATION_MAP.put("傣族", 18);
|
||||
NATION_MAP.put("黎族", 19);
|
||||
NATION_MAP.put("傈僳族", 20);
|
||||
NATION_MAP.put("佤族", 21);
|
||||
NATION_MAP.put("畲族", 22);
|
||||
NATION_MAP.put("高山族", 23);
|
||||
NATION_MAP.put("拉祜族", 24);
|
||||
NATION_MAP.put("水族", 25);
|
||||
NATION_MAP.put("东乡族", 26);
|
||||
NATION_MAP.put("纳西族", 27);
|
||||
NATION_MAP.put("景颇族", 28);
|
||||
NATION_MAP.put("柯尔克孜族", 29);
|
||||
NATION_MAP.put("土族", 30);
|
||||
NATION_MAP.put("达斡尔族", 31);
|
||||
NATION_MAP.put("仫佬族", 32);
|
||||
NATION_MAP.put("羌族", 33);
|
||||
NATION_MAP.put("布朗族", 34);
|
||||
NATION_MAP.put("撒拉族", 35);
|
||||
NATION_MAP.put("毛南族", 36);
|
||||
NATION_MAP.put("仡佬族", 37);
|
||||
NATION_MAP.put("锡伯族", 38);
|
||||
NATION_MAP.put("阿昌族", 39);
|
||||
NATION_MAP.put("普米族", 40);
|
||||
NATION_MAP.put("塔吉克族", 41);
|
||||
NATION_MAP.put("怒族", 42);
|
||||
NATION_MAP.put("乌兹别克族", 43);
|
||||
NATION_MAP.put("俄罗斯族", 44);
|
||||
NATION_MAP.put("鄂温克族", 45);
|
||||
NATION_MAP.put("德昂族", 46);
|
||||
NATION_MAP.put("保安族", 47);
|
||||
NATION_MAP.put("裕固族", 48);
|
||||
NATION_MAP.put("京族", 49);
|
||||
NATION_MAP.put("塔塔尔族", 50);
|
||||
NATION_MAP.put("独龙族", 51);
|
||||
NATION_MAP.put("鄂伦春族", 52);
|
||||
NATION_MAP.put("赫哲族", 53);
|
||||
NATION_MAP.put("门巴族", 54);
|
||||
NATION_MAP.put("珞巴族", 55);
|
||||
NATION_MAP.put("基诺族", 56);
|
||||
}
|
||||
|
||||
/**
|
||||
* 人员详情信息获取(根据人员证件号获取)
|
||||
*
|
||||
* @param idCard
|
||||
* @param config
|
||||
* @return
|
||||
*/
|
||||
public static BrmPersonQueryByIdCardResponse getByPaperNumber(String idCard, ProjectUfaceConfig config) {
|
||||
BrmPersonQueryByIdCardSDK sdk = new BrmPersonQueryByIdCardSDK();
|
||||
BrmPersonQueryByIdCardRequest request = new BrmPersonQueryByIdCardRequest(idCard);
|
||||
printReq(request, "人员详情信息获取(根据人员证件号获取)");
|
||||
request.setOauthConfigBaseInfo(getOauthConfig(config));
|
||||
BrmPersonQueryByIdCardResponse response = sdk.brmPersonQueryByIdCard(request);
|
||||
printResp(response, "人员详情信息获取(根据人员证件号获取)");
|
||||
throwErrIf(response);
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 人员删除
|
||||
*
|
||||
* @param iccIds
|
||||
* @param config
|
||||
* @return
|
||||
*/
|
||||
public static BrmPersonDelResponse deletePerson(List<Long> iccIds, ProjectUfaceConfig config) {
|
||||
BrmPersonDelSDK sdk = new BrmPersonDelSDK();
|
||||
BrmPersonDelRequest request = new BrmPersonDelRequest();
|
||||
request.setIds(iccIds);
|
||||
request.setOauthConfigBaseInfo(getOauthConfig(config));
|
||||
printReq(request, "人员删除");
|
||||
BrmPersonDelResponse response = sdk.brmPersonDel(request);
|
||||
printResp(response, "人员删除");
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 图片质量检测
|
||||
* 1.人脸图片规范
|
||||
* a.照片需要小于4M
|
||||
* b.照片大小推荐 500*500
|
||||
* c.图片格式JPG、JPEG、PNG
|
||||
* d.人脸无遮挡(如戴帽子、口罩、眼镜等)、无修图
|
||||
* e.人脸需双眼睁开、表情自然、露额,头发不要遮挡
|
||||
*
|
||||
* @param fileBase64
|
||||
* @param config
|
||||
* @return
|
||||
*/
|
||||
public static CheckFaceResp checkFace(String fileBase64, ProjectUfaceConfig config) {
|
||||
try {
|
||||
String url = "https://" + config.getIccIp() + ":" + config.getIccPort() + "/evo-apigw/evo-brm/1.2.0/person/subsystem/upload/img";
|
||||
JSONObject form = new JSONObject();
|
||||
form.put("fileType", 3);//1:File格式 2:url格式 3:base64格式
|
||||
form.put("saveType", 2);
|
||||
form.put("fileBase64", fileBase64);
|
||||
url = HttpUtil.urlWithForm(url, form, CharsetUtil.CHARSET_UTF_8, false);
|
||||
log.info("图片质量检测 url:{},form:{}", url, JSON.toJSONString(form));
|
||||
String authorizationValue = getAuthorizationValue(config);
|
||||
String result = HttpRequest.post(url)
|
||||
.header("Authorization", authorizationValue)
|
||||
.form(form)
|
||||
.execute().body();
|
||||
log.info("图片质量检测 result:{}", result);
|
||||
return JSONObject.parseObject(result, CheckFaceResp.class);
|
||||
} catch (OpenAlertException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
throw new OpenAlertException("请求异常,请联系管理员", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取token的authorizationValue
|
||||
*
|
||||
* @param config
|
||||
* @return
|
||||
* @throws ClientException
|
||||
*/
|
||||
public static String getAuthorizationValue(ProjectUfaceConfig config) {
|
||||
IccTokenResponse.IccToken accessToken = null;
|
||||
try {
|
||||
accessToken = HttpUtils.getToken(getOauthConfig(config));
|
||||
} catch (ClientException e) {
|
||||
throw new OpenAlertException("获取icc的token失败,请联系管理员", e);
|
||||
}
|
||||
return accessToken.getToken_type() + " " + accessToken.getAccess_token();
|
||||
}
|
||||
|
||||
/**
|
||||
* 人员全局id生成(人员新增用上)
|
||||
*
|
||||
* @param config
|
||||
* @return
|
||||
*/
|
||||
public static Long getGenerateIdForPerson(ProjectUfaceConfig config) {
|
||||
Long id = null;
|
||||
PersonGenerateIdResponse response = null;
|
||||
try {
|
||||
response = HttpUtils.executeJson("/evo-apigw/evo-brm/1.0.0/person/generate-id", null, null, Method.GET, getOauthConfig(config), PersonGenerateIdResponse.class);
|
||||
printResp(JSONUtil.toJsonStr(response), "人员全局id生成(人员新增用上)");
|
||||
} catch (ClientException e) {
|
||||
log.error(e.getErrMsg(), e);
|
||||
}
|
||||
if (response.isSuccess()) {
|
||||
id = response.getData().getId();
|
||||
log.info("PersonDemo,generateId,personId:{}", response.getData().getId());
|
||||
} else {
|
||||
log.info("获取人员id失败:{}", response.getErrMsg());
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* 人员更新
|
||||
*
|
||||
* @param config
|
||||
* @return
|
||||
*/
|
||||
public static PersonAddResponse updatePerson(WorkerInfoExt workerInfo, ProjectUfaceConfig config) {
|
||||
PersonUpdateRequest personUpdateRequest = new PersonUpdateRequest();
|
||||
personUpdateRequest.setId(workerInfo.getIccId());
|
||||
personUpdateRequest.setName(workerInfo.getWorkerName());
|
||||
personUpdateRequest.setCode(workerInfo.getPersonSn());
|
||||
personUpdateRequest.setPaperType(111);
|
||||
personUpdateRequest.setPaperNumber(workerInfo.getIdCard());
|
||||
personUpdateRequest.setPaperAddress("证件地址");
|
||||
personUpdateRequest.setDepartmentId(workerInfo.getIccDepartmentId());
|
||||
//添加人脸
|
||||
if (StrUtil.isNotBlank(workerInfo.getFieldAcquisitionUrl())) {
|
||||
//设置生物特征数据(人像头像、人像特征、指纹特征)
|
||||
String base64 = Base64Util.convertFileToBase64WithPrefix(PathUtil.reviseSlash(PathUtil.getBasePath() + "/" + workerInfo.getFieldAcquisitionUrl()));
|
||||
List<PersonUpdateRequest.PersonBioSignature> personBioSignatures = new ArrayList<>();
|
||||
PersonUpdateRequest.PersonBioSignature personBioSignature = new PersonUpdateRequest.PersonBioSignature();
|
||||
personBioSignature.setType(3);
|
||||
personBioSignature.setIndex(1);
|
||||
personBioSignature.setPath(uploadImageByBase64(base64));
|
||||
personBioSignatures.add(personBioSignature);
|
||||
personUpdateRequest.setPersonBiosignatures(personBioSignatures);
|
||||
}
|
||||
|
||||
PersonAddResponse response = null;
|
||||
try {
|
||||
printReq(personUpdateRequest, "人员更新");
|
||||
response = HttpUtils.executeJson("/evo-apigw/evo-brm/1.2.0/person/subsystem/update", personUpdateRequest, null, Method.PUT, getOauthConfig(config), PersonAddResponse.class);
|
||||
printResp(response, "人员更新");
|
||||
} catch (Exception e) {
|
||||
throw new OpenAlertException(e.getMessage(), e);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取民族数字
|
||||
*
|
||||
* @param nation
|
||||
* @return
|
||||
*/
|
||||
private static int getNationType(String nation) {
|
||||
if (nation == null || nation.trim().isEmpty()) {
|
||||
return 0; // 如果输入为空或空白字符串,默认为其他
|
||||
}
|
||||
// 使用 getOrDefault 方法,如果 Map 中没有该民族名称,则返回默认值 0
|
||||
String key = nation.trim();
|
||||
if (!key.contains("族")) {
|
||||
key += "族";
|
||||
}
|
||||
return NATION_MAP.getOrDefault(key, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 部门新增
|
||||
*
|
||||
* @param parentId
|
||||
* @param name
|
||||
* @param config
|
||||
* @return
|
||||
*/
|
||||
public static BrmDeptAddResponse addDepartment(long parentId, String name, ProjectUfaceConfig config) {
|
||||
BrmDeptAddSDK adk = new BrmDeptAddSDK();
|
||||
BrmDeptAddRequest request = new BrmDeptAddRequest();
|
||||
request.setParentId(parentId);
|
||||
request.setName(name);
|
||||
request.setOauthConfigBaseInfo(getOauthConfig(config));
|
||||
printReq(request, "部门新增");
|
||||
BrmDeptAddResponse response = adk.brmDeptAdd(request);
|
||||
printResp(response, "部门新增");
|
||||
return response;
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 人员批量新增
|
||||
// *
|
||||
// * @param personList
|
||||
// * @param config
|
||||
// * @return
|
||||
// */
|
||||
// public static BrmPersonBatchAddResponse batchAddPerson(ArrayList<BrmPersonBatchAddRequest.PersonBatchData> personList, ProjectUfaceConfig config) {
|
||||
// BrmPersonBatchAddSDK sdk = new BrmPersonBatchAddSDK();
|
||||
// BrmPersonBatchAddRequest request = new BrmPersonBatchAddRequest();
|
||||
// request.setPersonList(personList);
|
||||
// request.setOauthConfigBaseInfo(getOauthConfig(config));
|
||||
// printReq(request, "人员批量新增");
|
||||
// BrmPersonBatchAddResponse response = sdk.personBatchAdd(request);
|
||||
// printResp(response, "人员批量新增");
|
||||
// return response;
|
||||
// }
|
||||
|
||||
/**
|
||||
* 部门更新
|
||||
*
|
||||
* @param parentId
|
||||
* @param id
|
||||
* @param name
|
||||
* @param config
|
||||
* @return
|
||||
*/
|
||||
public static BrmDeptUpdateResponse updateDepartment(long parentId, long id, String name, ProjectUfaceConfig config) {
|
||||
BrmDeptUpdateSDK adk = new BrmDeptUpdateSDK();
|
||||
BrmDeptUpdateRequest request = new BrmDeptUpdateRequest();
|
||||
request.setId(id);
|
||||
request.setParentId(parentId);
|
||||
request.setName(name);
|
||||
request.setOauthConfigBaseInfo(getOauthConfig(config));
|
||||
printReq(request, "部门更新");
|
||||
BrmDeptUpdateResponse response = adk.brmDeptUpdate(request);
|
||||
printResp(response, "部门更新");
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 部门删除
|
||||
*
|
||||
* @param id
|
||||
* @param config
|
||||
* @return
|
||||
*/
|
||||
public static DepartmentUpdateResponse deleteDepartment(Long id, ProjectUfaceConfig config) {
|
||||
DepartmentUpdateResponse response = null;
|
||||
Map<String, Long> idMap = new HashMap<>();
|
||||
try {
|
||||
idMap.put("id", id);
|
||||
printReq(idMap, "部门删除");
|
||||
response = HttpUtils.executeJson("/evo-apigw/evo-brm/1.0.0/department/delete", idMap, null, Method.DELETE, getOauthConfig(config), DepartmentUpdateResponse.class);
|
||||
printResp(response, "部门删除");
|
||||
} catch (ClientException e) {
|
||||
log.error(e.getErrMsg(), e);
|
||||
}
|
||||
if (!response.isSuccess()) {
|
||||
log.info("部门删除失败:{}", response.getErrMsg());
|
||||
} else {
|
||||
log.info("部门删除成功");
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 部门详情查询
|
||||
*
|
||||
* @param iccId
|
||||
* @param config
|
||||
* @return
|
||||
*/
|
||||
public static BrmDeptQueryResponse.DeptPageData getDepartmentById(Long iccId, ProjectUfaceConfig config) {
|
||||
if (iccId == null) {
|
||||
return null;
|
||||
}
|
||||
BrmDeptQuerySDK querySDK = new BrmDeptQuerySDK();
|
||||
BrmDeptQueryRequest request = new BrmDeptQueryRequest(iccId);
|
||||
request.setOauthConfigBaseInfo(getOauthConfig(config));
|
||||
printReq(request, "部门详情查询");
|
||||
BrmDeptQueryResponse response = querySDK.brmDeptPage(request);
|
||||
printResp(response, "部门详情查询");
|
||||
if (response.getCode().equals("28170002")) {
|
||||
//部门不存在
|
||||
return null;
|
||||
}
|
||||
if (!response.isSuccess()) {
|
||||
throwErrIf(response);
|
||||
}
|
||||
return response.getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* 打印响应
|
||||
*
|
||||
* @param response
|
||||
* @param name
|
||||
*/
|
||||
private static void printResp(Object response, String name) {
|
||||
log.info("调用icc<<" + name + ">>结果:{}", JSON.toJSONString(response));
|
||||
}
|
||||
|
||||
/**
|
||||
* 打印请求
|
||||
*
|
||||
* @param request
|
||||
* @param name
|
||||
*/
|
||||
private static void printReq(Object request, String name) {
|
||||
log.info("调用icc<<" + name + ">>请求:{}", JSON.toJSONString(request));
|
||||
}
|
||||
|
||||
/**
|
||||
* 抛出异常错误提示
|
||||
*
|
||||
* @param response
|
||||
*/
|
||||
public static void throwErrIf(IccResponse response) {
|
||||
if (!response.isSuccess()) {
|
||||
throw new OpenAlertException(StrUtil.format("调用icc报错,请联系管理员。code:{},errMsg:{}", response.getCode(), response.getErrMsg()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取大华ICC的配置
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private static OauthConfigUserPwdInfo getOauthConfig(ProjectUfaceConfig config) {
|
||||
OauthConfigUserPwdInfo oauthConfigBaseInfo = new OauthConfigUserPwdInfo(config.getIccIp(), config.getIccClientId(),
|
||||
config.getIccClientSecret(), config.getIccUserName(), config.getIccPassword(), false, config.getIccPort(), config.getIccPort());
|
||||
return oauthConfigBaseInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 部门分页查询
|
||||
*
|
||||
* @param request
|
||||
* @param config
|
||||
* @return
|
||||
*/
|
||||
public static BrmDeptPageResponse getDepartmentPage(BrmDeptPageRequest request, ProjectUfaceConfig config) {
|
||||
BrmDeptPageSDK sdk = new BrmDeptPageSDK();
|
||||
request.setOauthConfigBaseInfo(getOauthConfig(config));
|
||||
printReq(request, "部门分页查询");
|
||||
BrmDeptPageResponse response = sdk.brmDeptPage(request);
|
||||
printResp(response, "部门分页查询");
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传图片(适用于icc平台5.0.15及以上版本)
|
||||
*
|
||||
* @param imageBase64 图片base64字符串
|
||||
* @return fileUrl 图片url
|
||||
* @throws ClientException
|
||||
*/
|
||||
public static String uploadImageByBase64(String imageBase64) {
|
||||
String fileUrl = null;
|
||||
OauthConfigUserPwdInfo config = OauthConfigUtil.getOauthConfig();
|
||||
UploadImageResponse response = null;
|
||||
try {
|
||||
Map map = new HashMap();
|
||||
map.put("imageBase64", imageBase64);
|
||||
printReq(map, "上传图片");
|
||||
response = HttpUtils.executeJson("/evo-apigw/evo-brm/1.0.0/person/subsystem/third/upload/img", map, null, Method.POST, config, UploadImageResponse.class);
|
||||
printResp(response, "上传图片");
|
||||
} catch (ClientException e) {
|
||||
log.error(e.getErrMsg(), e);
|
||||
}
|
||||
if (response.isSuccess()) {
|
||||
fileUrl = response.getData().getFileUrl();
|
||||
log.info("PersonDemo,uploadImageByBase64,fileUrl:{}", response.getData().getFileUrl());
|
||||
} else {
|
||||
throw new OpenAlertException("图片上传失败," + response.getErrMsg());
|
||||
}
|
||||
return fileUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* 人员新增
|
||||
*
|
||||
* @param workerInfo
|
||||
* @param config
|
||||
* @return
|
||||
*/
|
||||
public static PersonAddResponse addPerson(WorkerInfoExt workerInfo, ProjectUfaceConfig config) {
|
||||
PersonAddRequest personAddRequest = new PersonAddRequest();
|
||||
personAddRequest.setId(getGenerateIdForPerson(config));
|
||||
personAddRequest.setName(workerInfo.getWorkerName());
|
||||
personAddRequest.setCode(workerInfo.getPersonSn());
|
||||
personAddRequest.setPaperType(111);
|
||||
personAddRequest.setPaperNumber(workerInfo.getIdCard());
|
||||
personAddRequest.setPaperAddress("证件地址");
|
||||
personAddRequest.setDepartmentId(workerInfo.getIccDepartmentId());
|
||||
//添加人脸
|
||||
if (StrUtil.isNotBlank(workerInfo.getFieldAcquisitionUrl())) {
|
||||
//设置生物特征数据(人像头像、人像特征、指纹特征)
|
||||
String base64 = Base64Util.convertFileToBase64WithPrefix(PathUtil.reviseSlash(PathUtil.getBasePath() + "/" + workerInfo.getFieldAcquisitionUrl()));
|
||||
List<PersonAddRequest.PersonBioSignature> personBioSignatures = new ArrayList<>();
|
||||
PersonAddRequest.PersonBioSignature personBioSignature = new PersonAddRequest.PersonBioSignature();
|
||||
personBioSignature.setType(3);
|
||||
personBioSignature.setIndex(1);
|
||||
personBioSignature.setPath(uploadImageByBase64(base64));
|
||||
personBioSignatures.add(personBioSignature);
|
||||
personAddRequest.setPersonBiosignatures(personBioSignatures);
|
||||
}
|
||||
PersonAddResponse response = null;
|
||||
printReq(personAddRequest, "人员新增");
|
||||
try {
|
||||
response = HttpUtils.executeJson("/evo-apigw/evo-brm/1.2.0/person/subsystem/add", personAddRequest, null, Method.POST, getOauthConfig(config), PersonAddResponse.class);
|
||||
} catch (ClientException e) {
|
||||
throw new OpenAlertException(e.getMessage(), e);
|
||||
}
|
||||
printResp(response, "人员新增");
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 人员扩展
|
||||
*/
|
||||
@Data
|
||||
private static class WorkerInfoExt extends WorkerInfo {
|
||||
/**
|
||||
* icc部门id
|
||||
*/
|
||||
private Long iccDepartmentId;
|
||||
|
||||
}
|
||||
}
|
||||
@ -8,6 +8,9 @@ import com.zhgd.xmgl.modules.video.entity.vo.TalkURLsV2Vo;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 同步第三方监控接口
|
||||
*/
|
||||
public interface VideoItemManufacturer {
|
||||
void setConfig(ProjectVideoConfig config);
|
||||
|
||||
|
||||
@ -1,14 +1,26 @@
|
||||
package com.zhgd.xmgl.call.api;
|
||||
|
||||
import com.zhgd.xmgl.modules.basicdata.entity.SystemUser;
|
||||
import com.zhgd.xmgl.call.IccWorkerCall;
|
||||
import com.zhgd.xmgl.modules.project.entity.Project;
|
||||
import com.zhgd.xmgl.modules.project.entity.ProjectUfaceConfig;
|
||||
import com.zhgd.xmgl.modules.worker.entity.DepartmentInfo;
|
||||
import com.zhgd.xmgl.modules.worker.entity.EnterpriseInfo;
|
||||
import com.zhgd.xmgl.modules.worker.entity.TeamInfo;
|
||||
import com.zhgd.xmgl.modules.worker.entity.WorkerInfo;
|
||||
|
||||
public interface WorkerCarManufacturer {
|
||||
void setConfig(Project project);
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* 同步第三方劳务接口
|
||||
*/
|
||||
public interface WorkerManufacturer {
|
||||
void setConfig(ProjectUfaceConfig config);
|
||||
|
||||
/**
|
||||
* 设置通知用户id
|
||||
*
|
||||
* @param noticeUser
|
||||
*/
|
||||
void setNoticeUser(Long noticeUser);
|
||||
|
||||
/**
|
||||
@ -60,4 +72,40 @@ public interface WorkerCarManufacturer {
|
||||
* @param project
|
||||
*/
|
||||
void saveProject(Project project);
|
||||
|
||||
/**
|
||||
* 保存劳务人员
|
||||
*
|
||||
* @param workerInfo
|
||||
*/
|
||||
void saveWorkerInfo(WorkerInfo workerInfo);
|
||||
|
||||
/**
|
||||
* 保存劳务人员同步步骤和状态
|
||||
*
|
||||
* @param workerInfo
|
||||
*/
|
||||
void saveWorkerInfoStatus(WorkerInfo workerInfo);
|
||||
|
||||
/**
|
||||
* 保存劳务人员门禁权限
|
||||
*
|
||||
* @param workerInfo
|
||||
*/
|
||||
void saveWorkerUFaceAuth(WorkerInfo workerInfo);
|
||||
|
||||
/**
|
||||
* 删除劳务人员
|
||||
*
|
||||
* @param workerInfo
|
||||
*/
|
||||
void deleteWorkerInfo(WorkerInfo workerInfo);
|
||||
|
||||
/**
|
||||
* 图片质量检测
|
||||
*
|
||||
* @param file
|
||||
* @return
|
||||
*/
|
||||
IccWorkerCall.CheckFaceResp checkFace(File file);
|
||||
}
|
||||
@ -0,0 +1,56 @@
|
||||
package com.zhgd.xmgl.call.factory;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.zhgd.jeecg.common.util.SpringContextUtils;
|
||||
import com.zhgd.xmgl.call.IccWorkerCall;
|
||||
import com.zhgd.xmgl.call.api.WorkerManufacturer;
|
||||
import com.zhgd.xmgl.modules.project.entity.Project;
|
||||
import com.zhgd.xmgl.modules.project.entity.ProjectUfaceConfig;
|
||||
import com.zhgd.xmgl.modules.project.enums.ProjectUfaceConfigSupplierTypeEnum;
|
||||
import com.zhgd.xmgl.modules.project.service.IProjectService;
|
||||
import com.zhgd.xmgl.modules.project.service.IProjectUfaceConfigService;
|
||||
import com.zhgd.xmgl.security.util.SecurityUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@Component
|
||||
public class CarManufacturerFactory {
|
||||
@Lazy
|
||||
@Autowired
|
||||
public IProjectUfaceConfigService projectUfaceConfigService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private IProjectService projectService;
|
||||
|
||||
// /**
|
||||
// * 获取WorkerManufacturer
|
||||
// *
|
||||
// * @param projectSn
|
||||
// * @param type 1:人员和门禁,2:车辆
|
||||
// * @return
|
||||
// */
|
||||
// public WorkerManufacturer getWorkerManufacturer(String projectSn, int type) {
|
||||
// Project project = projectService.getOne(new LambdaQueryWrapper<Project>()
|
||||
// .eq(Project::getProjectSn, projectSn)
|
||||
// );
|
||||
// if (project == null) {
|
||||
// return null;
|
||||
// }
|
||||
// ProjectUfaceConfig ufaceConfig = null;
|
||||
// if (type == 1) {
|
||||
// ufaceConfig = projectUfaceConfigService.getOne(new LambdaQueryWrapper<ProjectUfaceConfig>()
|
||||
// .eq(ProjectUfaceConfig::getProjectSn, projectSn));
|
||||
// }
|
||||
// WorkerManufacturer manufacturer = null;
|
||||
// if (Objects.equals(project.getSyncIcc(), 1) &&
|
||||
// (type == 2 || (type == 1 && ufaceConfig != null && ufaceConfig.getSupplierType().equals(ProjectUfaceConfigSupplierTypeEnum.ICC.getCode())))) {
|
||||
// manufacturer = SpringContextUtils.getBean(IccWorkerCall.class);
|
||||
// manufacturer.setNoticeUser(SecurityUtils.getUser().getUserId());
|
||||
// manufacturer.setConfig(project);
|
||||
// }
|
||||
// return manufacturer;
|
||||
// }
|
||||
}
|
||||
@ -1,43 +0,0 @@
|
||||
package com.zhgd.xmgl.call.factory;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.zhgd.jeecg.common.util.SpringContextUtils;
|
||||
import com.zhgd.xmgl.call.IccCall;
|
||||
import com.zhgd.xmgl.call.api.WorkerCarManufacturer;
|
||||
import com.zhgd.xmgl.modules.project.entity.Project;
|
||||
import com.zhgd.xmgl.modules.project.service.IProjectService;
|
||||
import com.zhgd.xmgl.security.util.SecurityUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@Component
|
||||
public class WorkerCarManufacturerFactory {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private IProjectService projectService;
|
||||
|
||||
/**
|
||||
* 获取WorkerCarManufacturer
|
||||
*
|
||||
* @param projectSn
|
||||
* @return
|
||||
*/
|
||||
public WorkerCarManufacturer getWorkerCarManufacturer(String projectSn) {
|
||||
Project project = projectService.getOne(new LambdaQueryWrapper<Project>()
|
||||
.eq(Project::getProjectSn, projectSn)
|
||||
);
|
||||
if (project == null) {
|
||||
return null;
|
||||
}
|
||||
WorkerCarManufacturer manufacturer = null;
|
||||
if (Objects.equals(project.getSyncIcc(), 1)) {
|
||||
manufacturer = SpringContextUtils.getBean(IccCall.class);
|
||||
manufacturer.setNoticeUser(SecurityUtils.getUser().getUserId());
|
||||
manufacturer.setConfig(project);
|
||||
}
|
||||
return manufacturer;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,42 @@
|
||||
package com.zhgd.xmgl.call.factory;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.zhgd.jeecg.common.util.SpringContextUtils;
|
||||
import com.zhgd.xmgl.call.IccWorkerCall;
|
||||
import com.zhgd.xmgl.call.api.WorkerManufacturer;
|
||||
import com.zhgd.xmgl.modules.project.entity.ProjectUfaceConfig;
|
||||
import com.zhgd.xmgl.modules.project.enums.ProjectUfaceConfigSupplierTypeEnum;
|
||||
import com.zhgd.xmgl.modules.project.service.IProjectUfaceConfigService;
|
||||
import com.zhgd.xmgl.security.util.SecurityUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class WorkerManufacturerFactory {
|
||||
@Lazy
|
||||
@Autowired
|
||||
public IProjectUfaceConfigService projectUfaceConfigService;
|
||||
|
||||
/**
|
||||
* 获取WorkerManufacturer
|
||||
*
|
||||
* @param projectSn
|
||||
* @return
|
||||
*/
|
||||
public WorkerManufacturer getWorkerManufacturer(String projectSn) {
|
||||
ProjectUfaceConfig ufaceConfig = projectUfaceConfigService.getOne(new LambdaQueryWrapper<ProjectUfaceConfig>()
|
||||
.eq(ProjectUfaceConfig::getProjectSn, projectSn)
|
||||
);
|
||||
if (ufaceConfig == null) {
|
||||
return null;
|
||||
}
|
||||
WorkerManufacturer manufacturer = null;
|
||||
if (ufaceConfig.getSupplierType().equals(ProjectUfaceConfigSupplierTypeEnum.ICC.getCode())) {
|
||||
manufacturer = SpringContextUtils.getBean(IccWorkerCall.class);
|
||||
manufacturer.setNoticeUser(SecurityUtils.getUser().getUserId());
|
||||
manufacturer.setConfig(ufaceConfig);
|
||||
}
|
||||
return manufacturer;
|
||||
}
|
||||
}
|
||||
@ -31,7 +31,7 @@ public class ProjectUfaceConfig implements Serializable {
|
||||
@Excel(name = "项目SN", width = 15)
|
||||
@ApiModelProperty(value="项目SN")
|
||||
private java.lang.String projectSn;
|
||||
@ApiModelProperty(value = "1杭州宇泛智能科技,2用jdpush推送,3.mqtt,4.芊熠智能,5佳信捷,6佳信捷新设备,7海康门禁,8弹弓,9海康门禁isc")
|
||||
@ApiModelProperty(value = "1杭州宇泛智能科技,2用jdpush推送,3.mqtt,4.芊熠智能,5佳信捷,6佳信捷新设备,7海康门禁,8弹弓,9海康门禁isc,10icc")
|
||||
private java.lang.Integer supplierType;
|
||||
/**项目应用Id*/
|
||||
@Excel(name = "项目应用Id", width = 15)
|
||||
@ -54,4 +54,17 @@ public class ProjectUfaceConfig implements Serializable {
|
||||
|
||||
@ApiModelProperty(value="服务接口路径")
|
||||
private java.lang.String serviceUrl;
|
||||
|
||||
@ApiModelProperty(value = "大华clientId")
|
||||
private String iccClientId;
|
||||
@ApiModelProperty(value = "大华clientSecret")
|
||||
private String iccClientSecret;
|
||||
@ApiModelProperty(value = "大华ip")
|
||||
private String iccIp;
|
||||
@ApiModelProperty(value = "大华port")
|
||||
private String iccPort;
|
||||
@ApiModelProperty(value = "大华username")
|
||||
private String iccUserName;
|
||||
@ApiModelProperty(value = "大华password")
|
||||
private String iccPassword;
|
||||
}
|
||||
|
||||
@ -40,7 +40,11 @@ public enum ProjectUfaceConfigSupplierTypeEnum {
|
||||
/**
|
||||
*海康门禁isc
|
||||
*/
|
||||
HIKVISION_ACCESS_CONTROL_ISC(9, "海康门禁isc");
|
||||
HIKVISION_ACCESS_CONTROL_ISC(9, "海康门禁isc"),
|
||||
/**
|
||||
* ICC
|
||||
*/
|
||||
ICC(10, "ICC");
|
||||
|
||||
private final Integer code;
|
||||
private final String desc;
|
||||
|
||||
@ -20,8 +20,8 @@ import com.zhgd.jeecg.common.execption.OpenAlertException;
|
||||
import com.zhgd.jeecg.common.mybatis.EntityMap;
|
||||
import com.zhgd.redis.lock.RedisRepository;
|
||||
import com.zhgd.xmgl.async.AsyncHikvision;
|
||||
import com.zhgd.xmgl.call.api.WorkerCarManufacturer;
|
||||
import com.zhgd.xmgl.call.factory.WorkerCarManufacturerFactory;
|
||||
import com.zhgd.xmgl.call.api.WorkerManufacturer;
|
||||
import com.zhgd.xmgl.call.factory.WorkerManufacturerFactory;
|
||||
import com.zhgd.xmgl.constant.Cts;
|
||||
import com.zhgd.xmgl.entity.vo.ZwProjectDataVo;
|
||||
import com.zhgd.xmgl.modules.basicdata.constant.DictionaryConstant;
|
||||
@ -79,8 +79,10 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@ -89,6 +91,7 @@ import org.springframework.util.CollectionUtils;
|
||||
import javax.annotation.Resource;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.Function;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
@ -194,7 +197,10 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
||||
private String fmsMonitoringScreenPageUrl;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private WorkerCarManufacturerFactory workerCarManufacturerFactory;
|
||||
private WorkerManufacturerFactory workerManufacturerFactory;
|
||||
@Autowired
|
||||
@Qualifier("doubleCarbonExecutor")
|
||||
private ThreadPoolTaskExecutor threadPoolTaskExecutor;
|
||||
|
||||
@Override
|
||||
public List<String> getProjectSnList(String sn) {
|
||||
@ -374,9 +380,11 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
||||
|
||||
//同步海康
|
||||
asyncHikvision.editProjectForHikvision(old);
|
||||
WorkerCarManufacturer workerCarManufacturer = workerCarManufacturerFactory.getWorkerCarManufacturer(project.getProjectSn());
|
||||
if (workerCarManufacturer != null) {
|
||||
workerCarManufacturer.saveProject(project);
|
||||
WorkerManufacturer workerManufacturer = workerManufacturerFactory.getWorkerManufacturer(project.getProjectSn());
|
||||
if (workerManufacturer != null) {
|
||||
CompletableFuture.runAsync(() -> {
|
||||
workerManufacturer.saveProject(project);
|
||||
}, threadPoolTaskExecutor);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -12,6 +12,9 @@ import com.zhgd.jeecg.common.execption.OpenAlertException;
|
||||
import com.zhgd.jeecg.common.util.pass.HttpUtils;
|
||||
import com.zhgd.jeecg.upload.operation.FileOperation;
|
||||
import com.zhgd.xmgl.call.HikvisionCall;
|
||||
import com.zhgd.xmgl.call.IccWorkerCall;
|
||||
import com.zhgd.xmgl.call.api.WorkerManufacturer;
|
||||
import com.zhgd.xmgl.call.factory.WorkerManufacturerFactory;
|
||||
import com.zhgd.xmgl.modules.project.entity.Project;
|
||||
import com.zhgd.xmgl.modules.project.mapper.ProjectMapper;
|
||||
import com.zhgd.xmgl.modules.worker.entity.WorkerInfo;
|
||||
@ -29,6 +32,7 @@ import org.apache.commons.collections.MapUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@ -66,42 +70,72 @@ public class UfaceRecognitionController {
|
||||
private String imageUrlPrefix;
|
||||
@Value("${xingzong.inner.upload.image.url.prefix:}")
|
||||
private String xingzongInnerUploadImageUrlPrefix;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private WorkerManufacturerFactory workerManufacturerFactory;
|
||||
|
||||
@ApiOperation(value = "检测人脸照片是否有人脸", notes = "列表查询人脸设备信息", httpMethod = "POST")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "fileUrl", value = "照片路径", paramType = "body", required = true, dataType = "String"),
|
||||
@ApiImplicitParam(name = "projectSn", value = "项目sn", paramType = "body", required = false, dataType = "String"),
|
||||
})
|
||||
@PostMapping(value = "/checkFace")
|
||||
public Result<Map<String, Object>> checkFace(@RequestBody Map<String, Object> map) {
|
||||
Map<String, Object> data = new HashMap<>(16);
|
||||
String os = System.getProperty("os.name");
|
||||
if (os.toLowerCase().startsWith(WIN) || os.toLowerCase().startsWith(LINUX)) {
|
||||
String fileUrl = MapUtils.getString(map, "fileUrl");
|
||||
String errType = "0";
|
||||
String sucType = "1";
|
||||
String checkType = "checkType";
|
||||
String message = "message";
|
||||
String projectSn = MapUtils.getString(map, "projectSn");
|
||||
String fileUrl = MapUtils.getString(map, "fileUrl");
|
||||
WorkerManufacturer workerManufacturer = workerManufacturerFactory.getWorkerManufacturer(projectSn);
|
||||
if (workerManufacturer != null) {
|
||||
if (StringUtils.isNotEmpty(fileUrl)) {
|
||||
File file = new File(basePath, fileUrl);
|
||||
log.info("basePath:{},fileUrl:{}", basePath, fileUrl);
|
||||
ImageInfo imageInfo = getRGBData(file);
|
||||
List<FaceInfo> faceInfoList = new ArrayList<FaceInfo>();
|
||||
int errorCode = faceEngine.detectFaces(imageInfo.getImageData(), imageInfo.getWidth(), imageInfo.getHeight(), imageInfo.getImageFormat(), faceInfoList);
|
||||
log.info("errorCode:{}", errorCode);
|
||||
if (faceInfoList.size() > 0) {
|
||||
if (faceInfoList.size() > 1) {
|
||||
FileOperation.deleteFile(file);
|
||||
data.put("checkType", "0");
|
||||
data.put("message", "检测到多张人脸");
|
||||
} else {
|
||||
data.put("checkType", "1");
|
||||
data.put("message", "成功");
|
||||
}
|
||||
IccWorkerCall.CheckFaceResp resp = workerManufacturer.checkFace(file);
|
||||
if (resp.getSuccess()) {
|
||||
data.put(checkType, sucType);
|
||||
data.put(message, "成功");
|
||||
} else {
|
||||
FileOperation.deleteFile(file);
|
||||
data.put("checkType", "0");
|
||||
data.put("message", "未检测到人脸");
|
||||
data.put(checkType, errType);
|
||||
data.put(message, resp.getErrMsg());
|
||||
}
|
||||
log.info("{}", faceInfoList);
|
||||
} else {
|
||||
data.put("checkType", "0");
|
||||
data.put("message", "图片路径不正确");
|
||||
data.put(checkType, errType);
|
||||
data.put(message, "图片路径不正确");
|
||||
}
|
||||
} else {
|
||||
if (os.toLowerCase().startsWith(WIN) || os.toLowerCase().startsWith(LINUX)) {
|
||||
if (StringUtils.isNotEmpty(fileUrl)) {
|
||||
File file = new File(basePath, fileUrl);
|
||||
log.info("basePath:{},fileUrl:{}", basePath, fileUrl);
|
||||
ImageInfo imageInfo = getRGBData(file);
|
||||
List<FaceInfo> faceInfoList = new ArrayList<FaceInfo>();
|
||||
int errorCode = faceEngine.detectFaces(imageInfo.getImageData(), imageInfo.getWidth(), imageInfo.getHeight(), imageInfo.getImageFormat(), faceInfoList);
|
||||
log.info("errorCode:{}", errorCode);
|
||||
if (faceInfoList.size() > 0) {
|
||||
if (faceInfoList.size() > 1) {
|
||||
FileOperation.deleteFile(file);
|
||||
data.put(checkType, errType);
|
||||
data.put(message, "检测到多张人脸");
|
||||
} else {
|
||||
data.put(checkType, sucType);
|
||||
data.put(message, "成功");
|
||||
}
|
||||
} else {
|
||||
FileOperation.deleteFile(file);
|
||||
data.put(checkType, errType);
|
||||
data.put(message, "未检测到人脸");
|
||||
}
|
||||
log.info("{}", faceInfoList);
|
||||
} else {
|
||||
data.put(checkType, errType);
|
||||
data.put(message, "图片路径不正确");
|
||||
}
|
||||
} else {
|
||||
data.put(checkType, errType);
|
||||
data.put(message, "该系统不支持人脸识别");
|
||||
}
|
||||
}
|
||||
return Result.success(data);
|
||||
|
||||
@ -352,7 +352,8 @@ public class WorkerInfo implements Serializable {
|
||||
*/
|
||||
@ApiModelProperty(value = "考勤组id")
|
||||
private Long attendanceGroupV2Id;
|
||||
|
||||
@ApiModelProperty(value="icc同步id")
|
||||
private java.lang.Long iccId ;
|
||||
@TableField(exist = false)
|
||||
@ApiModelProperty(value = "人员性质")
|
||||
private String workerNatureName;
|
||||
|
||||
@ -7,8 +7,8 @@ import com.zhgd.jeecg.common.mybatis.EntityMap;
|
||||
import com.zhgd.xmgl.async.AsyncHikvision;
|
||||
import com.zhgd.xmgl.async.AsyncJiLianDa;
|
||||
import com.zhgd.xmgl.async.AsyncWorker;
|
||||
import com.zhgd.xmgl.call.api.WorkerCarManufacturer;
|
||||
import com.zhgd.xmgl.call.factory.WorkerCarManufacturerFactory;
|
||||
import com.zhgd.xmgl.call.api.WorkerManufacturer;
|
||||
import com.zhgd.xmgl.call.factory.WorkerManufacturerFactory;
|
||||
import com.zhgd.xmgl.modules.gt.entity.GtMaterialInOutWarehouse;
|
||||
import com.zhgd.xmgl.modules.worker.entity.DepartmentInfo;
|
||||
import com.zhgd.xmgl.modules.worker.entity.WorkerInfo;
|
||||
@ -19,11 +19,14 @@ import com.zhgd.xmgl.modules.worker.mapper.WorkerInfoMapper;
|
||||
import com.zhgd.xmgl.modules.worker.service.IDepartmentInfoService;
|
||||
import com.zhgd.xmgl.util.MessageUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
/**
|
||||
* @Description: 劳务人员部门
|
||||
@ -46,7 +49,10 @@ public class DepartmentInfoServiceImpl extends ServiceImpl<DepartmentInfoMapper,
|
||||
private AsyncHikvision asyncHikvision;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private WorkerCarManufacturerFactory workerCarManufacturerFactory;
|
||||
private WorkerManufacturerFactory workerManufacturerFactory;
|
||||
@Autowired
|
||||
@Qualifier("doubleCarbonExecutor")
|
||||
private ThreadPoolTaskExecutor threadPoolTaskExecutor;
|
||||
|
||||
@Override
|
||||
public void removeDepartmentInfo(String id) {
|
||||
@ -66,9 +72,11 @@ public class DepartmentInfoServiceImpl extends ServiceImpl<DepartmentInfoMapper,
|
||||
|
||||
//同步海康
|
||||
asyncHikvision.deleteDepartmentInfoForHikvision(departmentInfo.getId() + "", departmentInfo);
|
||||
WorkerCarManufacturer workerCarManufacturer = workerCarManufacturerFactory.getWorkerCarManufacturer(departmentInfo.getProjectSn());
|
||||
if (workerCarManufacturer != null) {
|
||||
workerCarManufacturer.deleteDepartmentInfo(departmentInfo);
|
||||
WorkerManufacturer workerManufacturer = workerManufacturerFactory.getWorkerManufacturer(departmentInfo.getProjectSn());
|
||||
if (workerManufacturer != null) {
|
||||
CompletableFuture.runAsync(() -> {
|
||||
workerManufacturer.deleteDepartmentInfo(departmentInfo);
|
||||
},threadPoolTaskExecutor);
|
||||
}
|
||||
}
|
||||
|
||||
@ -110,9 +118,11 @@ public class DepartmentInfoServiceImpl extends ServiceImpl<DepartmentInfoMapper,
|
||||
|
||||
//同步海康
|
||||
asyncHikvision.addDepartmentInfoForHikvision(departmentInfo);
|
||||
WorkerCarManufacturer workerCarManufacturer = workerCarManufacturerFactory.getWorkerCarManufacturer(departmentInfo.getProjectSn());
|
||||
if (workerCarManufacturer != null) {
|
||||
workerCarManufacturer.saveDepartmentInfo(departmentInfo);
|
||||
WorkerManufacturer workerManufacturer = workerManufacturerFactory.getWorkerManufacturer(departmentInfo.getProjectSn());
|
||||
if (workerManufacturer != null) {
|
||||
CompletableFuture.runAsync(() -> {
|
||||
workerManufacturer.saveDepartmentInfo(departmentInfo);
|
||||
}, threadPoolTaskExecutor);
|
||||
}
|
||||
return departmentInfo;
|
||||
}
|
||||
@ -135,9 +145,11 @@ public class DepartmentInfoServiceImpl extends ServiceImpl<DepartmentInfoMapper,
|
||||
|
||||
//同步海康
|
||||
asyncHikvision.editDepartmentInfoForHikvision(departmentInfo);
|
||||
WorkerCarManufacturer workerCarManufacturer = workerCarManufacturerFactory.getWorkerCarManufacturer(departmentInfo.getProjectSn());
|
||||
if (workerCarManufacturer != null) {
|
||||
workerCarManufacturer.saveDepartmentInfo(departmentInfo);
|
||||
WorkerManufacturer workerManufacturer = workerManufacturerFactory.getWorkerManufacturer(departmentInfo.getProjectSn());
|
||||
if (workerManufacturer != null) {
|
||||
CompletableFuture.runAsync(() -> {
|
||||
workerManufacturer.saveDepartmentInfo(departmentInfo);
|
||||
}, threadPoolTaskExecutor);
|
||||
}
|
||||
return departmentInfo;
|
||||
}
|
||||
|
||||
@ -21,8 +21,8 @@ import com.zhgd.xmgl.async.AsyncHikvision;
|
||||
import com.zhgd.xmgl.async.AsyncJiLianDa;
|
||||
import com.zhgd.xmgl.async.AsyncWorker;
|
||||
import com.zhgd.xmgl.base.CompanyVo;
|
||||
import com.zhgd.xmgl.call.api.WorkerCarManufacturer;
|
||||
import com.zhgd.xmgl.call.factory.WorkerCarManufacturerFactory;
|
||||
import com.zhgd.xmgl.call.api.WorkerManufacturer;
|
||||
import com.zhgd.xmgl.call.factory.WorkerManufacturerFactory;
|
||||
import com.zhgd.xmgl.modules.basicdata.service.ISystemUserService;
|
||||
import com.zhgd.xmgl.modules.basicdata.service.impl.CompanyServiceImpl;
|
||||
import com.zhgd.xmgl.modules.exam.entity.ExamTrain;
|
||||
@ -62,12 +62,15 @@ import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -144,7 +147,10 @@ public class EnterpriseInfoServiceImpl extends ServiceImpl<EnterpriseInfoMapper,
|
||||
private WorkerAttendanceMapper workerAttendanceMapper;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private WorkerCarManufacturerFactory workerCarManufacturerFactory;
|
||||
private WorkerManufacturerFactory workerManufacturerFactory;
|
||||
@Autowired
|
||||
@Qualifier("doubleCarbonExecutor")
|
||||
private ThreadPoolTaskExecutor threadPoolTaskExecutor;
|
||||
|
||||
@Override
|
||||
public List<EntityMap> getEnterpriseInfoList(Map<String, Object> map) {
|
||||
@ -268,9 +274,11 @@ public class EnterpriseInfoServiceImpl extends ServiceImpl<EnterpriseInfoMapper,
|
||||
|
||||
//同步海康
|
||||
asyncHikvision.addEnterpriseInfoForHikvision(enterpriseInfo);
|
||||
WorkerCarManufacturer workerCarManufacturer = workerCarManufacturerFactory.getWorkerCarManufacturer(enterpriseInfo.getProjectSn());
|
||||
if (workerCarManufacturer != null) {
|
||||
workerCarManufacturer.saveEnterpriseInfo(enterpriseInfo);
|
||||
WorkerManufacturer workerManufacturer = workerManufacturerFactory.getWorkerManufacturer(enterpriseInfo.getProjectSn());
|
||||
if (workerManufacturer != null) {
|
||||
CompletableFuture.runAsync(() -> {
|
||||
workerManufacturer.saveEnterpriseInfo(enterpriseInfo);
|
||||
}, threadPoolTaskExecutor);
|
||||
}
|
||||
return enterpriseInfo;
|
||||
}
|
||||
@ -325,9 +333,11 @@ public class EnterpriseInfoServiceImpl extends ServiceImpl<EnterpriseInfoMapper,
|
||||
}
|
||||
//同步海康
|
||||
asyncHikvision.deleteEnterpriseInfoForHikvision(projectSn, enterpriseInfo.getEnterpriseName());
|
||||
WorkerCarManufacturer workerCarManufacturer = workerCarManufacturerFactory.getWorkerCarManufacturer(projectSn);
|
||||
if (workerCarManufacturer != null) {
|
||||
workerCarManufacturer.deleteEnterpriseInfo(enterpriseInfo);
|
||||
WorkerManufacturer workerManufacturer = workerManufacturerFactory.getWorkerManufacturer(projectSn);
|
||||
if (workerManufacturer != null) {
|
||||
CompletableFuture.runAsync(() -> {
|
||||
workerManufacturer.deleteEnterpriseInfo(enterpriseInfo);
|
||||
},threadPoolTaskExecutor);
|
||||
}
|
||||
}
|
||||
|
||||
@ -381,9 +391,11 @@ public class EnterpriseInfoServiceImpl extends ServiceImpl<EnterpriseInfoMapper,
|
||||
|
||||
//同步海康
|
||||
asyncHikvision.editEnterpriseInfoForHikvision(enterpriseInfo);
|
||||
WorkerCarManufacturer workerCarManufacturer = workerCarManufacturerFactory.getWorkerCarManufacturer(enterpriseInfo.getProjectSn());
|
||||
if (workerCarManufacturer != null) {
|
||||
workerCarManufacturer.saveEnterpriseInfo(enterpriseInfo);
|
||||
WorkerManufacturer workerManufacturer = workerManufacturerFactory.getWorkerManufacturer(enterpriseInfo.getProjectSn());
|
||||
if (workerManufacturer != null) {
|
||||
CompletableFuture.runAsync(() -> {
|
||||
workerManufacturer.saveEnterpriseInfo(enterpriseInfo);
|
||||
}, threadPoolTaskExecutor);
|
||||
}
|
||||
return enterpriseInfo;
|
||||
}
|
||||
@ -793,7 +805,7 @@ public class EnterpriseInfoServiceImpl extends ServiceImpl<EnterpriseInfoMapper,
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnterpriseInfo getEnterpriseByProjectSnAndEnterpriseId(String projectSn,Long enterpriseId) {
|
||||
public EnterpriseInfo getEnterpriseByProjectSnAndEnterpriseId(String projectSn, Long enterpriseId) {
|
||||
List<EntityMap> infoList = this.getEnterpriseInfoList(new MapBuilder<String, Object>()
|
||||
.put("projectSn", projectSn)
|
||||
.put("enterpriseId", enterpriseId)
|
||||
|
||||
@ -11,8 +11,8 @@ import com.zhgd.jeecg.common.mybatis.EntityMap;
|
||||
import com.zhgd.xmgl.async.AsyncHikvision;
|
||||
import com.zhgd.xmgl.async.AsyncJiLianDa;
|
||||
import com.zhgd.xmgl.async.AsyncWorker;
|
||||
import com.zhgd.xmgl.call.api.WorkerCarManufacturer;
|
||||
import com.zhgd.xmgl.call.factory.WorkerCarManufacturerFactory;
|
||||
import com.zhgd.xmgl.call.api.WorkerManufacturer;
|
||||
import com.zhgd.xmgl.call.factory.WorkerManufacturerFactory;
|
||||
import com.zhgd.xmgl.modules.basicdata.service.impl.SystemUserServiceImpl;
|
||||
import com.zhgd.xmgl.modules.worker.entity.EnterpriseInfo;
|
||||
import com.zhgd.xmgl.modules.worker.entity.TeamInfo;
|
||||
@ -29,11 +29,14 @@ import com.zhgd.xmgl.util.MessageUtil;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@ -69,7 +72,10 @@ public class TeamInfoServiceImpl extends ServiceImpl<TeamInfoMapper, TeamInfo> i
|
||||
private AsyncHikvision asyncHikvision;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private WorkerCarManufacturerFactory workerCarManufacturerFactory;
|
||||
private WorkerManufacturerFactory workerManufacturerFactory;
|
||||
@Autowired
|
||||
@Qualifier("doubleCarbonExecutor")
|
||||
private ThreadPoolTaskExecutor threadPoolTaskExecutor;
|
||||
|
||||
@Override
|
||||
public void removeTeamInfo(String id) {
|
||||
@ -89,9 +95,11 @@ public class TeamInfoServiceImpl extends ServiceImpl<TeamInfoMapper, TeamInfo> i
|
||||
|
||||
//同步海康
|
||||
asyncHikvision.deleteTeamInfoForHikvision(teamInfo.getId() + "", teamInfo);
|
||||
WorkerCarManufacturer workerCarManufacturer = workerCarManufacturerFactory.getWorkerCarManufacturer(teamInfo.getProjectSn());
|
||||
if (workerCarManufacturer != null) {
|
||||
workerCarManufacturer.deleteTeamInfo(teamInfo);
|
||||
WorkerManufacturer workerManufacturer = workerManufacturerFactory.getWorkerManufacturer(teamInfo.getProjectSn());
|
||||
if (workerManufacturer != null) {
|
||||
CompletableFuture.runAsync(() -> {
|
||||
workerManufacturer.deleteTeamInfo(teamInfo);
|
||||
},threadPoolTaskExecutor);
|
||||
}
|
||||
}
|
||||
|
||||
@ -149,9 +157,11 @@ public class TeamInfoServiceImpl extends ServiceImpl<TeamInfoMapper, TeamInfo> i
|
||||
|
||||
//同步海康
|
||||
asyncHikvision.editTeamInfoForHikvision(teamInfo);
|
||||
WorkerCarManufacturer workerCarManufacturer = workerCarManufacturerFactory.getWorkerCarManufacturer(teamInfo.getProjectSn());
|
||||
if (workerCarManufacturer != null) {
|
||||
workerCarManufacturer.saveTeamInfo(teamInfo);
|
||||
WorkerManufacturer workerManufacturer = workerManufacturerFactory.getWorkerManufacturer(teamInfo.getProjectSn());
|
||||
if (workerManufacturer != null) {
|
||||
CompletableFuture.runAsync(() -> {
|
||||
workerManufacturer.saveTeamInfo(teamInfo);
|
||||
}, threadPoolTaskExecutor);
|
||||
}
|
||||
return teamInfo;
|
||||
}
|
||||
@ -185,9 +195,11 @@ public class TeamInfoServiceImpl extends ServiceImpl<TeamInfoMapper, TeamInfo> i
|
||||
|
||||
//同步海康
|
||||
asyncHikvision.addTeamInfoForHikvision(teamInfo);
|
||||
WorkerCarManufacturer workerCarManufacturer = workerCarManufacturerFactory.getWorkerCarManufacturer(teamInfo.getProjectSn());
|
||||
if (workerCarManufacturer != null) {
|
||||
workerCarManufacturer.saveTeamInfo(teamInfo);
|
||||
WorkerManufacturer workerManufacturer = workerManufacturerFactory.getWorkerManufacturer(teamInfo.getProjectSn());
|
||||
if (workerManufacturer != null) {
|
||||
CompletableFuture.runAsync(() -> {
|
||||
workerManufacturer.saveTeamInfo(teamInfo);
|
||||
},threadPoolTaskExecutor);
|
||||
}
|
||||
return teamInfo;
|
||||
}
|
||||
|
||||
@ -32,6 +32,8 @@ import com.zhgd.xmgl.async.AsyncJiLianDa;
|
||||
import com.zhgd.xmgl.async.AsyncWorker;
|
||||
import com.zhgd.xmgl.base.entity.vo.TrendOneVo;
|
||||
import com.zhgd.xmgl.call.HikvisionCall;
|
||||
import com.zhgd.xmgl.call.api.WorkerManufacturer;
|
||||
import com.zhgd.xmgl.call.factory.WorkerManufacturerFactory;
|
||||
import com.zhgd.xmgl.constant.Cts;
|
||||
import com.zhgd.xmgl.entity.vo.NumberTimeTableVo;
|
||||
import com.zhgd.xmgl.modules.basicdata.entity.Company;
|
||||
@ -84,10 +86,12 @@ import org.apache.commons.collections.MapUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.scheduling.annotation.AsyncResult;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@ -103,6 +107,7 @@ import java.math.RoundingMode;
|
||||
import java.nio.charset.Charset;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
@ -295,6 +300,12 @@ public class WorkerInfoServiceImpl extends ServiceImpl<WorkerInfoMapper, WorkerI
|
||||
@Lazy
|
||||
@Resource
|
||||
private IUfaceDevService ufaceDevService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private WorkerManufacturerFactory workerManufacturerFactory;
|
||||
@Autowired
|
||||
@Qualifier("doubleCarbonExecutor")
|
||||
private ThreadPoolTaskExecutor threadPoolTaskExecutor;
|
||||
|
||||
/**
|
||||
* 人员管理分页
|
||||
@ -535,6 +546,14 @@ public class WorkerInfoServiceImpl extends ServiceImpl<WorkerInfoMapper, WorkerI
|
||||
.eq(WorkerInfoDelete::getProjectSn, workerInfo.getProjectSn())
|
||||
.eq(WorkerInfoDelete::getIdCard, workerInfo.getIdCard())
|
||||
);
|
||||
WorkerManufacturer workerManufacturer = workerManufacturerFactory.getWorkerManufacturer(workerInfo.getProjectSn());
|
||||
if (workerManufacturer != null) {
|
||||
CompletableFuture.runAsync(() -> {
|
||||
workerManufacturer.saveWorkerInfo(workerInfo);
|
||||
}, threadPoolTaskExecutor).thenRun(() -> {
|
||||
workerManufacturer.saveWorkerUFaceAuth(workerInfo);
|
||||
});
|
||||
}
|
||||
return workerInfo;
|
||||
}
|
||||
|
||||
@ -615,6 +634,14 @@ public class WorkerInfoServiceImpl extends ServiceImpl<WorkerInfoMapper, WorkerI
|
||||
}
|
||||
asyncJiLianDa.saveWorkerInfo(workerInfo);
|
||||
updateWorkerHkStatus(workerInfo);
|
||||
WorkerManufacturer workerManufacturer = workerManufacturerFactory.getWorkerManufacturer(workerInfo.getProjectSn());
|
||||
if (workerManufacturer != null) {
|
||||
CompletableFuture.runAsync(() -> {
|
||||
workerManufacturer.saveWorkerInfo(workerInfo);
|
||||
}, threadPoolTaskExecutor).thenRun(() -> {
|
||||
workerManufacturer.saveWorkerUFaceAuth(workerInfo);
|
||||
});
|
||||
}
|
||||
return workerInfo;
|
||||
}
|
||||
|
||||
@ -657,7 +684,12 @@ public class WorkerInfoServiceImpl extends ServiceImpl<WorkerInfoMapper, WorkerI
|
||||
|
||||
//同步海康
|
||||
deleteWorkerForHikvision(String.valueOf(workerInfo.getId()), workerInfo);
|
||||
|
||||
WorkerManufacturer workerManufacturer = workerManufacturerFactory.getWorkerManufacturer(workerInfo.getProjectSn());
|
||||
if (workerManufacturer != null) {
|
||||
CompletableFuture.runAsync(() -> {
|
||||
workerManufacturer.deleteWorkerInfo(workerInfo);
|
||||
}, threadPoolTaskExecutor);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkExistAccount(String id) {
|
||||
@ -2027,6 +2059,12 @@ public class WorkerInfoServiceImpl extends ServiceImpl<WorkerInfoMapper, WorkerI
|
||||
workerInfoMapper.updateById(workerInfo);
|
||||
//同步海康
|
||||
this.editWorkerForHikvision(workerInfo);
|
||||
WorkerManufacturer workerManufacturer = workerManufacturerFactory.getWorkerManufacturer(workerInfo.getProjectSn());
|
||||
if (workerManufacturer != null) {
|
||||
CompletableFuture.runAsync(() -> {
|
||||
workerManufacturer.saveWorkerInfo(workerInfo);
|
||||
}, threadPoolTaskExecutor);
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@ -2034,6 +2072,12 @@ public class WorkerInfoServiceImpl extends ServiceImpl<WorkerInfoMapper, WorkerI
|
||||
workerInfoMapper.insert(workerInfo);
|
||||
//同步海康
|
||||
this.addWorkerForHikvision(workerInfo);
|
||||
WorkerManufacturer workerManufacturer = workerManufacturerFactory.getWorkerManufacturer(workerInfo.getProjectSn());
|
||||
if (workerManufacturer != null) {
|
||||
CompletableFuture.runAsync(() -> {
|
||||
workerManufacturer.saveWorkerInfo(workerInfo);
|
||||
}, threadPoolTaskExecutor);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkParams(List<Map<String, String>> list, Map<String, Object> teamMap, Map<String, Object> departmentMap) {
|
||||
|
||||
@ -7,9 +7,41 @@ import org.apache.commons.codec.binary.Base64;
|
||||
import java.io.*;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
public class Base64Util {
|
||||
// 文件扩展名 -> MIME类型映射
|
||||
private static final Map<String, String> MIME_TYPES = new HashMap<>();
|
||||
|
||||
static {
|
||||
// 图片
|
||||
MIME_TYPES.put(".jpg", "image/jpeg");
|
||||
MIME_TYPES.put(".jpeg", "image/jpeg");
|
||||
MIME_TYPES.put(".png", "image/png");
|
||||
MIME_TYPES.put(".gif", "image/gif");
|
||||
MIME_TYPES.put(".bmp", "image/bmp");
|
||||
MIME_TYPES.put(".webp", "image/webp");
|
||||
|
||||
// 文档
|
||||
MIME_TYPES.put(".pdf", "application/pdf");
|
||||
MIME_TYPES.put(".txt", "text/plain");
|
||||
|
||||
// Office
|
||||
MIME_TYPES.put(".doc", "application/msword");
|
||||
MIME_TYPES.put(".docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document");
|
||||
MIME_TYPES.put(".xls", "application/vnd.ms-excel");
|
||||
MIME_TYPES.put(".xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||
MIME_TYPES.put(".ppt", "application/vnd.ms-powerpoint");
|
||||
MIME_TYPES.put(".pptx", "application/vnd.openxmlformats-officedocument.presentationml.presentation");
|
||||
|
||||
// 压缩包
|
||||
MIME_TYPES.put(".zip", "application/zip");
|
||||
MIME_TYPES.put(".rar", "application/x-rar-compressed");
|
||||
MIME_TYPES.put(".7z", "application/x-7z-compressed");
|
||||
}
|
||||
|
||||
public static String getURLImage(String imageUrl) {
|
||||
String base64String = "";
|
||||
try {
|
||||
@ -40,19 +72,31 @@ public class Base64Util {
|
||||
* @param imgPath
|
||||
*/
|
||||
public static String convertFileToBase64(String imgPath) {
|
||||
byte[] data = null;
|
||||
// 读取图片字节数组
|
||||
try {
|
||||
InputStream in = new FileInputStream(imgPath);
|
||||
data = new byte[in.available()];
|
||||
in.read(data);
|
||||
in.close();
|
||||
} catch (IOException e) {
|
||||
log.error("error:", e);
|
||||
}
|
||||
// 对字节数组进行Base64编码,得到Base64编码的字符串
|
||||
String base64Str = Base64.encodeBase64String(data);
|
||||
return base64Str;
|
||||
byte[] fileBytes = FileUtil.readBytes(imgPath);
|
||||
return Base64.encodeBase64String(fileBytes);
|
||||
}
|
||||
|
||||
/**
|
||||
* 本地文件(图片、excel等)转换成Base64字符串(带前缀)
|
||||
*
|
||||
* @param filePath
|
||||
* @return
|
||||
*/
|
||||
public static String convertFileToBase64WithPrefix(String filePath) {
|
||||
String base64 = convertFileToBase64(filePath);
|
||||
String fileExt = getFileExtension(filePath).toLowerCase();
|
||||
|
||||
// 获取对应的MIME类型,默认使用application/octet-stream
|
||||
String mimeType = MIME_TYPES.getOrDefault(fileExt, "application/octet-stream");
|
||||
return "data:" + mimeType + ";base64," + base64;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件扩展名(带点)
|
||||
*/
|
||||
private static String getFileExtension(String filename) {
|
||||
int dotIndex = filename.lastIndexOf('.');
|
||||
return (dotIndex == -1) ? "" : filename.substring(dotIndex);
|
||||
}
|
||||
|
||||
public static String getFileToBase64(String imgPath) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user