|
|
@@ -1,46 +1,18 @@ |
|
|
|
package cn.com.taiji.iaw.manager.ass; |
|
|
|
|
|
|
|
import cn.com.taiji.common.manager.ManagerException; |
|
|
|
import cn.com.taiji.core.entity.basic.QtkCardInfo; |
|
|
|
import cn.com.taiji.core.entity.basic.QtkCustomerInfo; |
|
|
|
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.SourceType; |
|
|
|
import cn.com.taiji.core.entity.dict.basic.VehicleType; |
|
|
|
import cn.com.taiji.core.entity.dict.log.OperateType; |
|
|
|
import cn.com.taiji.core.manager.cache.RedisKeyGenerator; |
|
|
|
import cn.com.taiji.core.model.comm.protocol.ias.ass.*; |
|
|
|
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.QtkCustomerInfoRepo; |
|
|
|
import cn.com.taiji.core.repo.jpa.basic.QtkObuInfoRepo; |
|
|
|
import cn.com.taiji.core.repo.jpa.basic.QtkVehicleInfoRepo; |
|
|
|
import cn.com.taiji.iaw.dto.ass.AssBaseInfoQueryRequestDTO; |
|
|
|
import cn.com.taiji.iaw.dto.ass.AssBaseInfoQueryResponseDTO; |
|
|
|
import cn.com.taiji.iaw.dto.ass.DeviceLossReqDTO; |
|
|
|
import cn.com.taiji.iaw.manager.AbstractIawManager; |
|
|
|
import cn.com.taiji.iaw.model.ass.CardObuInfoModel; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
@Service |
|
|
|
public class DeviceLossManagerImpl extends AbstractIawManager implements DeviceLossManager { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private QtkCustomerInfoRepo customerInfoRepo; |
|
|
|
@Autowired |
|
|
|
private QtkVehicleInfoRepo vehicleInfoRepo; |
|
|
|
@Autowired |
|
|
|
private QtkCardInfoRepo cardInfoRepo; |
|
|
|
@Autowired |
|
|
|
private QtkObuInfoRepo obuInfoRepo; |
|
|
|
|
|
|
|
@Override |
|
|
|
public void loss(DeviceLossReqDTO reqDto) throws ManagerException { |
|
|
|
reqDto.validate(); |
|
|
@@ -106,80 +78,4 @@ public class DeviceLossManagerImpl extends AbstractIawManager implements DeviceL |
|
|
|
// 保存日志操作日志 失败不计入日志 |
|
|
|
persistOperateLog(operateType, response.getOrderNo(), source, findOpenIdByToken(reqDto.getAccessToken()), "挂失解挂操作" + response.getMsg()); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public AssBaseInfoQueryResponseDTO query(AssBaseInfoQueryRequestDTO dto) throws ManagerException { |
|
|
|
// 查询车辆信息 |
|
|
|
QtkVehicleInfo vehicle = vehicleInfoRepo.findByVehicleId(dto.getVehicleId()); |
|
|
|
if (vehicle == null) { |
|
|
|
throw new ManagerException("未获取到车辆信息!"); |
|
|
|
} |
|
|
|
|
|
|
|
// 查询用户信息 |
|
|
|
QtkCustomerInfo customer = customerInfoRepo.findByCustomerId(vehicle.getCustomerId()); |
|
|
|
if (customer == null) { |
|
|
|
throw new ManagerException("未获取到用户信息!"); |
|
|
|
} |
|
|
|
|
|
|
|
// 状态过滤卡和OBU |
|
|
|
CardStatus[] cardStatus; |
|
|
|
ObuStatus[] obuStatus; |
|
|
|
|
|
|
|
if ("1".equals(dto.getStatus())) { |
|
|
|
// 状态1:只查询正常的卡和OBU |
|
|
|
cardStatus = new CardStatus[]{CardStatus.ZC}; |
|
|
|
obuStatus = new ObuStatus[]{ObuStatus.ZC}; |
|
|
|
} else if ("2".equals(dto.getStatus())) { |
|
|
|
// 状态2:只查询已挂失的卡和OBU |
|
|
|
cardStatus = new CardStatus[]{CardStatus.KGS}; |
|
|
|
obuStatus = new ObuStatus[]{ObuStatus.BQGS}; |
|
|
|
} else { |
|
|
|
// 查询所有卡和OBU(正常+挂失) |
|
|
|
cardStatus = new CardStatus[]{CardStatus.ZC, CardStatus.KGS}; |
|
|
|
obuStatus = new ObuStatus[]{ObuStatus.ZC, ObuStatus.BQGS}; |
|
|
|
} |
|
|
|
|
|
|
|
// 查询卡和OBU信息 |
|
|
|
List<QtkCardInfo> cardInfos = cardInfoRepo.listByVehicleIdInUse(dto.getVehicleId(), cardStatus); |
|
|
|
if (cardInfos.isEmpty()) { |
|
|
|
throw new ManagerException("未获取到卡信息!"); |
|
|
|
} |
|
|
|
List<QtkObuInfo> obuInfos = obuInfoRepo.listObuByVehicleIdInUse(dto.getVehicleId(), obuStatus); |
|
|
|
if (obuInfos.isEmpty()) { |
|
|
|
throw new ManagerException("未获取到OBU信息!"); |
|
|
|
} |
|
|
|
|
|
|
|
// 卡OBU信息 |
|
|
|
List<CardObuInfoModel> cardObuInfos = new ArrayList<>(); |
|
|
|
for (QtkCardInfo card : cardInfos) { |
|
|
|
for (QtkObuInfo obu : obuInfos) { |
|
|
|
if (card.getVehicleId().equals(obu.getVehicleId())) { |
|
|
|
CardObuInfoModel model = new CardObuInfoModel(); |
|
|
|
model.setCardId(card.getCardId()); |
|
|
|
model.setCardType(card.getCardTypeNew()); |
|
|
|
model.setCardStatus(card.getCardStatus()); |
|
|
|
model.setObuId(obu.getObuId()); |
|
|
|
model.setObuType(obu.getObuType()); |
|
|
|
model.setObuStatus(obu.getObuStatus()); |
|
|
|
cardObuInfos.add(model); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 响应 |
|
|
|
AssBaseInfoQueryResponseDTO response = new AssBaseInfoQueryResponseDTO(); |
|
|
|
response.setCustomerName(customer.getCustomerName()); |
|
|
|
response.setCustomerTel(customer.getCustomerTel()); |
|
|
|
response.setCustomerIdType(customer.getCustomerIdType().getValue()); |
|
|
|
response.setCustomerIdNum(customer.getCustomerIdNum()); |
|
|
|
response.setVehiclePlate(vehicle.getVehiclePlate()); |
|
|
|
response.setVehiclePlateColor(vehicle.getVehiclePlateColor() + ""); |
|
|
|
if (vehicle.getType() != null) { |
|
|
|
VehicleType vehicleType = VehicleType.fromCode(vehicle.getType()); |
|
|
|
response.setVehicleType(vehicleType != null ? vehicleType.getValue() : null); |
|
|
|
} |
|
|
|
response.setCardObuInfos(cardObuInfos); |
|
|
|
|
|
|
|
return response; |
|
|
|
} |
|
|
|
} |