1、新增车辆人员同步大华
parent
81d4242c31
commit
0d36024105
|
|
@ -2,10 +2,15 @@ package com.zcloud.primeport.command;
|
|||
|
||||
import com.alibaba.cola.exception.BizException;
|
||||
import com.zcloud.primeport.domain.gateway.PersonApplyGateway;
|
||||
import com.zcloud.primeport.domain.model.PersonApplyE;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* web-app
|
||||
|
|
@ -17,23 +22,38 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
@AllArgsConstructor
|
||||
public class PersonApplyRemoveExe {
|
||||
private final PersonApplyGateway personApplyGateway;
|
||||
private final DaHuaPersonSyncExe daHuaPersonSyncExe;
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean execute(Long id) {
|
||||
PersonApplyE person = findPerson(id);
|
||||
boolean res = personApplyGateway.deletedPersonApplyById(id);
|
||||
if (!res) {
|
||||
throw new BizException("删除失败");
|
||||
}
|
||||
daHuaPersonSyncExe.syncDeletedPersons(person == null ? Collections.emptyList() : Collections.singletonList(person));
|
||||
return true;
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
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);
|
||||
if (!res) {
|
||||
throw new BizException("删除失败");
|
||||
}
|
||||
daHuaPersonSyncExe.syncDeletedPersons(persons);
|
||||
return true;
|
||||
}
|
||||
|
||||
private PersonApplyE findPerson(Long id) {
|
||||
return personApplyGateway.getPersonById(id);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -37,15 +37,18 @@ public class PersonApplyUpdateExe {
|
|||
private final XgfApplyPersonGateway xgfApplyPersonGateway;
|
||||
private final MessageNoticeExe messageNoticeExe;
|
||||
private final MessageTemplateConfig messageTemplateConfig;
|
||||
private final DaHuaPersonSyncExe daHuaPersonSyncExe;
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void execute(PersonApplyUpdateCmd personApplyUpdateCmd) {
|
||||
PersonApplyE original = personApplyGateway.getPersonById(personApplyUpdateCmd.getId());
|
||||
PersonApplyE personApplyE = new PersonApplyE();
|
||||
BeanUtils.copyProperties(personApplyUpdateCmd, personApplyE);
|
||||
boolean res = personApplyGateway.update(personApplyE);
|
||||
if (!res) {
|
||||
throw new BizException("修改失败");
|
||||
}
|
||||
daHuaPersonSyncExe.syncUpdatedPerson(original, personApplyUpdateCmd);
|
||||
}
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
|
||||
|
|
@ -56,6 +59,9 @@ public class PersonApplyUpdateExe {
|
|||
.reasonsRefusal(cmd.getReasonsRefusal()).build();
|
||||
build.setId(cmd.getId());
|
||||
personApplyGateway.xgfPersonAudit(build);
|
||||
if (cmd.getAuditFlag().equals(2)) {
|
||||
daHuaPersonSyncExe.syncApprovedPersons(build.getId());
|
||||
}
|
||||
|
||||
// 完成待办
|
||||
messageNoticeExe.sendMessageCompleteEvent(build.getId());
|
||||
|
|
|
|||
|
|
@ -3,10 +3,15 @@ package com.zcloud.primeport.command;
|
|||
import com.alibaba.cola.exception.BizException;
|
||||
import com.zcloud.primeport.domain.gateway.VehicleApplyGateway;
|
||||
import com.zcloud.primeport.domain.gateway.VehicleAuditGateway;
|
||||
import com.zcloud.primeport.domain.model.VehicleApplyE;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* web-app
|
||||
|
|
@ -19,23 +24,35 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
public class VehicleApplyRemoveExe {
|
||||
private final VehicleApplyGateway vehicleApplyGateway;
|
||||
private final VehicleAuditGateway vehicleAuditGateway;
|
||||
private final DaHuaVehicleSyncExe daHuaVehicleSyncExe;
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean execute(Long id) {
|
||||
VehicleApplyE vehicle = vehicleApplyGateway.getById(id);
|
||||
boolean res = vehicleApplyGateway.deletedVehicleApplyById(id);
|
||||
vehicleAuditGateway.deletedVehicleAuditByApplyId(id);
|
||||
if (!res) {
|
||||
throw new BizException("删除失败");
|
||||
}
|
||||
daHuaVehicleSyncExe.syncDeletedVehicles(vehicle == null
|
||||
? Collections.emptyList() : Collections.singletonList(vehicle));
|
||||
return true;
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
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);
|
||||
if (!res) {
|
||||
throw new BizException("删除失败");
|
||||
}
|
||||
daHuaVehicleSyncExe.syncDeletedVehicles(vehicles);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ public class VehicleAuditUpdateExe {
|
|||
private final CarDockUtil carDockUtil;
|
||||
private final MessageNoticeExe messageNoticeExe;
|
||||
private final MessageTemplateConfig messageTemplateConfig;
|
||||
private final DaHuaVehicleSyncExe daHuaVehicleSyncExe;
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void execute(VehicleAuditUpdateCmd vehicleAuditUpdateCmd) {
|
||||
|
|
@ -76,6 +77,7 @@ public class VehicleAuditUpdateExe {
|
|||
} else {
|
||||
carDockUtil.executeInternalVehicle(vehicleApplyE1);
|
||||
}
|
||||
daHuaVehicleSyncExe.syncApprovedVehicle(cmd.getVehicleApplyId());
|
||||
}
|
||||
|
||||
// 完成待办
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ public interface DaHuaGateway {
|
|||
|
||||
Long generatePersonId();
|
||||
|
||||
Long findPersonIdByPaperNumber(String paperNumber);
|
||||
|
||||
Map<String, Object> syncPerson(DaHuaPersonSyncCmd cmd);
|
||||
|
||||
Map<String, Object> updatePerson(DaHuaPersonSyncCmd cmd);
|
||||
|
|
|
|||
|
|
@ -37,6 +37,8 @@ public interface PersonApplyGateway {
|
|||
|
||||
List<PersonApplyE> personListByxgfApplyPersonId(Long id);
|
||||
|
||||
PersonApplyE getPersonById(Long id);
|
||||
|
||||
XgfApplyPersonE getXgfApplyPersonById(Long id);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,10 @@ public class DaHuaPersonSyncCmd {
|
|||
|
||||
private Long departmentId;
|
||||
|
||||
private Integer departmentType;
|
||||
|
||||
private Integer type;
|
||||
|
||||
private Integer personType;
|
||||
|
||||
private Integer availableTimes;
|
||||
|
|
|
|||
|
|
@ -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_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_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 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";
|
||||
|
|
@ -59,6 +60,18 @@ public class DaHuaPersonApi {
|
|||
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 {
|
||||
if (daHuaApiClient == null) {
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
public Map<String, Object> syncPerson(DaHuaPersonSyncCmd cmd) {
|
||||
if (daHuaPersonApi == null || !daHuaPersonApi.isConfigured()) {
|
||||
|
|
|
|||
|
|
@ -207,6 +207,17 @@ public class PersonApplyGatewayImpl implements PersonApplyGateway {
|
|||
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
|
||||
public XgfApplyPersonE getXgfApplyPersonById (Long id) {
|
||||
XgfApplyPersonDO byId = xgfApplyPersonRepository.getById(id);
|
||||
|
|
|
|||
Loading…
Reference in New Issue