|
|
@@ -0,0 +1,166 @@ |
|
|
|
package cn.com.taiji.iaw.manager.ass; |
|
|
|
|
|
|
|
import cn.com.taiji.common.manager.ManagerException; |
|
|
|
import cn.com.taiji.common.manager.net.http.ServiceHandleException; |
|
|
|
import cn.com.taiji.common.pub.BeanTools; |
|
|
|
import cn.com.taiji.core.entity.ass.AssDeviceResume; |
|
|
|
import cn.com.taiji.core.entity.ass.AssOrderinfo; |
|
|
|
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.ass.AssOrderStatus; |
|
|
|
import cn.com.taiji.core.entity.dict.ass.AssOrderStep; |
|
|
|
import cn.com.taiji.core.entity.dict.ass.AssOrderType; |
|
|
|
import cn.com.taiji.core.entity.dict.basic.CardStatus; |
|
|
|
import cn.com.taiji.core.entity.dict.basic.CardType; |
|
|
|
import cn.com.taiji.core.entity.dict.basic.ObuStatus; |
|
|
|
import cn.com.taiji.core.entity.dict.basic.VehicleType; |
|
|
|
import cn.com.taiji.core.manager.tools.issue.IssueTools; |
|
|
|
import cn.com.taiji.core.model.comm.protocol.ias.ass.ResignRequest; |
|
|
|
import cn.com.taiji.core.model.comm.protocol.ias.order.SignQueryResponse; |
|
|
|
import cn.com.taiji.core.repo.jpa.ass.AssDeviceResumeRepo; |
|
|
|
import cn.com.taiji.core.repo.jpa.ass.AssOrderinfoRepo; |
|
|
|
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.DeviceResumeAddRequestDTO; |
|
|
|
import cn.com.taiji.iaw.dto.ass.DeviceResumeResponseDTO; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import cn.com.taiji.iaw.manager.AbstractCommManager; |
|
|
|
|
|
|
|
import java.time.LocalDateTime; |
|
|
|
|
|
|
|
/** |
|
|
|
* 卡签恢复使用相关功能 |
|
|
|
*/ |
|
|
|
@Service |
|
|
|
public class DeviceResumeManagerImpl extends AbstractCommManager implements DeviceResumeManager { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private AssDeviceResumeRepo deviceResumeRepo; |
|
|
|
@Autowired |
|
|
|
private AssOrderinfoRepo orderinfoRepo; |
|
|
|
@Autowired |
|
|
|
private QtkCardInfoRepo cardInfoRepo; |
|
|
|
@Autowired |
|
|
|
private QtkObuInfoRepo obuInfoRepo; |
|
|
|
@Autowired |
|
|
|
private QtkCustomerInfoRepo customerInfoRepo; |
|
|
|
@Autowired |
|
|
|
private QtkVehicleInfoRepo vehicleInfoRepo; |
|
|
|
|
|
|
|
@Override |
|
|
|
public DeviceResumeResponseDTO add(DeviceResumeAddRequestDTO reqDto) throws ManagerException { |
|
|
|
// 审核是否能新增 |
|
|
|
checkDeviceResume(reqDto); |
|
|
|
// 保存售后订单 |
|
|
|
AssOrderinfo orderinfo = saveOrderInfo(reqDto); |
|
|
|
// 保存审核记录 |
|
|
|
AssDeviceResume deviceResume = saveDeviceResume(reqDto,orderinfo); |
|
|
|
DeviceResumeResponseDTO responseDTO = new DeviceResumeResponseDTO(); |
|
|
|
responseDTO.setId(deviceResume.getId()); |
|
|
|
return responseDTO; |
|
|
|
} |
|
|
|
|
|
|
|
public void checkDeviceResume(DeviceResumeAddRequestDTO reqDto) throws ManagerException { |
|
|
|
// 1、判断卡签状态为有卡挂起和无卡挂起状态可以申请解除挂起。 |
|
|
|
QtkCardInfo cardInfo = cardInfoRepo.findByCardId(reqDto.getCardId()); |
|
|
|
if (cardInfo == null) { |
|
|
|
throw new ManagerException("未查到卡信息,不允许解挂!"); |
|
|
|
} |
|
|
|
QtkObuInfo obuInfo = obuInfoRepo.findByObuId(reqDto.getObuId()); |
|
|
|
if (obuInfo == null) { |
|
|
|
throw new ManagerException("未查到签信息,不允许解挂!"); |
|
|
|
} |
|
|
|
if (cardInfo.getCardStatus() != CardStatus.YKGQ && cardInfo.getCardStatus() != CardStatus.WKGQ) { |
|
|
|
throw new ManagerException("卡号状态不是有卡挂起或无卡挂起状态,不允许解挂!"); |
|
|
|
} |
|
|
|
// 2、判断卡签信息中的用户编号和车辆编号是否存在用户数据和车辆数据,不存在不允许解挂。 |
|
|
|
QtkCustomerInfo customerInfo = customerInfoRepo.findByCustomerId(cardInfo.getCustomerId()); |
|
|
|
if (customerInfo == null) { |
|
|
|
throw new ManagerException("未查到用户信息,不允许解挂!"); |
|
|
|
} |
|
|
|
QtkVehicleInfo vehicleInfo = vehicleInfoRepo.findByVehicleId(cardInfo.getVehicleId()); |
|
|
|
if (vehicleInfo == null) { |
|
|
|
throw new ManagerException("未查到车辆信息,不允许解挂!"); |
|
|
|
} |
|
|
|
// 3、判断卡签信息中的车辆编号,判断车辆数据中的用户编号和卡签信息中的车辆编号是否一致,不一致,不允许解挂。 |
|
|
|
if (!cardInfo.getVehicleId().equals(vehicleInfo.getVehicleId()) |
|
|
|
||!obuInfo.getVehicleId().equals(vehicleInfo.getVehicleId())) { |
|
|
|
throw new ManagerException("车辆编号不一致,不允许解挂!"); |
|
|
|
} |
|
|
|
if (!vehicleInfo.getCustomerId().equals(customerInfo.getCustomerId()) |
|
|
|
|| !cardInfo.getCustomerId().equals(customerInfo.getCustomerId()) |
|
|
|
|| !obuInfo.getCustomerId().equals(customerInfo.getCustomerId())) { |
|
|
|
throw new ManagerException("车辆用户信息与卡签用户信息不一致,不允许解挂!"); |
|
|
|
} |
|
|
|
// 4、判断上传的车辆资料,通过上传资料计算车型,当车型发生变更时,不允许进行解挂。 |
|
|
|
Integer vehicleClass = IssueTools.getVehicleClass(reqDto.getVanType(), reqDto.getVehicleDimensions(), |
|
|
|
reqDto.getApprovedCount(), reqDto.getAxleCount(), reqDto.getTotalMass()); |
|
|
|
VehicleType vehicleType = VehicleType.fromCode(vehicleClass); |
|
|
|
if (vehicleInfo.getType() != vehicleType.getCode()){ |
|
|
|
throw new ManagerException("车辆类型发生变更,不允许进行解挂!"); |
|
|
|
} |
|
|
|
// 5、进行车牌校验,判断车牌占用情况,有则不允许解挂。 |
|
|
|
QtkObuInfo zcObuInfo = obuInfoRepo.findByVehicleIdAndObuStatus(vehicleInfo.getVehicleId(), ObuStatus.ZC); |
|
|
|
QtkCardInfo zcCardInfo = cardInfoRepo.findByVehicleIdAndCardStatus(vehicleInfo.getVehicleId()); |
|
|
|
if (zcObuInfo != null || zcCardInfo != null){ |
|
|
|
throw new ManagerException("车牌已占用,不允许进行解挂!"); |
|
|
|
} |
|
|
|
// 6、判断用户原签约关系是否正常,不正常不允许解挂。" |
|
|
|
ResignRequest resignRequest = new ResignRequest(); |
|
|
|
resignRequest.setWxOpenId(reqDto.getWxOpenId()); |
|
|
|
resignRequest.setProductId(cardInfo.getPackageId()); |
|
|
|
resignRequest.setVehicleId(cardInfo.getVehicleId()); |
|
|
|
resignRequest.setName(reqDto.getCustomerName()); |
|
|
|
resignRequest.setIdNum(reqDto.getCustomerIdNum()); |
|
|
|
resignRequest.setFlag(1); |
|
|
|
SignQueryResponse response = jsonPostRepeat(resignRequest); |
|
|
|
if (response.getUserState().equals("OPENED") |
|
|
|
|| !response.getUserState().equals("UNAUTHORIZED")){ |
|
|
|
return; |
|
|
|
}else{ |
|
|
|
throw new ManagerException("用户原签约关系异常,不允许进行解挂!"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public AssOrderinfo saveOrderInfo(DeviceResumeAddRequestDTO reqDto) throws ServiceHandleException { |
|
|
|
QtkCardInfo cardInfo = cardInfoRepo.findByCardId(reqDto.getCardId()); |
|
|
|
QtkCustomerInfo customerInfo = customerInfoRepo.findByCustomerId(cardInfo.getCustomerId()); |
|
|
|
AssOrderinfo orderinfo = new AssOrderinfo(); |
|
|
|
BeanTools.copyProperties(reqDto, orderinfo); |
|
|
|
orderinfo.setOrderType(AssOrderType.DEVICE_RESUME); |
|
|
|
orderinfo.setOrderSource(reqDto.getOrderSource()); |
|
|
|
orderinfo.setAgencyId(cardInfo.getAgencyId()); |
|
|
|
orderinfo.setChannelId(cardInfo.getChannelId()); |
|
|
|
orderinfo.setOrderStatus(AssOrderStatus.NORMAL); |
|
|
|
orderinfo.setOrderStep(AssOrderStep.WAITING_AUDIT); |
|
|
|
orderinfo.setApplyTime(LocalDateTime.now()); |
|
|
|
orderinfo.setOpenId(findOpenIdByToken(reqDto.getAccessToken())); |
|
|
|
orderinfo.setCustomerId(cardInfo.getCustomerId()); |
|
|
|
orderinfo.setCustomerName(reqDto.getCustomerName()); |
|
|
|
orderinfo.setCustomerTel(reqDto.getCustomerTel()); |
|
|
|
orderinfo.setUserType(customerInfo.getUserType()); |
|
|
|
orderinfo.setArtificialStatus(0); |
|
|
|
orderinfo.setVehicleId(cardInfo.getVehicleId()); |
|
|
|
orderinfo.setVehiclePlate(reqDto.getVehiclePlate()); |
|
|
|
orderinfo.setVehiclePlateColor(reqDto.getVehiclePlateColor()); |
|
|
|
orderinfo.setCardId(cardInfo.getCardId()); |
|
|
|
orderinfo.setCardType(CardType.fromCode(cardInfo.getCardType())); |
|
|
|
orderinfo.setObuId(reqDto.getObuId()); |
|
|
|
return orderinfoRepo.save(orderinfo); |
|
|
|
} |
|
|
|
|
|
|
|
public AssDeviceResume saveDeviceResume(DeviceResumeAddRequestDTO reqDto, AssOrderinfo orderinfo){ |
|
|
|
AssDeviceResume deviceResume = new AssDeviceResume(); |
|
|
|
BeanTools.copyProperties(reqDto, deviceResume); |
|
|
|
deviceResume.setOrderNo(orderinfo.getOrderNo()); |
|
|
|
deviceResume.setInsertTime(LocalDateTime.now()); |
|
|
|
return deviceResumeRepo.save(deviceResume); |
|
|
|
} |
|
|
|
|
|
|
|
} |