1、新增车辆人员同步大华

koumen
shenzhidan 2026-07-28 17:08:43 +08:00
parent 81d4242c31
commit 0d36024105
10 changed files with 104 additions and 4 deletions

View File

@ -2,10 +2,15 @@ package com.zcloud.primeport.command;
import com.alibaba.cola.exception.BizException; import com.alibaba.cola.exception.BizException;
import com.zcloud.primeport.domain.gateway.PersonApplyGateway; import com.zcloud.primeport.domain.gateway.PersonApplyGateway;
import com.zcloud.primeport.domain.model.PersonApplyE;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/** /**
* web-app * web-app
@ -17,23 +22,38 @@ import org.springframework.transaction.annotation.Transactional;
@AllArgsConstructor @AllArgsConstructor
public class PersonApplyRemoveExe { public class PersonApplyRemoveExe {
private final PersonApplyGateway personApplyGateway; private final PersonApplyGateway personApplyGateway;
private final DaHuaPersonSyncExe daHuaPersonSyncExe;
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public boolean execute(Long id) { public boolean execute(Long id) {
PersonApplyE person = findPerson(id);
boolean res = personApplyGateway.deletedPersonApplyById(id); boolean res = personApplyGateway.deletedPersonApplyById(id);
if (!res) { if (!res) {
throw new BizException("删除失败"); throw new BizException("删除失败");
} }
daHuaPersonSyncExe.syncDeletedPersons(person == null ? Collections.emptyList() : Collections.singletonList(person));
return true; return true;
} }
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public boolean execute(Long[] ids) { public boolean execute(Long[] ids) {
List<PersonApplyE> persons = new ArrayList<>();
for (Long id : ids) {
PersonApplyE person = findPerson(id);
if (person != null) {
persons.add(person);
}
}
boolean res = personApplyGateway.deletedPersonApplyByIds(ids); boolean res = personApplyGateway.deletedPersonApplyByIds(ids);
if (!res) { if (!res) {
throw new BizException("删除失败"); throw new BizException("删除失败");
} }
daHuaPersonSyncExe.syncDeletedPersons(persons);
return true; return true;
} }
private PersonApplyE findPerson(Long id) {
return personApplyGateway.getPersonById(id);
}
} }

View File

@ -37,15 +37,18 @@ public class PersonApplyUpdateExe {
private final XgfApplyPersonGateway xgfApplyPersonGateway; private final XgfApplyPersonGateway xgfApplyPersonGateway;
private final MessageNoticeExe messageNoticeExe; private final MessageNoticeExe messageNoticeExe;
private final MessageTemplateConfig messageTemplateConfig; private final MessageTemplateConfig messageTemplateConfig;
private final DaHuaPersonSyncExe daHuaPersonSyncExe;
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void execute(PersonApplyUpdateCmd personApplyUpdateCmd) { public void execute(PersonApplyUpdateCmd personApplyUpdateCmd) {
PersonApplyE original = personApplyGateway.getPersonById(personApplyUpdateCmd.getId());
PersonApplyE personApplyE = new PersonApplyE(); PersonApplyE personApplyE = new PersonApplyE();
BeanUtils.copyProperties(personApplyUpdateCmd, personApplyE); BeanUtils.copyProperties(personApplyUpdateCmd, personApplyE);
boolean res = personApplyGateway.update(personApplyE); boolean res = personApplyGateway.update(personApplyE);
if (!res) { if (!res) {
throw new BizException("修改失败"); throw new BizException("修改失败");
} }
daHuaPersonSyncExe.syncUpdatedPerson(original, personApplyUpdateCmd);
} }
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@ -56,6 +59,9 @@ public class PersonApplyUpdateExe {
.reasonsRefusal(cmd.getReasonsRefusal()).build(); .reasonsRefusal(cmd.getReasonsRefusal()).build();
build.setId(cmd.getId()); build.setId(cmd.getId());
personApplyGateway.xgfPersonAudit(build); personApplyGateway.xgfPersonAudit(build);
if (cmd.getAuditFlag().equals(2)) {
daHuaPersonSyncExe.syncApprovedPersons(build.getId());
}
// 完成待办 // 完成待办
messageNoticeExe.sendMessageCompleteEvent(build.getId()); messageNoticeExe.sendMessageCompleteEvent(build.getId());

View File

@ -3,10 +3,15 @@ package com.zcloud.primeport.command;
import com.alibaba.cola.exception.BizException; import com.alibaba.cola.exception.BizException;
import com.zcloud.primeport.domain.gateway.VehicleApplyGateway; import com.zcloud.primeport.domain.gateway.VehicleApplyGateway;
import com.zcloud.primeport.domain.gateway.VehicleAuditGateway; import com.zcloud.primeport.domain.gateway.VehicleAuditGateway;
import com.zcloud.primeport.domain.model.VehicleApplyE;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/** /**
* web-app * web-app
@ -19,23 +24,35 @@ import org.springframework.transaction.annotation.Transactional;
public class VehicleApplyRemoveExe { public class VehicleApplyRemoveExe {
private final VehicleApplyGateway vehicleApplyGateway; private final VehicleApplyGateway vehicleApplyGateway;
private final VehicleAuditGateway vehicleAuditGateway; private final VehicleAuditGateway vehicleAuditGateway;
private final DaHuaVehicleSyncExe daHuaVehicleSyncExe;
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public boolean execute(Long id) { public boolean execute(Long id) {
VehicleApplyE vehicle = vehicleApplyGateway.getById(id);
boolean res = vehicleApplyGateway.deletedVehicleApplyById(id); boolean res = vehicleApplyGateway.deletedVehicleApplyById(id);
vehicleAuditGateway.deletedVehicleAuditByApplyId(id); vehicleAuditGateway.deletedVehicleAuditByApplyId(id);
if (!res) { if (!res) {
throw new BizException("删除失败"); throw new BizException("删除失败");
} }
daHuaVehicleSyncExe.syncDeletedVehicles(vehicle == null
? Collections.emptyList() : Collections.singletonList(vehicle));
return true; return true;
} }
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public boolean execute(Long[] ids) { public boolean execute(Long[] ids) {
List<VehicleApplyE> vehicles = new ArrayList<>();
for (Long id : ids) {
VehicleApplyE vehicle = vehicleApplyGateway.getById(id);
if (vehicle != null) {
vehicles.add(vehicle);
}
}
boolean res = vehicleApplyGateway.deletedVehicleApplyByIds(ids); boolean res = vehicleApplyGateway.deletedVehicleApplyByIds(ids);
if (!res) { if (!res) {
throw new BizException("删除失败"); throw new BizException("删除失败");
} }
daHuaVehicleSyncExe.syncDeletedVehicles(vehicles);
return true; return true;
} }
} }

View File

@ -36,6 +36,7 @@ public class VehicleAuditUpdateExe {
private final CarDockUtil carDockUtil; private final CarDockUtil carDockUtil;
private final MessageNoticeExe messageNoticeExe; private final MessageNoticeExe messageNoticeExe;
private final MessageTemplateConfig messageTemplateConfig; private final MessageTemplateConfig messageTemplateConfig;
private final DaHuaVehicleSyncExe daHuaVehicleSyncExe;
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void execute(VehicleAuditUpdateCmd vehicleAuditUpdateCmd) { public void execute(VehicleAuditUpdateCmd vehicleAuditUpdateCmd) {
@ -76,6 +77,7 @@ public class VehicleAuditUpdateExe {
} else { } else {
carDockUtil.executeInternalVehicle(vehicleApplyE1); carDockUtil.executeInternalVehicle(vehicleApplyE1);
} }
daHuaVehicleSyncExe.syncApprovedVehicle(cmd.getVehicleApplyId());
} }
// 完成待办 // 完成待办

View File

@ -12,6 +12,8 @@ public interface DaHuaGateway {
Long generatePersonId(); Long generatePersonId();
Long findPersonIdByPaperNumber(String paperNumber);
Map<String, Object> syncPerson(DaHuaPersonSyncCmd cmd); Map<String, Object> syncPerson(DaHuaPersonSyncCmd cmd);
Map<String, Object> updatePerson(DaHuaPersonSyncCmd cmd); Map<String, Object> updatePerson(DaHuaPersonSyncCmd cmd);
@ -27,4 +29,4 @@ public interface DaHuaGateway {
Map<String, Object> deleteCar(List<String> carNumList); Map<String, Object> deleteCar(List<String> carNumList);
Map<String, Object> queryAccessRecord(DaHuaAccessRecordCmd cmd); Map<String, Object> queryAccessRecord(DaHuaAccessRecordCmd cmd);
} }

View File

@ -37,6 +37,8 @@ public interface PersonApplyGateway {
List<PersonApplyE> personListByxgfApplyPersonId(Long id); List<PersonApplyE> personListByxgfApplyPersonId(Long id);
PersonApplyE getPersonById(Long id);
XgfApplyPersonE getXgfApplyPersonById(Long id); XgfApplyPersonE getXgfApplyPersonById(Long id);
} }

View File

@ -23,6 +23,10 @@ public class DaHuaPersonSyncCmd {
private Long departmentId; private Long departmentId;
private Integer departmentType;
private Integer type;
private Integer personType; private Integer personType;
private Integer availableTimes; private Integer availableTimes;
@ -74,4 +78,4 @@ public class DaHuaPersonSyncCmd {
private String path; private String path;
private String base64Data; private String base64Data;
} }
} }

View File

@ -18,6 +18,7 @@ public class DaHuaPersonApi {
private static final String PERSON_ADD_URL = "/evo-apigw/evo-brm/1.2.0/person/subsystem/add"; private static final String PERSON_ADD_URL = "/evo-apigw/evo-brm/1.2.0/person/subsystem/add";
private static final String PERSON_UPDATE_URL = "/evo-apigw/evo-brm/1.2.0/person/subsystem/update"; private static final String PERSON_UPDATE_URL = "/evo-apigw/evo-brm/1.2.0/person/subsystem/update";
private static final String PERSON_GENERATE_ID_URL = "/evo-apigw/evo-brm/1.0.0/person/generate-id"; private static final String PERSON_GENERATE_ID_URL = "/evo-apigw/evo-brm/1.0.0/person/generate-id";
private static final String PERSON_GET_BY_PAPER_NUMBER_URL = "/evo-apigw/evo-brm/1.2.0/person/subsystem/get-by-paper-number";
private static final String PERSON_DELETE_URL = "/evo-apigw/evo-brm/1.0.0/person/delete"; private static final String PERSON_DELETE_URL = "/evo-apigw/evo-brm/1.0.0/person/delete";
private static final String CAR_ADD_URL = "/evo-apigw/evo-brm/1.0.0/car/add"; private static final String CAR_ADD_URL = "/evo-apigw/evo-brm/1.0.0/car/add";
private static final String CAR_UPDATE_URL = "/evo-apigw/evo-brm/1.0.0/car/update"; private static final String CAR_UPDATE_URL = "/evo-apigw/evo-brm/1.0.0/car/update";
@ -59,6 +60,18 @@ public class DaHuaPersonApi {
return daHuaApiClient.getForm(PERSON_GENERATE_ID_URL, null, headers); return daHuaApiClient.getForm(PERSON_GENERATE_ID_URL, null, headers);
} }
public GeneralResponse getPersonByPaperNumber(String paperNumber) throws ClientException {
if (daHuaApiClient == null) {
return null;
}
String token = daHuaApiClient.getToken();
Map<String, String> headers = new HashMap<>();
headers.put("Authorization", "bearer " + token);
Map<String, Object> params = new HashMap<>();
params.put("paperNumber", paperNumber);
return daHuaApiClient.getForm(PERSON_GET_BY_PAPER_NUMBER_URL, params, headers);
}
public GeneralResponse deletePerson(Map<String, Object> body) throws ClientException { public GeneralResponse deletePerson(Map<String, Object> body) throws ClientException {
if (daHuaApiClient == null) { if (daHuaApiClient == null) {
return null; return null;
@ -118,4 +131,4 @@ public class DaHuaPersonApi {
headers.put("Authorization", "bearer " + token); headers.put("Authorization", "bearer " + token);
return daHuaApiClient.postJson(ACCESS_RECORD_URL, body, headers); return daHuaApiClient.postJson(ACCESS_RECORD_URL, body, headers);
} }
} }

View File

@ -71,6 +71,29 @@ public class DaHuaGatewayImpl implements DaHuaGateway {
} }
} }
@Override
public Long findPersonIdByPaperNumber(String paperNumber) {
if (daHuaPersonApi == null || !daHuaPersonApi.isConfigured()) {
throw new RuntimeException("大华服务未配置");
}
try {
GeneralResponse response = daHuaPersonApi.getPersonByPaperNumber(paperNumber);
if (response == null || !"0".equals(response.getCode())) {
return null;
}
JSONObject responseJson = JSONUtil.parseObj(JSONUtil.toJsonStr(response));
String result = responseJson.getStr("result");
if (result == null || result.isEmpty()) {
return null;
}
JSONObject resultJson = JSONUtil.parseObj(result);
JSONObject data = resultJson.getJSONObject("data");
return data == null || data.isEmpty() ? null : data.getLong("id");
} catch (ClientException e) {
throw new RuntimeException("查询大华人员失败", e);
}
}
@Override @Override
public Map<String, Object> syncPerson(DaHuaPersonSyncCmd cmd) { public Map<String, Object> syncPerson(DaHuaPersonSyncCmd cmd) {
if (daHuaPersonApi == null || !daHuaPersonApi.isConfigured()) { if (daHuaPersonApi == null || !daHuaPersonApi.isConfigured()) {
@ -564,4 +587,4 @@ public class DaHuaGatewayImpl implements DaHuaGateway {
return resultMap; return resultMap;
} }
} }
} }

View File

@ -207,6 +207,17 @@ public class PersonApplyGatewayImpl implements PersonApplyGateway {
return xgfApplyPersonES; return xgfApplyPersonES;
} }
@Override
public PersonApplyE getPersonById(Long id) {
PersonApplyDO personApplyDO = personApplyRepository.getById(id);
if (personApplyDO == null) {
return null;
}
PersonApplyE personApplyE = new PersonApplyE();
BeanUtils.copyProperties(personApplyDO, personApplyE);
return personApplyE;
}
@Override @Override
public XgfApplyPersonE getXgfApplyPersonById (Long id) { public XgfApplyPersonE getXgfApplyPersonById (Long id) {
XgfApplyPersonDO byId = xgfApplyPersonRepository.getById(id); XgfApplyPersonDO byId = xgfApplyPersonRepository.getById(id);