Browse Source

用户车辆信息接口调整

master
huminghao 1 month ago
parent
commit
eb24df0fb6

+ 0
- 8
zhywpt-app-iaw/src/main/java/cn/com/taiji/iaw/api/comm/VehicleInfoController.java View File

@@ -15,7 +15,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;


/**
@@ -46,11 +45,4 @@ public class VehicleInfoController extends MyValidController {
}


@ApiOperation("etc卡信息查询")
@PostMapping("/queryCardInfo")
public ApiResponse<List<CardInfoQueryResponseDTO>> queryCardInfo(@Valid @RequestBody CardInfoQueryRequestDTO dto) throws ManagerException {
return ApiResponse.of(manager.queryCardInfo(dto));
}


}

+ 0
- 34
zhywpt-app-iaw/src/main/java/cn/com/taiji/iaw/dto/comm/CardInfoQueryRequestDTO.java View File

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

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

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

/**
* @Auther: humh
* @Description:
* @Date: 2025/4/23 15:14
* @email: huminghao@mail.taiji.com.cn
* @version: 1.0
*/
@ApiModel(description = "卡信息查询请求")
@Getter
@Setter
@Accessors(chain = true)
public class CardInfoQueryRequestDTO extends AbstractBizRequestDTO {


@ApiModelProperty(value = "车牌号")
@NotBlank
private String vehiclePlate;
@ApiModelProperty(value = "车牌颜色")
@NotNull
private Integer vehiclePlateColor;

}

+ 0
- 27
zhywpt-app-iaw/src/main/java/cn/com/taiji/iaw/dto/comm/CardInfoQueryResponseDTO.java View File

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

import cn.com.taiji.common.model.BaseModel;
import io.swagger.annotations.ApiModel;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

/**
* @Auther: humh
* @Description:
* @Date: 2025/4/15 11:11
* @email: huminghao@mail.taiji.com.cn
* @version: 1.0
*/
@ApiModel(description = "卡信息查询响应")
@Getter
@Setter
@Accessors(chain = true)
public class CardInfoQueryResponseDTO extends BaseModel {


/** etc卡号 */
private String cardId;
/** 卡类型1-记账卡 2-储值卡 3-预存卡 */
private Integer cardType;
}

+ 2
- 2
zhywpt-app-iaw/src/main/java/cn/com/taiji/iaw/dto/comm/VehicleInfoViewRequestDTO.java View File

@@ -20,7 +20,7 @@ import lombok.experimental.Accessors;
@Accessors(chain = true)
public class VehicleInfoViewRequestDTO extends AbstractBizRequestDTO {

@ApiModelProperty(value = "数据id")
private String id;
@ApiModelProperty(value = "车辆id,车牌号_车牌颜色")
private String vehicleId;

}

+ 0
- 3
zhywpt-app-iaw/src/main/java/cn/com/taiji/iaw/manager/comm/VehicleInfoManager.java View File

@@ -4,7 +4,6 @@ import cn.com.taiji.common.manager.ManagerException;
import cn.com.taiji.common.model.dao.Pagination;
import cn.com.taiji.iaw.dto.comm.*;

import java.util.List;

/**
* @Auther: humh
@@ -18,6 +17,4 @@ public interface VehicleInfoManager {

VehicleInfoViewResponseDTO view(VehicleInfoViewRequestDTO dto) throws ManagerException;

List<CardInfoQueryResponseDTO> queryCardInfo(CardInfoQueryRequestDTO dto) throws ManagerException;

}

+ 5
- 42
zhywpt-app-iaw/src/main/java/cn/com/taiji/iaw/manager/comm/VehicleInfoManagerImpl.java View File

@@ -1,33 +1,19 @@
package cn.com.taiji.iaw.manager.comm;

import cn.com.taiji.common.manager.ManagerException;
import cn.com.taiji.common.manager.net.http.ServiceHandleException;
import cn.com.taiji.common.model.dao.Pagination;
import cn.com.taiji.common.pub.StringTools;
import cn.com.taiji.common.pub.dao.HqlBuilder;
import cn.com.taiji.common.repo.request.jpa.JpaPageableDataRequest;
import cn.com.taiji.core.entity.basic.QtkCardInfo;
import cn.com.taiji.core.entity.basic.QtkCustomerInfo;
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.UserType;
import cn.com.taiji.core.entity.user.AccountInfo;
import cn.com.taiji.core.repo.jpa.basic.QtkCardInfoRepo;
import cn.com.taiji.core.repo.jpa.basic.QtkCustomerInfoRepo;
import cn.com.taiji.core.repo.jpa.basic.QtkVehicleInfoRepo;
import cn.com.taiji.core.repo.jpa.user.AccountInfoRepo;
import cn.com.taiji.core.repo.request.basic.QtkVehicleInfoPageRequest;
import cn.com.taiji.iaw.dto.comm.*;
import cn.com.taiji.iaw.manager.AbstractCommManager;
import cn.com.taiji.iaw.repo.jpa.request.comm.VehicleSignPageRequest;
import cn.com.taiji.iaw.tools.WxLoginUserUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

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

/**
* @Auther: humh
@@ -43,27 +29,21 @@ public class VehicleInfoManagerImpl extends AbstractCommManager implements Vehic
private QtkVehicleInfoRepo repo;
@Autowired
private WxLoginUserUtil wxLoginUserUtil;
@Autowired
private QtkCardInfoRepo cardInfoRepo;
@Autowired
private QtkCustomerInfoRepo customerInfoRepo;
@Override
public Pagination page(VehicleInfoPageRequestDTO dto) throws ManagerException {
dto.validate();
QtkVehicleInfoPageRequest pageRequest = copyProperties(dto, new QtkVehicleInfoPageRequest());
// String customerId = wxLoginUserUtil.getCustomerIdFromOpenId(findOpenIdByToken(dto.getAccessToken()));
// if (StringUtils.isEmpty(customerId)){
// throw new ManagerException("未获取到用户信息!");
// }
QtkCustomerInfo customerInfo = customerInfoRepo.findByCustomerId(dto.getCustomerId());
if (customerInfo == null) throw new ManagerException("未获取到用户信息!");
Boolean checked = wxLoginUserUtil.checkCustomerInfoAndAccountInfo(dto.getCustomerId(), findAccountInfoByToken(dto.getAccessToken()));
if (checked){
throw new ManagerException("用户信息有更新操作,请重新登录!");
}
pageRequest.setCustomerId(dto.getCustomerId());
return repo.page(pageRequest);
}

@Override
public VehicleInfoViewResponseDTO view(VehicleInfoViewRequestDTO dto) throws ManagerException {
QtkVehicleInfo vehicleInfo = repo.findById(dto.getId()).orElse(null);
QtkVehicleInfo vehicleInfo = repo.findByVehicleId(dto.getVehicleId());
if (vehicleInfo == null) {
throw new ManagerException("未获取到车辆信息!");
}
@@ -71,22 +51,5 @@ public class VehicleInfoManagerImpl extends AbstractCommManager implements Vehic
}


@Override
public List<CardInfoQueryResponseDTO> queryCardInfo(CardInfoQueryRequestDTO dto) throws ManagerException {
String customerId = wxLoginUserUtil.getCustomerIdFromOpenId(findOpenIdByToken(dto.getAccessToken()));
if (StringUtils.isEmpty(customerId)){
throw new ManagerException("未获取到用户信息!");
}
List<QtkCardInfo> cardInfos = cardInfoRepo.listByCustomerIdAndVehicleId(customerId, dto.getVehiclePlate() + "_" + dto.getVehiclePlateColor());
List<CardInfoQueryResponseDTO> list = new ArrayList<>();
for (QtkCardInfo cardInfo : cardInfos) {
CardInfoQueryResponseDTO resDTo = new CardInfoQueryResponseDTO();
resDTo.setCardId(cardInfo.getCardId());
resDTo.setCardType(cardInfo.getCardType());
list.add(resDTo);
}
return list;
}


}

+ 24
- 40
zhywpt-app-iaw/src/main/java/cn/com/taiji/iaw/tools/WxLoginUserUtil.java View File

@@ -9,61 +9,45 @@ import cn.com.taiji.core.entity.user.AccountInfo;
import cn.com.taiji.core.repo.jpa.basic.QtkCustomerInfoRepo;
import cn.com.taiji.core.repo.jpa.user.AccountInfoRepo;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;

@Component
@RequiredArgsConstructor
public class WxLoginUserUtil extends AbstractManager {

private final AccountInfoRepo accountInfoRepo;
private final QtkCustomerInfoRepo customerInfoRepo;


/**
* 通过openId获取用户列表
* @param openId 小程序端openId
* 检查QtkCustomerInfo用户是否更新
*
*/
public QtkCustomerInfo getCustomerInfoFromOpenId(String openId) throws ManagerException {
AccountInfo accountInfo = accountInfoRepo.findByOpenId(openId);
if (accountInfo == null) {
throw new ManagerException("身份认证信息错误");
public Boolean checkCustomerInfoAndAccountInfo(String customerId, AccountInfo accountInfo) throws ManagerException {
if (StringUtils.isBlank(customerId)) {
throw new ManagerException("用户id不能为空!");
}
return customerInfoRepo.findByCustomerIdTypeAndCustomerIdNum(accountInfo.getIdType(),accountInfo.getIdNum());
}

/**
* 通过openId获取用户编号
* @param openId 小程序端openId
*/
public String getCustomerIdFromOpenId(String openId) throws ManagerException {
QtkCustomerInfo customerInfo = getCustomerInfoFromOpenId(openId);
if (accountInfo == null){
throw new ManagerException("未获取到账号信息!");
}
QtkCustomerInfo customerInfo = customerInfoRepo.findByCustomerId(customerId);
if (customerInfo == null) {
return null;
throw new ManagerException("未获取到用户信息!");
}
return customerInfo.getCustomerId();
}

/**
* 通过openId获取AccountInfo
* @param openId 小程序端openId
*/
public AccountInfo getAccountInfoFromOpenId(String openId) throws ManagerException {
AccountInfo accountInfo = accountInfoRepo.findByOpenId(openId);
if (accountInfo == null){
throw new ManagerException("身份认证信息错误");
if (UserType.PERSONAL_USER.equals(customerInfo.getUserType())){
if (!accountInfo.getIdNum().equals(customerInfo.getCustomerIdNum())){
//如果不相同则认为做了更新
return true;
}
} else if (UserType.UNIT_USER.equals(customerInfo.getUserType())) {
if (!accountInfo.getIdNum().equals(customerInfo.getAgentIdNum())){
//如果不相同则认为做了更新
return true;
}
} else {
throw new ManagerException("用户类型异常!");
}
return accountInfo;
return false;
}


/**
* 通过AccountInfo获得QtkCustomerInfo信息
*/
public QtkCustomerInfo getCustomerInfoFromAccountInfo(AccountInfo accountInfo) throws ManagerException {
QtkCustomerInfo customer = customerInfoRepo.findByCustomerIdTypeAndCustomerIdNum(accountInfo.getIdType(),accountInfo.getIdNum());
if (customer == null) {
throw new ManagerException("身份认证信息错误");
}
return customer;
}
}

Loading…
Cancel
Save