新增相关方人员车辆大华同步执行器
parent
04f9106abd
commit
56e01d59b4
|
|
@ -1,7 +1,6 @@
|
|||
package com.zcloud.primeport.command;
|
||||
|
||||
import com.alibaba.cola.exception.BizException;
|
||||
import com.zcloud.gbscommon.utils.Base64Util;
|
||||
import com.zcloud.primeport.domain.gateway.DaHuaGateway;
|
||||
import com.zcloud.primeport.domain.gateway.PersonApplyGateway;
|
||||
import com.zcloud.primeport.domain.model.DaHuaPersonSyncCmd;
|
||||
|
|
@ -9,9 +8,7 @@ import com.zcloud.primeport.domain.model.PersonApplyE;
|
|||
import com.zcloud.primeport.domain.model.XgfApplyPersonE;
|
||||
import com.zcloud.primeport.dto.PersonApplyUpdateCmd;
|
||||
import jodd.util.Base64;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -22,9 +19,8 @@ import java.util.Map;
|
|||
/**
|
||||
* 相关方人员同步大华平台。
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DaHuaPersonSyncExe {
|
||||
|
||||
private static final int RELATED_PARTY = 3;
|
||||
|
|
@ -32,9 +28,6 @@ public class DaHuaPersonSyncExe {
|
|||
private final DaHuaGateway daHuaGateway;
|
||||
private final PersonApplyGateway personApplyGateway;
|
||||
|
||||
@Value("${file.url:}")
|
||||
private String fileUrl;
|
||||
|
||||
/**
|
||||
* 相关方人员审核通过后,按证件号判断新增或更新大华人员。
|
||||
*/
|
||||
|
|
@ -125,46 +118,11 @@ public class DaHuaPersonSyncExe {
|
|||
DaHuaPersonSyncCmd.PersonBiosignature face = new DaHuaPersonSyncCmd.PersonBiosignature();
|
||||
face.setType(3);
|
||||
face.setIndex(1);
|
||||
// userFaceUrl 是文件服务器相对路径,读取图片并转换为 Base64 后交给大华网关。
|
||||
face.setBase64Data(resolveFaceBase64(faceUrl));
|
||||
face.setPath(faceUrl);
|
||||
cmd.setPersonBiosignatures(Collections.singletonList(face));
|
||||
return cmd;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据文件服务地址读取相关方人员头像并转换为图片 Base64。
|
||||
* 大华人员接口的 path 必须是大华图片上传接口返回的 fileUrl,不能直接使用本系统路径。
|
||||
*/
|
||||
private String resolveFaceBase64(String faceUrl) {
|
||||
if (faceUrl == null || faceUrl.trim().isEmpty()) {
|
||||
throw new BizException("相关方人员头像不能为空");
|
||||
}
|
||||
if (fileUrl == null || fileUrl.trim().isEmpty()) {
|
||||
throw new BizException("文件访问地址未配置");
|
||||
}
|
||||
String baseUrl = fileUrl.trim();
|
||||
String relativePath = faceUrl.trim();
|
||||
String imageUrl = baseUrl.endsWith("/")
|
||||
? baseUrl + removeLeadingSlash(relativePath)
|
||||
: baseUrl + "/" + removeLeadingSlash(relativePath);
|
||||
try {
|
||||
String faceBase64 = Base64Util.urlToBase64(imageUrl);
|
||||
if (faceBase64 == null || faceBase64.trim().isEmpty()) {
|
||||
throw new BizException("相关方人员头像转换失败");
|
||||
}
|
||||
return faceBase64;
|
||||
} catch (BizException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
log.error("获取相关方人员头像失败, imageUrl={}", imageUrl, e);
|
||||
throw new BizException("获取相关方人员头像失败");
|
||||
}
|
||||
}
|
||||
|
||||
private String removeLeadingSlash(String path) {
|
||||
return path.startsWith("/") ? path.substring(1) : path;
|
||||
}
|
||||
|
||||
private String decodeUserCard(String userCard) {
|
||||
try {
|
||||
return Base64.decodeToString(userCard);
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
package com.zcloud.primeport.command;
|
||||
|
||||
import com.alibaba.cola.exception.BizException;
|
||||
import com.zcloud.gbscommon.dahua.cmd.DaHuaCarAddCmd;
|
||||
import com.zcloud.primeport.domain.enums.VehicleBelongTypeEnum;
|
||||
import com.zcloud.primeport.domain.gateway.DaHuaGateway;
|
||||
import com.zcloud.primeport.domain.gateway.VehicleApplyGateway;
|
||||
import com.zcloud.primeport.domain.model.DaHuaCarAddCmd;
|
||||
import com.zcloud.primeport.domain.model.VehicleApplyE;
|
||||
import com.zcloud.primeport.plan.mjDevice.dto.CarEnum;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
|
@ -25,18 +25,18 @@ public class DaHuaVehicleSyncExe {
|
|||
private final VehicleApplyGateway vehicleApplyGateway;
|
||||
|
||||
/**
|
||||
* 车辆审核通过后,同步新增大华车辆(所有车辆类型均同步)。
|
||||
* 相关方车辆审核通过后,同步新增大华车辆。
|
||||
*/
|
||||
public void syncApprovedVehicle(Long vehicleApplyId) {
|
||||
VehicleApplyE vehicle = vehicleApplyGateway.getById(vehicleApplyId);
|
||||
if (vehicle == null) {
|
||||
if (!isRelatedPartyVehicle(vehicle)) {
|
||||
return;
|
||||
}
|
||||
syncAddedVehicle(vehicle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除车辆时,同步删除对应的大华车辆(所有车辆类型均同步)。
|
||||
* 删除相关方车辆时,同步删除对应的大华车辆。
|
||||
*/
|
||||
public void syncDeletedVehicles(List<VehicleApplyE> vehicles) {
|
||||
if (vehicles == null || vehicles.isEmpty()) {
|
||||
|
|
@ -44,7 +44,7 @@ public class DaHuaVehicleSyncExe {
|
|||
}
|
||||
List<String> carNumList = new ArrayList<>();
|
||||
for (VehicleApplyE vehicle : vehicles) {
|
||||
if (vehicle != null && vehicle.getLicenceNo() != null) {
|
||||
if (isRelatedPartyVehicle(vehicle)) {
|
||||
carNumList.add(vehicle.getLicenceNo());
|
||||
}
|
||||
}
|
||||
|
|
@ -61,11 +61,8 @@ public class DaHuaVehicleSyncExe {
|
|||
DaHuaCarAddCmd cmd = new DaHuaCarAddCmd();
|
||||
cmd.setCarNum(vehicle.getLicenceNo());
|
||||
cmd.setCarNumColor(CarEnum.getMenuKeyByPath(vehicle.getLicenceType()));
|
||||
Long dahuaDeptId = daHuaGateway.findDahuaDepartmentIdByCorpId(vehicle.getVehicleCorpId());
|
||||
if (dahuaDeptId == null) {
|
||||
throw new BizException("未找到大华部门映射配置, corpId=" + vehicle.getVehicleCorpId());
|
||||
}
|
||||
cmd.setDepartmentId(dahuaDeptId);
|
||||
// 大华车辆类型与本地字典不一致,该字段可选,不能直接透传本地 vehicleType。
|
||||
cmd.setDepartmentId(1L);
|
||||
cmd.setDepartmentName(vehicle.getVehicleDepartmentName());
|
||||
cmd.setService("evo-thirdParty");
|
||||
return cmd;
|
||||
|
|
@ -82,4 +79,4 @@ public class DaHuaVehicleSyncExe {
|
|||
throw new BizException(message + (errorMessage == null ? "" : ": " + errorMessage));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue