Explorar el Código

车牌校验

master
yangpeilai hace 1 semana
padre
commit
2b86e40b74

+ 8
- 0
zhywpt-app-iaw/src/main/java/cn/com/taiji/iaw/api/comm/PlateCheckController.java Ver fichero

@@ -5,6 +5,8 @@ import cn.com.taiji.common.web.ApiResponse;
import cn.com.taiji.core.model.comm.protocol.ias.vaild.VehiclePlateCheckRequest;
import cn.com.taiji.core.model.comm.protocol.ias.vaild.VehiclePlateCheckResponse;
import cn.com.taiji.iaw.api.MyValidController;
import cn.com.taiji.iaw.dto.comm.PlateCheckResponse;
import cn.com.taiji.iaw.dto.comm.VehiclePlateCheckYgzRequestDTO;
import cn.com.taiji.iaw.manager.issue.PlateCheckManager;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@@ -35,4 +37,10 @@ public class PlateCheckController extends MyValidController {
return ApiResponse.of(query);
}

@ApiOperation(value = "营改增车牌校验")
@PostMapping(value = "/checkYGZ")
public ApiResponse<PlateCheckResponse> checkYGZ(@Valid @RequestBody VehiclePlateCheckYgzRequestDTO reqDto) throws ManagerException {
return ApiResponse.of(manager.checkYGZ(reqDto));
}

}

+ 14
- 0
zhywpt-app-iaw/src/main/java/cn/com/taiji/iaw/dto/comm/PlateCheckResponse.java Ver fichero

@@ -0,0 +1,14 @@
package cn.com.taiji.iaw.dto.comm;

import lombok.Data;

@Data
public class PlateCheckResponse {
private Boolean result;
private Integer reason;
private Integer vehicleCompare;
private String info;
private int status;

private String message;
}

+ 16
- 0
zhywpt-app-iaw/src/main/java/cn/com/taiji/iaw/dto/comm/VehiclePlateCheckYgzRequestDTO.java Ver fichero

@@ -0,0 +1,16 @@
package cn.com.taiji.iaw.dto.comm;

import cn.com.taiji.core.dto.AbstractBizRequestDTO;
import io.swagger.annotations.ApiModel;
import lombok.Getter;
import lombok.Setter;

@ApiModel(description = "用户车辆信息查看详情")
@Getter
@Setter
public class VehiclePlateCheckYgzRequestDTO extends AbstractBizRequestDTO {
private String vehiclePlate;
private String vehiclePlateColor;
private String vehicleType;
private String releaseType;
}

+ 4
- 0
zhywpt-app-iaw/src/main/java/cn/com/taiji/iaw/manager/issue/PlateCheckManager.java Ver fichero

@@ -3,6 +3,8 @@ package cn.com.taiji.iaw.manager.issue;
import cn.com.taiji.common.manager.ManagerException;
import cn.com.taiji.core.model.comm.protocol.ias.vaild.VehiclePlateCheckRequest;
import cn.com.taiji.core.model.comm.protocol.ias.vaild.VehiclePlateCheckResponse;
import cn.com.taiji.iaw.dto.comm.PlateCheckResponse;
import cn.com.taiji.iaw.dto.comm.VehiclePlateCheckYgzRequestDTO;

/**
* @Author:ChenChao
@@ -12,4 +14,6 @@ import cn.com.taiji.core.model.comm.protocol.ias.vaild.VehiclePlateCheckResponse
*/
public interface PlateCheckManager {
VehiclePlateCheckResponse query(VehiclePlateCheckRequest reqDto) throws ManagerException;

PlateCheckResponse checkYGZ(VehiclePlateCheckYgzRequestDTO reqDto) throws ManagerException;
}

+ 117
- 3
zhywpt-app-iaw/src/main/java/cn/com/taiji/iaw/manager/issue/PlateCheckManagerImpl.java Ver fichero

@@ -2,11 +2,33 @@ package cn.com.taiji.iaw.manager.issue;

import cn.com.taiji.common.manager.ManagerException;
import cn.com.taiji.common.manager.net.http.ServiceHandleException;
import cn.com.taiji.common.pub.StringTools;
import cn.com.taiji.core.entity.basic.QtkCardInfo;
import cn.com.taiji.core.entity.basic.QtkObuInfo;
import cn.com.taiji.core.entity.basic.QtkVehicleInfo;
import cn.com.taiji.core.entity.dict.basic.CardStatus;
import cn.com.taiji.core.entity.dict.basic.ObuStatus;
import cn.com.taiji.core.entity.dict.basic.VehicleType;
import cn.com.taiji.core.entity.dict.ygz.DataSourceEnum;
import cn.com.taiji.core.model.comm.protocol.ias.vaild.VehiclePlateCheckRequest;
import cn.com.taiji.core.model.comm.protocol.ias.vaild.VehiclePlateCheckResponse;
import cn.com.taiji.core.model.comm.protocol.ias.ygz.YgzVehiclePlateCheckRequest;
import cn.com.taiji.core.model.comm.protocol.ias.ygz.YgzVehiclePlateCheckResponse;
import cn.com.taiji.core.model.comm.protocol.valid.GlyServiceError;
import cn.com.taiji.core.repo.jpa.basic.QtkCardInfoRepo;
import cn.com.taiji.core.repo.jpa.basic.QtkObuInfoRepo;
import cn.com.taiji.core.repo.jpa.basic.QtkVehicleInfoRepo;
import cn.com.taiji.iaw.dto.comm.PlateCheckResponse;
import cn.com.taiji.iaw.dto.comm.VehiclePlateCheckYgzRequestDTO;
import cn.com.taiji.iaw.manager.AbstractIawManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
* @Author:ChenChao
* @Date:2025/7/9 20:51
@@ -14,20 +36,112 @@ import org.springframework.stereotype.Service;
* @description:
*/
@Service
public class PlateCheckManagerImpl extends AbstractIawManager implements PlateCheckManager{
public class PlateCheckManagerImpl extends AbstractIawManager implements PlateCheckManager {

@Autowired
private QtkVehicleInfoRepo vehicleInfoRepo;

@Autowired
private QtkCardInfoRepo cardInfoRepo;

@Autowired
private QtkObuInfoRepo obuInfoRepo;

@Override
public VehiclePlateCheckResponse query(VehiclePlateCheckRequest reqDto) throws ManagerException {
reqDto.setCustomerId("");
VehiclePlateCheckResponse response = null;
try {
response = jsonPostRepeat(reqDto);
}catch (ManagerException e){
} catch (ManagerException e) {
if (e.getMessage().contains("车牌发行校验失败")) {
throw new ManagerException("请核对车牌号和车牌颜色");
}else {
} else {
throw e;
}
}
return response;
}

@Override
public PlateCheckResponse checkYGZ(VehiclePlateCheckYgzRequestDTO req) throws ManagerException {
// 本地车牌校验
PlateCheckResponse res = localPlateCheck(req);
// 本地没有查询营改增
if (res == null) {
res = new PlateCheckResponse();
YgzVehiclePlateCheckRequest plateCheck = new YgzVehiclePlateCheckRequest();
plateCheck.setVehiclePlate(req.getVehiclePlate());
plateCheck.setVehicleColor(Integer.valueOf(req.getVehiclePlateColor()));
plateCheck.setVehicleType(Integer.valueOf(req.getVehicleType()));
plateCheck.setIssueType(Integer.valueOf(req.getReleaseType()));
plateCheck.setDataSource(DataSourceEnum.DSI_INTERFACE);
try {
YgzVehiclePlateCheckResponse response = jsonPostRepeat(plateCheck);
if(response != null){
res.setInfo(response.getInfo());
}else {
res.setInfo("该车牌本省可以发行对应卡/签!");
}
}catch (ManagerException e) {
throw new ManagerException(e.getMessage());
}
}

res.setMessage(res.getInfo());
return res;
}

private PlateCheckResponse localPlateCheck(VehiclePlateCheckYgzRequestDTO req) throws ManagerException {
PlateCheckResponse response = new PlateCheckResponse();

// 查询车辆信息
String vehicleId = req.getVehiclePlate() + "_" + req.getVehiclePlateColor();
QtkVehicleInfo vehicle = vehicleInfoRepo.findByVehicleId(vehicleId);

if (vehicle == null) {
return null;
}

// 验证车辆类型
if (vehicle.getType() == null) {
throw new ManagerException("收费车型为空,请修改车辆信息!");
}

if (!String.valueOf(vehicle.getType()).equals(req.getVehicleType())) {
response.setInfo("收费车型与数据记录不相符");
return response;
}

// 根据releaseType处理不同情况
switch (req.getReleaseType()) {
case "1":
return checkCard(response, vehicleId);
case "2":
return checkObu(response, vehicleId);
case "0":
checkCard(response, vehicleId);
return checkObu(response, vehicleId);
default:
return response;
}
}

private PlateCheckResponse checkCard(PlateCheckResponse response, String vehicleId) {
List<QtkCardInfo> activeCards = cardInfoRepo.listByVehicleIdInUse(vehicleId, new CardStatus[]{CardStatus.ZC, CardStatus.KGS});
if (isEmpty(activeCards)) {
return null;
}
response.setInfo("车牌有在用的卡,卡号:"+activeCards.get(0).getCardId());
return response;
}

private PlateCheckResponse checkObu(PlateCheckResponse response, String vehicleId) {
List<QtkObuInfo> activeObus = obuInfoRepo.listObuByVehicleIdInUse(vehicleId, new ObuStatus[]{ObuStatus.ZC, ObuStatus.BQGS, ObuStatus.YFX});
if (isEmpty(activeObus)) {
return null;
}
response.setInfo("车牌有在用的OBU,OBU编号:"+activeObus.get(0).getObuId());
return response;
}
}

Cargando…
Cancelar
Guardar