@@ -14,7 +14,7 @@ import java.time.LocalDateTime; | |||
/** | |||
* 卡签挂失表 | |||
* 重新激活表 | |||
*/ | |||
@Getter | |||
@Setter | |||
@@ -35,7 +35,7 @@ public class AssDeviceReactivate extends AbstractStringPropertyUUIDEntity { | |||
@Column(name = "VEHICLE_PLATE") | |||
private String vehiclePlate;//车牌号; | |||
@NotNull | |||
@Column(name = "VEHICLE_PLATECOLOR") | |||
@Column(name = "VEHICLE_PLATE_COLOR") | |||
private Integer vehiclePlateColor;//车牌颜色; | |||
@NotNull | |||
@Column(name = "INSERT_TIME") |
@@ -0,0 +1,8 @@ | |||
package cn.com.taiji.core.repo.jpa.ass; | |||
import cn.com.taiji.common.repo.jpa.AbstractJpaRepo; | |||
import cn.com.taiji.core.entity.ass.AssDeviceReactivate; | |||
public interface AssDeviceReactivateRepo extends AbstractJpaRepo<AssDeviceReactivate, String> { | |||
} |
@@ -13,6 +13,8 @@ public interface IssueOrderinfoRepo extends AbstractJpaRepo<IssueOrderinfo, Stri | |||
IssueOrderinfo findNormalByVehicleId(String vehicleId); | |||
IssueOrderinfo findByOrderNo(String orderNo); | |||
@Query("from IssueOrderinfo where customerId = ?1 and orderStatus = 'NORMAL' and orderStep = 'WAITING_ACTIVE'") | |||
List<IssueOrderinfo> listByCustomerId(String customerId); | |||
IssueOrderinfo findByQdOrderNo(String qdOrderNo); | |||
@@ -0,0 +1,14 @@ | |||
package cn.com.taiji.core.repo.request.managew; | |||
import lombok.Getter; | |||
import lombok.Setter; | |||
@Getter | |||
@Setter | |||
public class DeviceReactivateModel { | |||
private String vehiclePlate;// 车牌号码 | |||
private Integer vehiclePlateColor;// 车牌颜色 | |||
private Integer activeType;// 激活类型1-发行激活 2-脱落激活 | |||
private String mobile;// 手机号 | |||
private Integer vehicleType; | |||
} |
@@ -2,6 +2,8 @@ package cn.com.taiji.iaw.api.ass; | |||
import javax.validation.Valid; | |||
import cn.com.taiji.common.manager.net.http.ServiceHandleException; | |||
import cn.com.taiji.iaw.dto.ass.active.*; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.web.bind.annotation.PostMapping; | |||
import org.springframework.web.bind.annotation.RequestBody; | |||
@@ -11,8 +13,6 @@ import org.springframework.web.bind.annotation.RestController; | |||
import cn.com.taiji.common.manager.ManagerException; | |||
import cn.com.taiji.common.web.ApiResponse; | |||
import cn.com.taiji.iaw.api.MyValidController; | |||
import cn.com.taiji.iaw.dto.ass.active.SaveRecordRequestDTO; | |||
import cn.com.taiji.iaw.dto.ass.active.SaveRecordResponseDTO; | |||
import cn.com.taiji.iaw.manager.ass.ActiveManager; | |||
import io.swagger.annotations.Api; | |||
import io.swagger.annotations.ApiOperation; | |||
@@ -33,9 +33,16 @@ public class ActiveController extends MyValidController { | |||
@ApiOperation(value = "查询可激活车辆列表") | |||
@PostMapping(value = "/queryVehicle") | |||
public ApiResponse<SaveRecordResponseDTO> queryVehicle(@Valid @RequestBody SaveRecordRequestDTO reqDto) throws ManagerException { | |||
SaveRecordResponseDTO resDto = manager.saveRecord(reqDto); | |||
public ApiResponse<QueryVehicleResponseDTO> queryVehicle(@Valid @RequestBody QueryVehicleRequestDTO reqDto) throws ManagerException { | |||
QueryVehicleResponseDTO resDto = manager.queryVehicle(reqDto); | |||
return ApiResponse.of(resDto).setMessage("操作成功"); | |||
} | |||
@ApiOperation(value = "保存记录") | |||
@PostMapping(value = "/saveRecords") | |||
public ApiResponse<ActivateDetailsResponseDTO> saveRecords(@Valid @RequestBody ActivateDetailsRequestDTO reqDto) throws ServiceHandleException { | |||
ActivateDetailsResponseDTO resDto = manager.saveRecords(reqDto); | |||
return ApiResponse.of(resDto).setMessage("保存成功"); | |||
} | |||
} |
@@ -0,0 +1,47 @@ | |||
package cn.com.taiji.iaw.dto.ass.active; | |||
import org.springframework.validation.annotation.Validated; | |||
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.persistence.Column; | |||
import javax.validation.constraints.NotBlank; | |||
import javax.validation.constraints.NotNull; | |||
@ApiModel(description = "激活明细请求") | |||
@Getter | |||
@Setter | |||
@Accessors(chain = true) | |||
@Validated | |||
public class ActivateDetailsRequestDTO extends AbstractBizRequestDTO { | |||
@NotBlank | |||
@ApiModelProperty(value = "车牌id") | |||
private String vehicleId;// 车牌颜色 | |||
@NotBlank | |||
@ApiModelProperty(value = "车牌号码") | |||
private String vehiclePlate;// 车牌号码 | |||
@NotNull | |||
@ApiModelProperty(value = "车牌颜色") | |||
private Integer vehiclePlateColor;// 车牌颜色 | |||
@NotBlank | |||
@ApiModelProperty(value = "etc卡号") | |||
private String cardId;// etc卡号 | |||
@NotBlank | |||
@ApiModelProperty(value = "OBU号") | |||
private String obuId;// OBU号 | |||
@ApiModelProperty(value = "行驶证正面图片地址") | |||
private String vehPosImgUrl;//行驶证正面图片地址 | |||
@ApiModelProperty(value = "行驶证反面图片地址") | |||
private String vehNegImgUrl;//行驶证反面图片地址 | |||
@NotBlank | |||
@ApiModelProperty(value = "车身照") | |||
private String vehBodyUrl;//车身照 | |||
@NotBlank | |||
@ApiModelProperty(value = "安装照") | |||
private String installImgUrl;//安装照 | |||
} |
@@ -0,0 +1,15 @@ | |||
package cn.com.taiji.iaw.dto.ass.active; | |||
import cn.com.taiji.common.model.BaseModel; | |||
import io.swagger.annotations.ApiModel; | |||
import lombok.Getter; | |||
import lombok.Setter; | |||
import lombok.experimental.Accessors; | |||
@ApiModel(description = "激活明细返回") | |||
@Getter | |||
@Setter | |||
@Accessors(chain = true) | |||
public class ActivateDetailsResponseDTO extends BaseModel { | |||
} |
@@ -18,7 +18,7 @@ import javax.validation.constraints.NotNull; | |||
@Validated | |||
public class QueryVehicleRequestDTO extends AbstractBizRequestDTO { | |||
@ApiModelProperty(value = "车牌号码") | |||
private String vehiclePlate;// 车牌号码 | |||
@ApiModelProperty(value = "车牌id,如传输即为非本人办理") | |||
private String vehicleId;// 车牌id | |||
} |
@@ -1,29 +1,20 @@ | |||
package cn.com.taiji.iaw.dto.ass.active; | |||
import java.util.List; | |||
import cn.com.taiji.common.model.BaseModel; | |||
import cn.com.taiji.core.repo.request.managew.DeviceReactivateModel; | |||
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; | |||
@ApiModel(description = "车辆列表查询返回") | |||
@Getter | |||
@Setter | |||
@Accessors(chain = true) | |||
public class QueryVehicleResponseDTO extends BaseModel { | |||
@NotBlank | |||
@ApiModelProperty(value = "车牌号码") | |||
private String vehiclePlate;// 车牌号码 | |||
@NotNull | |||
@ApiModelProperty(value = "车牌颜色") | |||
private Integer vehiclePlateColor;// 车牌颜色 | |||
@NotNull | |||
@ApiModelProperty(value = "激活类型") | |||
private Integer activeType;// 激活类型1-发行激活 2-脱落激活 | |||
List<DeviceReactivateModel> modelList; | |||
} |
@@ -1,8 +1,11 @@ | |||
package cn.com.taiji.iaw.manager; | |||
import java.io.IOException; | |||
import java.time.LocalDateTime; | |||
import java.time.format.DateTimeFormatter; | |||
import java.util.concurrent.Callable; | |||
import cn.com.taiji.common.pub.StringTools; | |||
import cn.com.taiji.common.web.util.WebTools; | |||
import cn.com.taiji.core.manager.cache.RedisCacheManager; | |||
import cn.com.taiji.core.model.comm.protocol.*; | |||
@@ -215,4 +218,14 @@ public abstract class AbstractCommManager extends RedisCacheManager { | |||
} | |||
} | |||
public String createOrderNo(String agentId) { | |||
return StringTools | |||
.hasText(agentId) | |||
? LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss")) | |||
+ agentId | |||
+ (int) ((Math.random() * 9 + 1) * Math.pow(10, 6)) | |||
: LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS")) | |||
+ (int) ((Math.random() * 9 + 1) * Math.pow(10, 5)); | |||
} | |||
} |
@@ -1,12 +1,14 @@ | |||
package cn.com.taiji.iaw.manager.ass; | |||
import cn.com.taiji.common.manager.ManagerException; | |||
import cn.com.taiji.iaw.dto.ass.active.SaveRecordRequestDTO; | |||
import cn.com.taiji.iaw.dto.ass.active.SaveRecordResponseDTO; | |||
import cn.com.taiji.common.manager.net.http.ServiceHandleException; | |||
import cn.com.taiji.iaw.dto.ass.active.*; | |||
/** | |||
* 激活记录相关功能 | |||
*/ | |||
public interface ActiveManager { | |||
SaveRecordResponseDTO saveRecord(SaveRecordRequestDTO requestDTO) throws ManagerException; | |||
QueryVehicleResponseDTO queryVehicle(QueryVehicleRequestDTO requestDTO) throws ManagerException; | |||
ActivateDetailsResponseDTO saveRecords(ActivateDetailsRequestDTO requestDTO) throws ServiceHandleException; | |||
} |
@@ -1,21 +1,40 @@ | |||
package cn.com.taiji.iaw.manager.ass; | |||
import cn.com.taiji.common.pub.BeanTools; | |||
import cn.com.taiji.core.entity.issue.IssueOrderinfo; | |||
import cn.com.taiji.core.entity.managew.ActiveRecord; | |||
import java.time.LocalDateTime; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
import cn.com.taiji.common.manager.net.http.ServiceHandleException; | |||
import cn.com.taiji.core.entity.ass.AssDeviceReactivate; | |||
import cn.com.taiji.core.entity.ass.AssOrderinfo; | |||
import cn.com.taiji.core.entity.basic.QtkCardInfo; | |||
import cn.com.taiji.core.entity.basic.QtkObuInfo; | |||
import cn.com.taiji.core.entity.dict.AuditStatus; | |||
import cn.com.taiji.core.entity.dict.ass.AssOrderStatus; | |||
import cn.com.taiji.core.entity.dict.ass.AssOrderType; | |||
import cn.com.taiji.core.entity.dict.basic.CardStatus; | |||
import cn.com.taiji.core.repo.jpa.ass.AssDeviceReactivateRepo; | |||
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.QtkObuInfoRepo; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
import org.springframework.transaction.annotation.Transactional; | |||
import cn.com.taiji.common.manager.ManagerException; | |||
import cn.com.taiji.common.pub.BeanTools; | |||
import cn.com.taiji.core.entity.basic.QtkCustomerInfo; | |||
import cn.com.taiji.core.entity.basic.QtkVehicleInfo; | |||
import cn.com.taiji.core.entity.issue.IssueOrderinfo; | |||
import cn.com.taiji.core.entity.managew.ActiveRecord; | |||
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.issue.IssueOrderinfoRepo; | |||
import cn.com.taiji.core.repo.jpa.managew.ActiveRecordRepo; | |||
import cn.com.taiji.iaw.dto.ass.active.SaveRecordRequestDTO; | |||
import cn.com.taiji.iaw.dto.ass.active.SaveRecordResponseDTO; | |||
import cn.com.taiji.core.repo.request.managew.DeviceReactivateModel; | |||
import cn.com.taiji.iaw.dto.ass.active.*; | |||
import cn.com.taiji.iaw.manager.AbstractCommManager; | |||
import java.time.LocalDateTime; | |||
/** | |||
* 激活记录相关功能 | |||
*/ | |||
@@ -25,7 +44,19 @@ public class ActiveManagerImpl extends AbstractCommManager implements ActiveMana | |||
@Autowired | |||
private ActiveRecordRepo recordRepo; | |||
@Autowired | |||
private IssueOrderinfoRepo orderinfoRepo; | |||
private IssueOrderinfoRepo issueOrderinfoRepo; | |||
@Autowired | |||
private QtkVehicleInfoRepo vehicleInfoRepo; | |||
@Autowired | |||
private QtkCustomerInfoRepo customerInfoRepo; | |||
@Autowired | |||
private AssOrderinfoRepo assOrderinfoRepo; | |||
@Autowired | |||
private AssDeviceReactivateRepo deviceReactivateRepo; | |||
@Autowired | |||
private QtkCardInfoRepo cardInfoRepo; | |||
@Autowired | |||
private QtkObuInfoRepo obuInfoRepo; | |||
/** | |||
* 新增激活记录 | |||
@@ -34,7 +65,7 @@ public class ActiveManagerImpl extends AbstractCommManager implements ActiveMana | |||
@Transactional(rollbackFor = Exception.class) | |||
public SaveRecordResponseDTO saveRecord(SaveRecordRequestDTO requestDTO) throws ManagerException { | |||
// 查找orderInfo | |||
IssueOrderinfo orderInfo = orderinfoRepo.findByOrderNo(requestDTO.getOrderNo()); | |||
IssueOrderinfo orderInfo = issueOrderinfoRepo.findByOrderNo(requestDTO.getOrderNo()); | |||
if (orderInfo == null){ | |||
throw new ManagerException("未查到订单表!"); | |||
} | |||
@@ -53,4 +84,79 @@ public class ActiveManagerImpl extends AbstractCommManager implements ActiveMana | |||
return resDTO; | |||
} | |||
@Override | |||
public QueryVehicleResponseDTO queryVehicle(QueryVehicleRequestDTO requestDTO) throws ManagerException { | |||
List<DeviceReactivateModel> list = new ArrayList<>() ; | |||
QtkCustomerInfo customerInfo = customerInfoRepo.findByCustomerId(requestDTO.getCustomerId()); | |||
if (customerInfo == null){ | |||
throw new ManagerException("未查到客户信息!"); | |||
} | |||
if (requestDTO.getVehicleId().isEmpty()){ | |||
// 本人办理,查询订单表和车辆表 | |||
List<QtkVehicleInfo> vehicleInfos = vehicleInfoRepo.findByCustomerId(requestDTO.getCustomerId()); | |||
if (!vehicleInfos.isEmpty()){ | |||
for (QtkVehicleInfo vehicleInfo : vehicleInfos) { | |||
DeviceReactivateModel model = new DeviceReactivateModel(); | |||
BeanTools.copyProperties(vehicleInfo, model); | |||
model.setMobile(customerInfo.getCustomerTel()); | |||
model.setVehicleType(vehicleInfo.getType()); | |||
model.setActiveType(1); | |||
list.add(model); | |||
} | |||
} | |||
List<IssueOrderinfo> orderinfos = issueOrderinfoRepo.listByCustomerId(requestDTO.getCustomerId()); | |||
if (!orderinfos.isEmpty()){ | |||
for (IssueOrderinfo orderinfo : orderinfos) { | |||
QtkVehicleInfo info = vehicleInfoRepo.findByVehicleId(orderinfo.getVehicleId()); | |||
DeviceReactivateModel model = new DeviceReactivateModel(); | |||
BeanTools.copyProperties(orderinfo, model); | |||
model.setMobile(customerInfo.getCustomerTel()); | |||
model.setVehicleType(info.getType()); | |||
model.setActiveType(2); | |||
list.add(model); | |||
} | |||
} | |||
}else { | |||
// 非本人办理,查询车辆信息表 | |||
QtkVehicleInfo info = vehicleInfoRepo.findByVehicleId(requestDTO.getVehicleId()); | |||
DeviceReactivateModel model = new DeviceReactivateModel(); | |||
BeanTools.copyProperties(info, model); | |||
model.setVehicleType(info.getType()); | |||
model.setMobile(customerInfo.getCustomerTel()); | |||
model.setActiveType(2); | |||
list.add(model); | |||
} | |||
QueryVehicleResponseDTO resDTO = new QueryVehicleResponseDTO(); | |||
resDTO.setModelList(list); | |||
return resDTO; | |||
} | |||
@Override | |||
public ActivateDetailsResponseDTO saveRecords(ActivateDetailsRequestDTO requestDTO) throws ServiceHandleException { | |||
LocalDateTime now = LocalDateTime.now(); | |||
QtkCardInfo cardInfo = cardInfoRepo.findByCardId(requestDTO.getCardId()); | |||
QtkCustomerInfo customerInfo = customerInfoRepo.findByCustomerId(requestDTO.getCustomerId()); | |||
String orderNo = createOrderNo(cardInfo.getAgencyId()); | |||
// 存售后订单 | |||
AssOrderinfo assOrderinfo = copyProperties(customerInfo, new AssOrderinfo()); | |||
BeanTools.copyProperties(requestDTO, assOrderinfo); | |||
assOrderinfo.setAgencyId(cardInfo.getAgencyId()); | |||
assOrderinfo.setChannelId(cardInfo.getChannelId()); | |||
assOrderinfo.setOrderNo(orderNo); | |||
assOrderinfo.setOpenId(findOpenIdByToken(requestDTO.getAccessToken())); | |||
assOrderinfo.setOrderType(AssOrderType.REACTIVATE); | |||
assOrderinfo.setOrderStatus(AssOrderStatus.FINISHED); | |||
assOrderinfo.setAuditStatus(AuditStatus.NO_AUDIT); | |||
assOrderinfo.setApplyTime(now); | |||
assOrderinfo.setInsertTime(now); | |||
assOrderinfo.setUpdateTime(now); | |||
assOrderinfoRepo.persist(assOrderinfo); | |||
// 存二次激活记录 | |||
AssDeviceReactivate deviceReactivate = new AssDeviceReactivate(); | |||
BeanTools.copyProperties(requestDTO, deviceReactivate); | |||
deviceReactivate.setInsertTime(now); | |||
deviceReactivate.setOrderNo(orderNo); | |||
deviceReactivateRepo.persist(deviceReactivate); | |||
return new ActivateDetailsResponseDTO(); | |||
} | |||
} |