Commit 521c8360 by xieshixiang

驾照信息查询

parent eb43dfe9
......@@ -5,9 +5,7 @@ import com.hikcreate.common.sdk.response.apiparam.Response;
import com.hikcreate.common.sdk.response.apiparam.ResponseGenerator;
import com.hikcreate.common.sdk.response.statuscode.StatusCode;
import com.hikcreate.edl.pub.web.mobile.domain.IBindService;
import com.hikcreate.edl.pub.web.mobile.infra.core.Result;
import com.hikcreate.edl.pub.web.mobile.infra.core.annotatiion.ResponseEncryptAnnotation;
import com.hikcreate.edl.pub.web.mobile.infra.core.enums.ResultCode;
import com.hikcreate.edl.pub.web.mobile.infra.data.mapper.BindInfoMapper;
import com.hikcreate.edl.pub.web.mobile.infra.model.BindInfo;
import com.hikcreate.edl.pub.web.mobile.infra.model.BindInfoQuery;
......@@ -23,6 +21,7 @@ import javax.annotation.Resource;
/**
* 绑定信息的controller
*
* @menu 提供给第三方接口
* @author: xieshixiang
* @time:2020/6/18 15:59
......@@ -65,12 +64,12 @@ public class BindInfoControlller extends BaseController {
* @date: 2020/6/19 10:27
*/
@PostMapping("unbind")
public Response unbindInfo( @RequestBody BindInfo info) {
public Response unbindInfo(@RequestBody BindInfo info) {
if (info == null) {
return ResponseGenerator.fail(StatusCode.PARAM_ERROR);
}
info.setStatus("0");
info.setUnbindTime(DateTime.now());
info.setUnbindTime(DateTime.now().toString());
return mapper.updateById(info) > 0 ? ResponseGenerator.success() : ResponseGenerator.fail("");
}
......
package com.hikcreate.edl.pub.web.mobile.api.controller;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.hikcreate.common.sdk.response.apiparam.Response;
import com.hikcreate.common.sdk.response.apiparam.ResponseGenerator;
import com.hikcreate.common.sdk.response.statuscode.StatusCode;
import com.hikcreate.edl.common.sdk.util.VerifyCodeUtil;
import com.hikcreate.edl.pub.web.mobile.domain.IBindService;
import com.hikcreate.edl.pub.web.mobile.infra.core.Result;
import com.hikcreate.edl.pub.web.mobile.infra.core.enums.ResultCode;
import com.hikcreate.edl.pub.web.mobile.infra.data.feign.edl_pub_service_sms.SmsFeign;
import com.hikcreate.edl.pub.web.mobile.infra.data.feign.edl_pub_service_sms.param.request.CheckVerifyCodeMicReq;
import com.hikcreate.edl.pub.web.mobile.infra.data.feign.edl_pub_service_sms.param.request.SendVerifyCodeMicReq;
import com.hikcreate.edl.pub.web.mobile.infra.data.mapper.VerifyInfoMapper;
import com.hikcreate.edl.pub.web.mobile.infra.model.BindInfoQuery;
import com.hikcreate.edl.pub.web.mobile.infra.model.VerifyInfo;
import com.hikcreate.edl.pub.web.mobile.infra.model.param.response.DrivingLicenseInfoRes;
import com.hikcreate.edl.pub.web.mobile.infra.model.param.response.InsuranceInfoRes;
import com.hikcreate.edl.pub.web.mobile.infra.model.param.response.ResultList;
......@@ -16,12 +24,17 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/**
* 对外提供给H5的接口
*
* @menu H5接口
* @author: xieshixiang
* @time:2020/6/19 16:37
......@@ -33,6 +46,10 @@ public class H5Controller {
@Autowired
IBindService service;
@Resource
VerifyInfoMapper verifyInfoMapper;
@Resource
SmsFeign smsFeign;
/**
* 年检信息查询接口
......@@ -43,7 +60,7 @@ public class H5Controller {
* @date: 2020/6/19 10:32
*/
@GetMapping("yearCheckInfo")
public Response<YearCheckInfoRes> yearCheckInfo( @RequestBody @Validated BindInfoQuery query) {
public Response<YearCheckInfoRes> yearCheckInfo(@RequestBody @Validated BindInfoQuery query) {
if (query == null) {
return ResponseGenerator.fail(StatusCode.PARAM_ERROR);
}
......@@ -97,4 +114,52 @@ public class H5Controller {
}
return service.drivingLicenseInfo(query);
}
@GetMapping("checkValidity")
public Response checkValidity(@RequestBody BindInfoQuery query) {
if (query == null) {
return ResponseGenerator.fail(StatusCode.PARAM_ERROR);
}
VerifyInfo verifyInfo = verifyInfoMapper.checkValidity(query.getPhone(), query.getUserId(),
DateUtil.offsetDay(DateTime.now(), -10));
if (verifyInfo != null) {
return ResponseGenerator.success();
} else {
SendVerifyCodeMicReq sendVerifyCodeMicReq = new SendVerifyCodeMicReq();
sendVerifyCodeMicReq.setUserId(query.getUserId());
sendVerifyCodeMicReq.setPhone(query.getPhone());
sendVerifyCodeMicReq.setVerifyCode(VerifyCodeUtil.getCode());
return ResponseGenerator.fail(StatusCode.PERMISSION_DENIED.getCode(), null, sendVerifyCodeMicReq);
}
}
@PostMapping("sendVerifyCode")
public Response sendVerifyCode(@RequestBody SendVerifyCodeMicReq req) {
if (req == null) {
return ResponseGenerator.fail(StatusCode.PARAM_ERROR);
}
return ResponseGenerator.success(smsFeign.sendVerifyCode(req));
}
@PostMapping("checkVerifyCode")
public Response sendVerifyCode(@RequestBody CheckVerifyCodeMicReq req) {
if (req == null) {
return ResponseGenerator.fail(StatusCode.PARAM_ERROR);
}
Result<Void> checkResult = smsFeign.checkVerifyCode(req);
if (ResultCode.SUCCESS.getCode().equals(checkResult.getCode())) {
VerifyInfo verifyInfo = new VerifyInfo();
verifyInfo.setUserId(req.getUserId());
verifyInfo.setVerifyCode(req.getVerifyCode());
verifyInfo.setPhone(req.getPhone());
verifyInfo.setPassTime(DateTime.now().toString());
verifyInfoMapper.insert(verifyInfo);
}
return ResponseGenerator.success(checkResult);
}
}
......@@ -9,13 +9,14 @@ import com.hikcreate.common.sdk.response.apiparam.Response;
import com.hikcreate.common.sdk.response.apiparam.ResponseGenerator;
import com.hikcreate.common.sdk.response.statuscode.StatusCode;
import com.hikcreate.edl.pub.web.mobile.domain.IBindService;
import com.hikcreate.edl.pub.web.mobile.infra.core.Result;
import com.hikcreate.edl.pub.web.mobile.infra.core.enums.ResultCode;
import com.hikcreate.edl.pub.web.mobile.infra.data.feign.dcp_service_vehicle.DrivingLicenseFeign;
import com.hikcreate.edl.pub.web.mobile.infra.data.feign.dcp_service_vehicle.VechicleFeign;
import com.hikcreate.edl.pub.web.mobile.infra.data.feign.dcp_service_vehicle.ViolationFeign;
import com.hikcreate.edl.pub.web.mobile.infra.data.feign.dcp_service_vehicle.param.request.IdCardQueryReq;
import com.hikcreate.edl.pub.web.mobile.infra.data.feign.dcp_service_vehicle.param.request.PlateNumAndTypeQueryReq;
import com.hikcreate.edl.pub.web.mobile.infra.data.feign.dcp_service_vehicle.param.request.PlateNumQueryReq;
import com.hikcreate.edl.pub.web.mobile.infra.data.feign.dcp_service_vehicle.param.request.ViolationPlateNumAndTypeQueryReq;
import com.hikcreate.edl.pub.web.mobile.infra.data.feign.dcp_service_vehicle.param.response.DrivingLicenseRes;
import com.hikcreate.edl.pub.web.mobile.infra.data.feign.dcp_service_vehicle.param.response.VehicleRes;
import com.hikcreate.edl.pub.web.mobile.infra.data.feign.dcp_service_vehicle.param.response.ViolationRes;
import com.hikcreate.edl.pub.web.mobile.infra.data.mapper.BindInfoMapper;
......@@ -23,7 +24,11 @@ import com.hikcreate.edl.pub.web.mobile.infra.data.mapper.VerifyInfoMapper;
import com.hikcreate.edl.pub.web.mobile.infra.model.BindInfo;
import com.hikcreate.edl.pub.web.mobile.infra.model.BindInfoQuery;
import com.hikcreate.edl.pub.web.mobile.infra.model.VerifyInfo;
import com.hikcreate.edl.pub.web.mobile.infra.model.param.response.*;
import com.hikcreate.edl.pub.web.mobile.infra.model.param.response.DrivingLicenseInfoRes;
import com.hikcreate.edl.pub.web.mobile.infra.model.param.response.InsuranceInfoRes;
import com.hikcreate.edl.pub.web.mobile.infra.model.param.response.ResultList;
import com.hikcreate.edl.pub.web.mobile.infra.model.param.response.ViolationInfoRes;
import com.hikcreate.edl.pub.web.mobile.infra.model.param.response.YearCheckInfoRes;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
......@@ -54,12 +59,14 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, BindInfo> imple
ViolationFeign violatio;
@Resource
VerifyInfoMapper verifyInfo;
@Resource
DrivingLicenseFeign drivingLicense;
@Override
public Response bind(BindInfo info) {
info.setUnqId(UUID.randomUUID().toString());
info.setGmtBindTime(DateTime.now());
info.setGmtBindTime(DateTime.now().toString());
//判断规则1:用户已绑定的车辆不超过3辆,包括已解绑但未过一个月的车辆
QueryWrapper boundQuery = new QueryWrapper();
......@@ -86,28 +93,27 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, BindInfo> imple
}
@Override
public Response<YearCheckInfoRes> yearCheckInfo( BindInfoQuery query) {
public Response<YearCheckInfoRes> yearCheckInfo(BindInfoQuery query) {
BindInfo bindInfo = mapper.selectById(query.getUnqId());
if (bindInfo == null || "0".equals(bindInfo.getStatus())) {
return ResponseGenerator.fail(StatusCode.DATA_ERROR);
}
PlateNumAndTypeQueryReq req = new PlateNumAndTypeQueryReq();
PlateNumAndTypeQueryReq req = new PlateNumAndTypeQueryReq();
req.setPlateNum(bindInfo.getPlateNum());
req.setPlateType(bindInfo.getPlateType());
VehicleRes vehicleRes = vechicle.getByPlateNumAndType(req);
if( Objects.isNull(vehicleRes) ) {
if (Objects.isNull(vehicleRes)) {
return ResponseGenerator.success();
}
YearCheckInfoRes yearCheckInfoRes = new YearCheckInfoRes();
yearCheckInfoRes.setPlateNum(bindInfo.getPlateNum());
yearCheckInfoRes.setValidityTime(vehicleRes.getYxqz());
Long checkTime = DateUtil.parse(vehicleRes.getYxqz(),"yyyy-MM-dd HH:mm:ss").getTime();
if( checkTime>=System.currentTimeMillis() ) {
Long checkTime = DateUtil.parse(vehicleRes.getYxqz(), "yyyy-MM-dd HH:mm:ss").getTime();
if (checkTime >= System.currentTimeMillis()) {
yearCheckInfoRes.setStatus("未到期");
} else {
yearCheckInfoRes.setStatus("已到期");
}
return ResponseGenerator.success(yearCheckInfoRes);
}
......@@ -117,31 +123,31 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, BindInfo> imple
if (bindInfo == null || "0".equals(bindInfo.getStatus())) {
return ResponseGenerator.fail(StatusCode.DATA_ERROR);
}
PlateNumAndTypeQueryReq req = new PlateNumAndTypeQueryReq();
PlateNumAndTypeQueryReq req = new PlateNumAndTypeQueryReq();
req.setPlateNum(bindInfo.getPlateNum());
req.setPlateType(bindInfo.getPlateType());
VehicleRes vehicleRes = vechicle.getByPlateNumAndType(req);
if( Objects.isNull(vehicleRes) ) {
if (Objects.isNull(vehicleRes)) {
return ResponseGenerator.success();
}
InsuranceInfoRes insuranceInfoRes = new InsuranceInfoRes();
insuranceInfoRes.setPlateNum(bindInfo.getPlateNum());
if( StrUtil.isNotBlank(vehicleRes.getBxzzrq()) ) {
Long time = DateUtil.parse(vehicleRes.getBxzzrq(),"yyyy-MM-dd HH:mm:ss").getTime();
if( time>=System.currentTimeMillis()) {
if (StrUtil.isNotBlank(vehicleRes.getBxzzrq())) {
Long time = DateUtil.parse(vehicleRes.getBxzzrq(), "yyyy-MM-dd HH:mm:ss").getTime();
if (time >= System.currentTimeMillis()) {
insuranceInfoRes.setStatus("有效");
} else {
insuranceInfoRes.setStatus("已到期");
}
insuranceInfoRes.setValidityTimeEnd(vehicleRes.getBxzzrq().substring(0,10));
insuranceInfoRes.setValidityTimeEnd(vehicleRes.getBxzzrq().substring(0, 10));
String endTime = DateUtil.format(
DateUtil.offsetMonth(DateUtil.parse(vehicleRes.getBxzzrq(),"yyyy-MM-dd HH:mm:ss"), -12),
DateUtil.offsetMonth(DateUtil.parse(vehicleRes.getBxzzrq(), "yyyy-MM-dd HH:mm:ss"), -12),
"yyyy-MM-dd");
insuranceInfoRes.setValidityTimeStart(endTime);
} else {
insuranceInfoRes.setStatus("未知");
}
return ResponseGenerator.success(insuranceInfoRes);
return null;
}
......@@ -163,7 +169,7 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, BindInfo> imple
info.setAction(res.getWfxw());
info.setAddress(res.getWfdz());
info.setGrade(res.getWfjfs());
info.setMoney(res.getfk);
info.setMoney(res.getFkje());
violationInfoResList.add(info);
}
return ResponseGenerator.success(new ResultList<>(violationInfoResList));
......@@ -176,13 +182,34 @@ public class BindServiceImpl extends ServiceImpl<BindInfoMapper, BindInfo> imple
return ResponseGenerator.fail(StatusCode.DATA_ERROR);
}
VerifyInfo verifyInfo = this.verifyInfo.checkValidity(query.getPhone(), query.getUserId(),
DateUtil.offsetDay(DateTime.now(), -10));
if (verifyInfo == null) {
return ResponseGenerator.fail(StatusCode.PERMISSION_DENIED);
}
PlateNumAndTypeQueryReq vechicleInfoReq = new PlateNumAndTypeQueryReq();
vechicleInfoReq.setPlateType(bindInfo.getPlateType());
vechicleInfoReq.setPlateNum(bindInfo.getPlateNum());
VehicleRes byPlateNumAndType = vechicle.getByPlateNumAndType(vechicleInfoReq);
if (byPlateNumAndType.getSfzmhm() == null) {
return ResponseGenerator.fail(StatusCode.ALERT_ERROR);
}
IdCardQueryReq idCardQueryReq = new IdCardQueryReq();
idCardQueryReq.setIdCard(byPlateNumAndType.getSfzmhm());
DrivingLicenseRes drivingLicenseRes = drivingLicense.getByIdCard(idCardQueryReq);
if (drivingLicenseRes == null) {
return ResponseGenerator.fail(StatusCode.ALERT_ERROR);
}
DrivingLicenseInfoRes result = new DrivingLicenseInfoRes();
result.setDriverName(drivingLicenseRes.getXm());
result.setPlateNum(drivingLicenseRes.getSfzmhm());
result.setValidityTime(drivingLicenseRes.getYxqz());
result.setStatus(drivingLicenseRes.getZtValue());
return ResponseGenerator.success(result);
}
......
package com.hikcreate.edl.pub.web.mobile.infra.data.feign.dcp_service_vehicle;
import com.hikcreate.edl.pub.web.mobile.infra.data.feign.dcp_service_vehicle.param.request.IdCardQueryReq;
import com.hikcreate.edl.pub.web.mobile.infra.data.feign.dcp_service_vehicle.param.response.DrivingLicenseRes;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
/**
*
*/
@RestController
@RequestMapping("drivingLicense")
public interface DrivingLicenseFeign {
@PostMapping("/getByIdCard")
DrivingLicenseRes getByIdCard(@RequestBody @Valid IdCardQueryReq req);
}
package com.hikcreate.edl.pub.web.mobile.infra.data.feign.dcp_service_vehicle.param.request;
import lombok.Data;
import javax.validation.constraints.NotBlank;
/**
* @author MOUBK
* @create 2019/7/5 14:56
*/
@Data
public class IdCardQueryReq {
@NotBlank(message = "IdCard is not blank")
private String idCard;
}
......@@ -13,12 +13,13 @@ import org.springframework.web.bind.annotation.RequestBody;
*/
@FeignClient( value = "edl-pub-service-sms", path = "sms" )
public interface SmsFeign {
@PostMapping( {"send"} )
Result<Void> send( @RequestBody SendMicReq var1 );
Result<Void> send( @RequestBody SendMicReq req );
@PostMapping( {"verifyCode/send"} )
Result<Void> sendVerifyCode( @RequestBody SendVerifyCodeMicReq var1 );
Result<Void> sendVerifyCode( @RequestBody SendVerifyCodeMicReq req );
@PostMapping( {"verifyCode/check"} )
Result<Void> checkVerifyCode( @RequestBody CheckVerifyCodeMicReq var1 );
Result<Void> checkVerifyCode( @RequestBody CheckVerifyCodeMicReq req);
}
\ No newline at end of file
......@@ -6,6 +6,7 @@ import lombok.experimental.Accessors;
@Data
@Accessors(chain = true)
public class CheckVerifyCodeMicReq {
private String userId;//用户ID
private String phone; // 手机号码
private String templateCode; // 短信模板编码
private String extraKey; // 附加的键,主要用于一辆机动车被多个人绑定的场景。
......
......@@ -5,6 +5,7 @@ import lombok.Data;
@Data
public class SendVerifyCodeMicReq {
private String userId;//用户ID
private String phone; // 手机号码
private String templateCode; // 短信模板编码
private String extraKey; // 附加的键,主要用于一辆机动车被多个人绑定的场景。
......
......@@ -47,11 +47,11 @@ public class BindInfo implements Serializable {
/**
* 绑定时间
*/
private DateTime gmtBindTime;
private String gmtBindTime;
/**
* 解绑时间
*/
private DateTime unbindTime;
private String unbindTime;
......
......@@ -30,7 +30,7 @@ public class VerifyInfo {
/**
* 上次通过验证的时间
*/
private DateTime passTime;
private String passTime;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment