修改VIN充电逻辑
This commit is contained in:
parent
35355b33ce
commit
bbd90511d3
@ -0,0 +1,73 @@
|
|||||||
|
package com.xhpc.general.controller;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import com.aliyun.oss.*;
|
||||||
|
import com.xhpc.common.core.domain.R;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
import com.aliyun.oss.OSS;
|
||||||
|
import com.aliyun.oss.common.auth.*;
|
||||||
|
import com.aliyun.oss.OSSClientBuilder;
|
||||||
|
import com.aliyun.oss.model.PutObjectRequest;
|
||||||
|
import com.aliyun.oss.model.PutObjectResult;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/file")
|
||||||
|
public class XhpcFileController {
|
||||||
|
|
||||||
|
public static final String accessKeyId = "LTAI5tBWjnuQGxGicnThwMF1";
|
||||||
|
public static final String accessKeySecret = "b0WNtFYtWyTEkZzcr2WOAPoZg6w2Xu";
|
||||||
|
|
||||||
|
@PostMapping(value = "/addFile")
|
||||||
|
public R addFile(@RequestParam MultipartFile file){
|
||||||
|
//获取文件名称
|
||||||
|
String originalFilename = file.getOriginalFilename();
|
||||||
|
String endpoint = "https://oss-cn-hangzhou.aliyuncs.com";
|
||||||
|
// 填写Bucket名称,例如examplebucket。
|
||||||
|
String bucketName = "xhpc-bucket1";
|
||||||
|
// 填写Object完整路径,完整路径中不能包含Bucket名称,例如exampledir/exampleobject.txt。
|
||||||
|
String format = DateUtil.format(DateUtil.date(), "yyyyMMddHHmmss");
|
||||||
|
String objectName = "vinFile/"+format+"/"+originalFilename;
|
||||||
|
// 创建OSSClient实例。
|
||||||
|
OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId,accessKeySecret);
|
||||||
|
try {
|
||||||
|
|
||||||
|
// 创建PutObjectRequest对象。
|
||||||
|
PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, objectName, file.getInputStream());
|
||||||
|
// 创建PutObject请求。
|
||||||
|
PutObjectResult result = ossClient.putObject(putObjectRequest);
|
||||||
|
System.out.println(result.toString());
|
||||||
|
Map<String,Object> map =new HashMap<>();
|
||||||
|
map.put("url","https://xhpc-bucket1.oss-cn-hangzhou.aliyuncs.com/"+objectName);
|
||||||
|
return R.ok(map);
|
||||||
|
} catch (OSSException oe) {
|
||||||
|
System.out.println("Caught an OSSException, which means your request made it to OSS, "
|
||||||
|
+ "but was rejected with an error response for some reason.");
|
||||||
|
System.out.println("Error Message:" + oe.getErrorMessage());
|
||||||
|
System.out.println("Error Code:" + oe.getErrorCode());
|
||||||
|
System.out.println("Request ID:" + oe.getRequestId());
|
||||||
|
System.out.println("Host ID:" + oe.getHostId());
|
||||||
|
} catch (ClientException ce) {
|
||||||
|
System.out.println("Caught an ClientException, which means the client encountered "
|
||||||
|
+ "a serious internal problem while trying to communicate with OSS, "
|
||||||
|
+ "such as not being able to access the network.");
|
||||||
|
System.out.println("Error Message:" + ce.getMessage());
|
||||||
|
}catch (Exception e){
|
||||||
|
|
||||||
|
}finally {
|
||||||
|
if (ossClient != null) {
|
||||||
|
ossClient.shutdown();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -192,8 +192,7 @@ public class XhpcChargeOrderController extends BaseController {
|
|||||||
public R pileVin(String serialNumber,String vinNumber)
|
public R pileVin(String serialNumber,String vinNumber)
|
||||||
{
|
{
|
||||||
logger.info("<<<<<<<<<<VIN码启动前判断<<<<<<<<<<<<<<serialNumber>>>>>>>>"+serialNumber+">>>vinNumber>>>"+vinNumber+">>>");
|
logger.info("<<<<<<<<<<VIN码启动前判断<<<<<<<<<<<<<<serialNumber>>>>>>>>"+serialNumber+">>>vinNumber>>>"+vinNumber+">>>");
|
||||||
return R.fail(1880, "无效VIN码");
|
return iXhpcChargeOrderService.pileVin(serialNumber,vinNumber);
|
||||||
//return iXhpcChargeOrderService.pileVin(serialNumber,vinNumber);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/constantSoc")
|
@GetMapping("/constantSoc")
|
||||||
|
|||||||
@ -173,7 +173,6 @@ public interface XhpcChargeOrderMapper {
|
|||||||
* 获取一次订单
|
* 获取一次订单
|
||||||
*
|
*
|
||||||
* @param status -1准备充电 0开始充电 1自动结算,2异常,3平台结算
|
* @param status -1准备充电 0开始充电 1自动结算,2异常,3平台结算
|
||||||
* @param source 0C端用户 1流量用户
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<Map<String,Object>> getXhpcChargeOrderStatus(@Param("status") Integer status);
|
List<Map<String,Object>> getXhpcChargeOrderStatus(@Param("status") Integer status);
|
||||||
@ -233,4 +232,7 @@ public interface XhpcChargeOrderMapper {
|
|||||||
//查询场站是否有道闸
|
//查询场站是否有道闸
|
||||||
Map<String,Object> getXhpcBarrierGate(@Param("chargingStationId")Long chargingStationId);
|
Map<String,Object> getXhpcBarrierGate(@Param("chargingStationId")Long chargingStationId);
|
||||||
|
|
||||||
|
//根据VIN码获取用户
|
||||||
|
Map<String,Object> getvVinNumber(@Param("vinNumber")String vinNumber);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -913,11 +913,13 @@ public class XhpcChargeOrderServiceImpl extends BaseService implements IXhpcChar
|
|||||||
}else if (vinNumber.length()!=17){
|
}else if (vinNumber.length()!=17){
|
||||||
return R.fail(1880, "无效VIN码");
|
return R.fail(1880, "无效VIN码");
|
||||||
}
|
}
|
||||||
//VIN码不存在 1881
|
Map<String, Object> stringObjectMap = xhpcChargeOrderMapper.getvVinNumber(vinNumber);
|
||||||
//Vin码表获取 用户id,用户类型
|
if(stringObjectMap ==null && stringObjectMap.get("appUerId")==null || stringObjectMap.get("source")==null){
|
||||||
Long userId = 1L;
|
return R.fail(1888, "无效VIN码");
|
||||||
Integer userType = 0;
|
}
|
||||||
//终端信息
|
Long userId =Long.valueOf(stringObjectMap.get("appUerId").toString());
|
||||||
|
Integer userType = Integer.parseInt(stringObjectMap.get("source").toString());
|
||||||
|
//终端信息
|
||||||
XhpcTerminal xhpcTerminal = xhpcChargeOrderMapper.getXhpcTerminalSerialNumber(serialNumber,null);
|
XhpcTerminal xhpcTerminal = xhpcChargeOrderMapper.getXhpcTerminalSerialNumber(serialNumber,null);
|
||||||
if (xhpcTerminal == null || xhpcTerminal.getTerminalId() == null || xhpcTerminal.getChargingPileId() == null || xhpcTerminal.getPileSerialNumber() == null) {
|
if (xhpcTerminal == null || xhpcTerminal.getTerminalId() == null || xhpcTerminal.getChargingPileId() == null || xhpcTerminal.getPileSerialNumber() == null) {
|
||||||
return R.fail(1104, "因限电该桩已停用,请选择其他桩进行充电");
|
return R.fail(1104, "因限电该桩已停用,请选择其他桩进行充电");
|
||||||
|
|||||||
@ -766,4 +766,13 @@
|
|||||||
left join xhpc_barrier_gate xbg on xcs.barrier_gate_id = xbg.barrier_gate_id and xbg.del_flag =0 and xbg.status =0
|
left join xhpc_barrier_gate xbg on xcs.barrier_gate_id = xbg.barrier_gate_id and xbg.del_flag =0 and xbg.status =0
|
||||||
where charging_station_id =#{chargingStationId}
|
where charging_station_id =#{chargingStationId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="getvVinNumber" resultType="map">
|
||||||
|
select
|
||||||
|
app_user_id as appUerId,
|
||||||
|
source as source
|
||||||
|
from xhpc_user_vehicle where vin_spec_code =#{vinNumber} and del_flag =0 and source !=1 and status =1 and vin_blacklist =0 order by create_time desc limit 1
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
@ -9,6 +9,8 @@ import com.alipay.api.DefaultAlipayClient;
|
|||||||
import com.alipay.api.internal.util.AlipayEncrypt;
|
import com.alipay.api.internal.util.AlipayEncrypt;
|
||||||
import com.alipay.api.request.AlipaySystemOauthTokenRequest;
|
import com.alipay.api.request.AlipaySystemOauthTokenRequest;
|
||||||
import com.alipay.api.response.AlipaySystemOauthTokenResponse;
|
import com.alipay.api.response.AlipaySystemOauthTokenResponse;
|
||||||
|
import com.aliyun.ocr20191230.models.RecognizeDrivingLicenseResponse;
|
||||||
|
import com.aliyun.ocr20191230.models.RecognizeDrivingLicenseResponseBody;
|
||||||
import com.xhpc.common.api.SettingConfigService;
|
import com.xhpc.common.api.SettingConfigService;
|
||||||
import com.xhpc.common.core.constant.HttpStatus;
|
import com.xhpc.common.core.constant.HttpStatus;
|
||||||
import com.xhpc.common.core.domain.R;
|
import com.xhpc.common.core.domain.R;
|
||||||
@ -30,7 +32,6 @@ import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.core.env.Environment;
|
import org.springframework.core.env.Environment;
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
@ -38,14 +39,15 @@ import javax.crypto.Cipher;
|
|||||||
import javax.crypto.spec.IvParameterSpec;
|
import javax.crypto.spec.IvParameterSpec;
|
||||||
import javax.crypto.spec.SecretKeySpec;
|
import javax.crypto.spec.SecretKeySpec;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.net.URL;
|
||||||
import java.security.AlgorithmParameters;
|
import java.security.AlgorithmParameters;
|
||||||
import java.security.Security;
|
import java.security.Security;
|
||||||
import java.util.Arrays;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import static com.xhpc.common.data.redis.StaticBeanUtil.REDIS;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* C端用户
|
* C端用户
|
||||||
*
|
*
|
||||||
@ -67,6 +69,9 @@ public class XhpcAppUserController extends BaseController {
|
|||||||
private RedisService redisService;
|
private RedisService redisService;
|
||||||
@Resource
|
@Resource
|
||||||
private IXhpcUserVehicleService xhpcUserVehicleService;
|
private IXhpcUserVehicleService xhpcUserVehicleService;
|
||||||
|
public static final String accessKeyId = "LTAI5t6Nr7MdNjMN4xNvgo1W";
|
||||||
|
public static final String accessKeySecret = "hXQopkhlny10aiBBEFia2dHu6RHCqV";
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* C端用户详情
|
* C端用户详情
|
||||||
@ -598,13 +603,96 @@ public class XhpcAppUserController extends BaseController {
|
|||||||
return xhpcUserVehicleService.getXhpcUserVehicleMessage(userId, source);
|
return xhpcUserVehicleService.getXhpcUserVehicleMessage(userId, source);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("添加车牌号")
|
@ApiOperation("添加车牌号/VIN码")
|
||||||
@PostMapping("/addUserVehicle")
|
@PostMapping("/addUserVehicle")
|
||||||
public R addUserVehicle(@RequestBody XhpcUserVehicle xhpcUserVehicle){
|
public R addUserVehicle(@RequestBody XhpcUserVehicle xhpcUserVehicle){
|
||||||
return xhpcUserVehicleService.addUserVehicle(xhpcUserVehicle);
|
return xhpcUserVehicleService.addUserVehicle(xhpcUserVehicle);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
//小程序用户车牌列表
|
||||||
System.out.println(new BCryptPasswordEncoder().encode("Scxh123456!"));
|
@ApiOperation("小程序用户车牌列表")
|
||||||
|
@GetMapping("/getUserVehicleList")
|
||||||
|
public TableDataInfo getUserVehicleList(HttpServletRequest request,Long userId,Integer source) {
|
||||||
|
List<Map<String, Object>> list = xhpcUserVehicleService.getUserVehicleList(request,userId,source);
|
||||||
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation("阿里云自动识别行驶证")
|
||||||
|
@GetMapping("/addUserVehicleUrl")
|
||||||
|
public R addUserVehicleUrl(String url,Long appUserId,Integer source){
|
||||||
|
try {
|
||||||
|
|
||||||
|
//同一个用户一天只有10次机会
|
||||||
|
Integer number = redisService.getCacheObject("vehicle:userId:"+appUserId+source);
|
||||||
|
if(number>10){
|
||||||
|
return R.fail("今天开通VIN码自动识别已达到上线,请手动输入车牌号和VIN开通");
|
||||||
|
}
|
||||||
|
com.aliyun.ocr20191230.Client client = createClient(accessKeyId, accessKeySecret);
|
||||||
|
URL urls = new URL(url);
|
||||||
|
InputStream inputStream = urls.openConnection().getInputStream();
|
||||||
|
com.aliyun.ocr20191230.models.RecognizeDrivingLicenseAdvanceRequest recognizeDrivingLicenseAdvanceRequest = new com.aliyun.ocr20191230.models.RecognizeDrivingLicenseAdvanceRequest()
|
||||||
|
.setImageURLObject(inputStream)
|
||||||
|
.setSide("face");
|
||||||
|
com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
|
||||||
|
RecognizeDrivingLicenseResponse response = client.recognizeDrivingLicenseAdvance(recognizeDrivingLicenseAdvanceRequest, runtime);
|
||||||
|
if(response.getStatusCode()==200){
|
||||||
|
RecognizeDrivingLicenseResponseBody.RecognizeDrivingLicenseResponseBodyDataFaceResult faceResult = response.getBody().getData().getFaceResult();
|
||||||
|
|
||||||
|
XhpcUserVehicle xhpcUserVehicle=new XhpcUserVehicle();
|
||||||
|
xhpcUserVehicle.setOwner(faceResult.getOwner());
|
||||||
|
xhpcUserVehicle.setVehicleName(faceResult.getPlateNumber());
|
||||||
|
xhpcUserVehicle.setEngineNumber(faceResult.getEngineNumber());
|
||||||
|
xhpcUserVehicle.setAddress(faceResult.getAddress());
|
||||||
|
xhpcUserVehicle.setVehicleType(faceResult.getVehicleType());
|
||||||
|
xhpcUserVehicle.setModel(faceResult.getModel());
|
||||||
|
xhpcUserVehicle.setRegisterDate(faceResult.getRegisterDate());
|
||||||
|
xhpcUserVehicle.setLssueDate(faceResult.getRegisterDate());
|
||||||
|
xhpcUserVehicle.setUseCharacter(faceResult.getUseCharacter());
|
||||||
|
xhpcUserVehicle.setVinSpecCode(faceResult.getVin());
|
||||||
|
xhpcUserVehicle.setAppUserId(appUserId);
|
||||||
|
xhpcUserVehicle.setSource(source);
|
||||||
|
xhpcUserVehicle.setDelFlag(1);
|
||||||
|
|
||||||
|
xhpcUserVehicleService.addUserVehicle(xhpcUserVehicle);
|
||||||
|
|
||||||
|
Map<String,Object> map =new HashMap<>();
|
||||||
|
map.put("vinSpecCode",faceResult.getVin());
|
||||||
|
map.put("vehicleName",faceResult.getPlateNumber());
|
||||||
|
map.put("vehicleId",xhpcUserVehicle.getVehicleId());
|
||||||
|
|
||||||
|
redisService.setCacheObject("vehicle:userId:"+appUserId+source,number+1);
|
||||||
|
|
||||||
|
return R.ok(map);
|
||||||
|
}else{
|
||||||
|
return R.fail("请重新上传行驶证");
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
|
||||||
|
}
|
||||||
|
return R.fail("请重新上传行驶证");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static com.aliyun.ocr20191230.Client createClient(String accessKeyId, String accessKeySecret) throws Exception {
|
||||||
|
com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
|
||||||
|
.setAccessKeyId(accessKeyId)
|
||||||
|
.setAccessKeySecret(accessKeySecret);
|
||||||
|
// 访问的域名
|
||||||
|
config.endpoint = "ocr.cn-shanghai.aliyuncs.com";
|
||||||
|
return new com.aliyun.ocr20191230.Client(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
//每天凌晨自动清除自动识别缓存
|
||||||
|
@Scheduled(cron = "0 0 23 * * ? ")
|
||||||
|
@GetMapping("/realtimeVehicleDedis")
|
||||||
|
public R realtimeVehicleDedis() {
|
||||||
|
logger.info("清除缓存>>>>>vehicle:userId::");
|
||||||
|
Collection<String> realtimeOrder = REDIS.keys("vehicle:userId:*");
|
||||||
|
for (String okey : realtimeOrder) {
|
||||||
|
redisService.deleteObject(okey);
|
||||||
|
}
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
package com.xhpc.user.controller;
|
package com.xhpc.user.controller;
|
||||||
|
|
||||||
|
import com.aliyun.ocr20191230.models.RecognizeDrivingLicenseResponse;
|
||||||
|
import com.aliyun.ocr20191230.models.RecognizeDrivingLicenseResponseBody;
|
||||||
import com.xhpc.common.core.domain.R;
|
import com.xhpc.common.core.domain.R;
|
||||||
import com.xhpc.common.core.web.controller.BaseController;
|
import com.xhpc.common.core.web.controller.BaseController;
|
||||||
import com.xhpc.common.core.web.page.TableDataInfo;
|
import com.xhpc.common.core.web.page.TableDataInfo;
|
||||||
@ -10,6 +12,9 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -21,6 +26,8 @@ import java.util.Map;
|
|||||||
@RequestMapping("/xhpc/userVehicle")
|
@RequestMapping("/xhpc/userVehicle")
|
||||||
public class XhpcUserVehicleConeroller extends BaseController {
|
public class XhpcUserVehicleConeroller extends BaseController {
|
||||||
|
|
||||||
|
public static final String accessKeyId = "LTAI5t6Nr7MdNjMN4xNvgo1W";
|
||||||
|
public static final String accessKeySecret = "hXQopkhlny10aiBBEFia2dHu6RHCqV";
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
IXhpcUserVehicleService xhpcUserVehicleService;
|
IXhpcUserVehicleService xhpcUserVehicleService;
|
||||||
@ -31,10 +38,82 @@ public class XhpcUserVehicleConeroller extends BaseController {
|
|||||||
return xhpcUserVehicleService.addUserVehicle(xhpcUserVehicle);
|
return xhpcUserVehicleService.addUserVehicle(xhpcUserVehicle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//小程序用户车牌列表
|
||||||
|
@GetMapping("/getUserVehicleList")
|
||||||
|
public TableDataInfo getUserVehicleList(HttpServletRequest request,Long appUserId,Integer source) {
|
||||||
|
List<Map<String, Object>> list = xhpcUserVehicleService.getUserVehicleList(request,appUserId,source);
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//后端
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo list(HttpServletRequest request, String vehicleName, String phone,String chargingStationName) {
|
public TableDataInfo list(HttpServletRequest request, String vehicleName, String phone,String chargingStationName) {
|
||||||
List<Map<String, Object>> list = xhpcUserVehicleService.list(request,vehicleName,phone,chargingStationName);
|
List<Map<String, Object>> list = xhpcUserVehicleService.list(request,vehicleName,phone,chargingStationName);
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation("阿里云自动识别行驶证")
|
||||||
|
@GetMapping("/addUserVehicleUrl")
|
||||||
|
public R addUserVehicleUrl(String url,Long appUserId,Integer source){
|
||||||
|
try {
|
||||||
|
com.aliyun.ocr20191230.Client client = createClient(accessKeyId, accessKeySecret);
|
||||||
|
URL urls = new URL(url);
|
||||||
|
InputStream inputStream = urls.openConnection().getInputStream();
|
||||||
|
com.aliyun.ocr20191230.models.RecognizeDrivingLicenseAdvanceRequest recognizeDrivingLicenseAdvanceRequest = new com.aliyun.ocr20191230.models.RecognizeDrivingLicenseAdvanceRequest()
|
||||||
|
.setImageURLObject(inputStream)
|
||||||
|
.setSide("face");
|
||||||
|
com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
|
||||||
|
RecognizeDrivingLicenseResponse response = client.recognizeDrivingLicenseAdvance(recognizeDrivingLicenseAdvanceRequest, runtime);
|
||||||
|
if(response.getStatusCode()==200){
|
||||||
|
RecognizeDrivingLicenseResponseBody.RecognizeDrivingLicenseResponseBodyDataFaceResult faceResult = response.getBody().getData().getFaceResult();
|
||||||
|
|
||||||
|
XhpcUserVehicle xhpcUserVehicle=new XhpcUserVehicle();
|
||||||
|
xhpcUserVehicle.setOwner(faceResult.getOwner());
|
||||||
|
xhpcUserVehicle.setVehicleName(faceResult.getPlateNumber());
|
||||||
|
xhpcUserVehicle.setEngineNumber(faceResult.getEngineNumber());
|
||||||
|
xhpcUserVehicle.setAddress(faceResult.getAddress());
|
||||||
|
xhpcUserVehicle.setVehicleType(faceResult.getVehicleType());
|
||||||
|
xhpcUserVehicle.setModel(faceResult.getModel());
|
||||||
|
xhpcUserVehicle.setRegisterDate(faceResult.getRegisterDate());
|
||||||
|
xhpcUserVehicle.setLssueDate(faceResult.getRegisterDate());
|
||||||
|
xhpcUserVehicle.setUseCharacter(faceResult.getUseCharacter());
|
||||||
|
xhpcUserVehicle.setVinSpecCode(faceResult.getVin());
|
||||||
|
xhpcUserVehicle.setAppUserId(appUserId);
|
||||||
|
xhpcUserVehicle.setSource(source);
|
||||||
|
xhpcUserVehicle.setDelFlag(1);
|
||||||
|
|
||||||
|
xhpcUserVehicleService.addUserVehicle(xhpcUserVehicle);
|
||||||
|
|
||||||
|
Map<String,Object> map =new HashMap<>();
|
||||||
|
map.put("vinSpecCode",faceResult.getVin());
|
||||||
|
map.put("vehicleName",faceResult.getPlateNumber());
|
||||||
|
map.put("vehicleId",xhpcUserVehicle.getVehicleId());
|
||||||
|
return R.ok(map);
|
||||||
|
}else{
|
||||||
|
return R.fail("请重新上传行驶证");
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
|
||||||
|
}
|
||||||
|
return R.fail("请重新上传行驶证");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static com.aliyun.ocr20191230.Client createClient(String accessKeyId, String accessKeySecret) throws Exception {
|
||||||
|
/*
|
||||||
|
初始化配置对象com.aliyun.teaopenapi.models.Config
|
||||||
|
Config对象存放 AccessKeyId、AccessKeySecret、endpoint等配置
|
||||||
|
*/
|
||||||
|
com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
|
||||||
|
.setAccessKeyId(accessKeyId)
|
||||||
|
.setAccessKeySecret(accessKeySecret);
|
||||||
|
// 访问的域名
|
||||||
|
config.endpoint = "ocr.cn-shanghai.aliyuncs.com";
|
||||||
|
return new com.aliyun.ocr20191230.Client(config);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,21 +22,66 @@ public class XhpcUserVehicle extends BaseEntity {
|
|||||||
private Long chargingStationId;
|
private Long chargingStationId;
|
||||||
|
|
||||||
private Integer source;
|
private Integer source;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 即插即充是否开通 0未开通 1开通
|
||||||
|
*/
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* VIN码
|
||||||
|
*/
|
||||||
|
private String vinSpecCode;
|
||||||
/**
|
/**
|
||||||
* 车牌
|
* 车牌
|
||||||
*/
|
*/
|
||||||
@Length(max = 10, message = "车牌不能超过10位")
|
@Length(max = 10, message = "车牌不能超过10位")
|
||||||
private String vehicleName;
|
private String vehicleName;
|
||||||
/**
|
/**
|
||||||
* 1.小型纯电车 2.小型混动电车 3.大型纯电车
|
* 是否为默认车辆 0不默认 1默认
|
||||||
*/
|
*/
|
||||||
private Integer type;
|
private Integer type;
|
||||||
/**
|
/**
|
||||||
* 删除标志(0代表存在 2代表删除)
|
* 删除标志(0代表存在 1代表删除)
|
||||||
*/
|
*/
|
||||||
private String delFlag;
|
private Integer delFlag;
|
||||||
|
|
||||||
|
|
||||||
private String tenantId;
|
private String tenantId;
|
||||||
|
/**
|
||||||
|
* 行驶证用户名称
|
||||||
|
*/
|
||||||
|
private String owner;
|
||||||
|
/**
|
||||||
|
* 发动机编号
|
||||||
|
*/
|
||||||
|
private String engineNumber;
|
||||||
|
/**
|
||||||
|
* 住址
|
||||||
|
*/
|
||||||
|
private String address;
|
||||||
|
/**
|
||||||
|
* 车辆类型
|
||||||
|
*/
|
||||||
|
private String vehicleType;
|
||||||
|
/**
|
||||||
|
* 品牌型号
|
||||||
|
*/
|
||||||
|
private String model;
|
||||||
|
/**
|
||||||
|
* 注册日期
|
||||||
|
*/
|
||||||
|
private String registerDate;
|
||||||
|
/**
|
||||||
|
* 发证日期
|
||||||
|
*/
|
||||||
|
private String lssueDate;
|
||||||
|
/**
|
||||||
|
* 使用性质
|
||||||
|
*/
|
||||||
|
private String useCharacter;
|
||||||
|
/**
|
||||||
|
* 图片地址
|
||||||
|
*/
|
||||||
|
private String url;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,5 +21,12 @@ public interface XhpcUserVehicleMapper {
|
|||||||
|
|
||||||
List<Map<String, Object>> list(@Param("vehicleName") String vehicleName,@Param("phone") String phone,@Param("chargingStationName")String chargingStationName,@Param("logOperatorId")Long logOperatorId,@Param("type")Integer type,@Param("tenantId")String tenantId);
|
List<Map<String, Object>> list(@Param("vehicleName") String vehicleName,@Param("phone") String phone,@Param("chargingStationName")String chargingStationName,@Param("logOperatorId")Long logOperatorId,@Param("type")Integer type,@Param("tenantId")String tenantId);
|
||||||
|
|
||||||
Map<String, Object> getXhpcUserVehicleMessage(@Param("userId") Long userId,@Param("source") Integer source);
|
List<Map<String, Object>> getUserVehicleList(@Param("userId") Long userId,@Param("source") Integer source,@Param("tenantId") String tenantId);
|
||||||
|
Map<String, Object> getXhpcUserVehicleMessage(@Param("userId") Long userId,@Param("source") Integer source,@Param("type") Integer type);
|
||||||
|
|
||||||
|
//查询是否有录入的数据
|
||||||
|
int xhpcUserVehicleInformation(@Param("userId") Long userId,@Param("source") Integer source,@Param("deFlag") Integer deFlag);
|
||||||
|
|
||||||
|
//查询黑名单
|
||||||
|
int getVinBlacklist(@Param("vinSpecCode") String vinSpecCode);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,5 +17,7 @@ public interface IXhpcUserVehicleService {
|
|||||||
|
|
||||||
List<Map<String, Object>> list(HttpServletRequest request,String vehicleName,String phone,String chargingStationName);
|
List<Map<String, Object>> list(HttpServletRequest request,String vehicleName,String phone,String chargingStationName);
|
||||||
|
|
||||||
|
List<Map<String, Object>> getUserVehicleList(HttpServletRequest request,Long userId,Integer source);
|
||||||
|
|
||||||
R getXhpcUserVehicleMessage(Long userId,Integer source);
|
R getXhpcUserVehicleMessage(Long userId,Integer source);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,11 +32,23 @@ public class XhpcUserVehicleServiceImpl extends BaseService implements IXhpcUser
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public R addUserVehicle(XhpcUserVehicle xhpcUserVehicle) {
|
public R addUserVehicle(XhpcUserVehicle xhpcUserVehicle) {
|
||||||
|
|
||||||
|
//查询VIN是否在黑名单
|
||||||
|
if(xhpcUserVehicle.getVinSpecCode() !=null || !"".equals(xhpcUserVehicle.getVinSpecCode())){
|
||||||
|
int vinBlacklist = xhpcUserVehicleMapper.getVinBlacklist(xhpcUserVehicle.getVinSpecCode());
|
||||||
|
if(vinBlacklist>0){
|
||||||
|
return R.fail("请联系客服添加VIN码");
|
||||||
|
}
|
||||||
|
}
|
||||||
//标记该用户其他车牌号为空
|
//标记该用户其他车牌号为空
|
||||||
if(xhpcUserVehicle.getVehicleId() !=null){
|
if(xhpcUserVehicle.getVehicleId() !=null){
|
||||||
|
xhpcUserVehicle.setDelFlag(0);
|
||||||
xhpcUserVehicleMapper.updateUserVehicle(xhpcUserVehicle);
|
xhpcUserVehicleMapper.updateUserVehicle(xhpcUserVehicle);
|
||||||
}else{
|
}else{
|
||||||
xhpcUserVehicleMapper.deleteUserVehicle(xhpcUserVehicle.getAppUserId(),xhpcUserVehicle.getVehicleId(),xhpcUserVehicle.getSource());
|
int i = xhpcUserVehicleMapper.xhpcUserVehicleInformation(xhpcUserVehicle.getAppUserId(), xhpcUserVehicle.getSource(), 0);
|
||||||
|
if(i==0){
|
||||||
|
xhpcUserVehicle.setType(1);
|
||||||
|
}
|
||||||
xhpcUserVehicleMapper.addUserVehicle(xhpcUserVehicle);
|
xhpcUserVehicleMapper.addUserVehicle(xhpcUserVehicle);
|
||||||
}
|
}
|
||||||
return R.ok();
|
return R.ok();
|
||||||
@ -69,8 +81,21 @@ public class XhpcUserVehicleServiceImpl extends BaseService implements IXhpcUser
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Map<String, Object>> getUserVehicleList(HttpServletRequest request,Long userId,Integer source) {
|
||||||
|
//获取登陆用户
|
||||||
|
LoginUser loginUser = tokenService.getLoginUser(request);
|
||||||
|
String tenantId = loginUser.getTenantId();
|
||||||
|
List<Map<String, Object>> list = xhpcUserVehicleMapper.getUserVehicleList(userId,source,tenantId);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public R getXhpcUserVehicleMessage(Long userId, Integer source) {
|
public R getXhpcUserVehicleMessage(Long userId, Integer source) {
|
||||||
return R.ok(xhpcUserVehicleMapper.getXhpcUserVehicleMessage(userId,source));
|
Map<String, Object> map = xhpcUserVehicleMapper.getXhpcUserVehicleMessage(userId, source, 1);
|
||||||
|
if(map == null){
|
||||||
|
return R.ok(xhpcUserVehicleMapper.getXhpcUserVehicleMessage(userId, source, null));
|
||||||
|
}
|
||||||
|
return R.ok(map);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,6 +18,16 @@
|
|||||||
<result column="tenant_id" property="tenantId"/>
|
<result column="tenant_id" property="tenantId"/>
|
||||||
<result column="charging_station_id" property="chargingStationId"/>
|
<result column="charging_station_id" property="chargingStationId"/>
|
||||||
<result column="source" property="source"/>
|
<result column="source" property="source"/>
|
||||||
|
<result column="status" property="status"/>
|
||||||
|
<result column="vin_spec_code" property="vinSpecCode"/>
|
||||||
|
<result column="owner" property="owner"/>
|
||||||
|
<result column="engine_number" property="engineNumber"/>
|
||||||
|
<result column="address" property="address"/>
|
||||||
|
<result column="vehicle_type" property="vehicleType"/>
|
||||||
|
<result column="model" property="model"/>
|
||||||
|
<result column="register_date" property="registerDate"/>
|
||||||
|
<result column="lssue_date" property="lssueDate"/>
|
||||||
|
<result column="use_character" property="useCharacter"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<update id="deleteUserVehicle">
|
<update id="deleteUserVehicle">
|
||||||
@ -65,6 +75,20 @@
|
|||||||
</if>
|
</if>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="getUserVehicleList" resultType="map">
|
||||||
|
select
|
||||||
|
vehicle_id as vehicleId,
|
||||||
|
app_user_id as appUserId,
|
||||||
|
vehicle_name as vehicleName,
|
||||||
|
vin_spec_code as vinSpecCode,
|
||||||
|
type as type,
|
||||||
|
status as status
|
||||||
|
from xhpc_user_vehicle where source =#{source} and app_user_id =#{userId} and del_flag=0 and tenant_id=#{tenantId} order by create_time desc
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<update id="updateUserVehicle" parameterType="com.xhpc.user.domain.XhpcUserVehicle">
|
<update id="updateUserVehicle" parameterType="com.xhpc.user.domain.XhpcUserVehicle">
|
||||||
UPDATE xhpc_user_vehicle
|
UPDATE xhpc_user_vehicle
|
||||||
<set>
|
<set>
|
||||||
@ -73,7 +97,10 @@
|
|||||||
<if test="chargingStationId != null ">charging_station_id =#{chargingStationId},</if>
|
<if test="chargingStationId != null ">charging_station_id =#{chargingStationId},</if>
|
||||||
<if test="null != vehicleName and '' != vehicleName">vehicle_name = #{vehicleName},</if>
|
<if test="null != vehicleName and '' != vehicleName">vehicle_name = #{vehicleName},</if>
|
||||||
<if test="null != type ">type = #{type},</if>
|
<if test="null != type ">type = #{type},</if>
|
||||||
<if test="null != remark and '' != remark">remark = #{remark}</if>
|
<if test="null != remark and '' != remark">remark = #{remark},</if>
|
||||||
|
<if test="status != null ">status,</if>
|
||||||
|
<if test="vinSpecCode != null and vinSpecCode !=''">vin_spec_code= #{vinSpecCode},</if>
|
||||||
|
<if test="delFlag != null ">del_flag= #{delFlag},</if>
|
||||||
</set>
|
</set>
|
||||||
WHERE vehicle_id = #{vehicleId}
|
WHERE vehicle_id = #{vehicleId}
|
||||||
</update>
|
</update>
|
||||||
@ -92,6 +119,17 @@
|
|||||||
<if test="updateTime != null ">update_time,</if>
|
<if test="updateTime != null ">update_time,</if>
|
||||||
<if test="remark != null and remark != ''">remark,</if>
|
<if test="remark != null and remark != ''">remark,</if>
|
||||||
<if test="tenantId != null ">tenant_id,</if>
|
<if test="tenantId != null ">tenant_id,</if>
|
||||||
|
<if test="status != null ">status,</if>
|
||||||
|
<if test="vinSpecCode != null and vinSpecCode !=''">vin_spec_code,</if>
|
||||||
|
<if test="owner != null and owner !=''">owner,</if>
|
||||||
|
<if test="engineNumber != null and engineNumber !=''">engine_number,</if>
|
||||||
|
<if test="address != null and address !=''">address,</if>
|
||||||
|
<if test="vehicleType != null and vehicleType !=''">vehicle_type,</if>
|
||||||
|
<if test="model != null and model !=''">model,</if>
|
||||||
|
<if test="registerDate != null and registerDate !=''">register_date,</if>
|
||||||
|
<if test="lssueDate != null and lssueDate !=''">lssue_date,</if>
|
||||||
|
<if test="useCharacter != null and useCharacter !=''">use_character,</if>
|
||||||
|
<if test="url != null and url !=''">url,</if>
|
||||||
create_time
|
create_time
|
||||||
)
|
)
|
||||||
values(
|
values(
|
||||||
@ -106,6 +144,17 @@
|
|||||||
<if test="updateTime != null ">#{updateTime},</if>
|
<if test="updateTime != null ">#{updateTime},</if>
|
||||||
<if test="remark != null and remark != ''">#{remark},</if>
|
<if test="remark != null and remark != ''">#{remark},</if>
|
||||||
<if test="tenantId != null ">#{tenantId},</if>
|
<if test="tenantId != null ">#{tenantId},</if>
|
||||||
|
<if test="status != null ">#{status},</if>
|
||||||
|
<if test="vinSpecCode != null and vinSpecCode !=''">#{vinSpecCode},</if>
|
||||||
|
<if test="owner != null and owner !=''">#{owner},</if>
|
||||||
|
<if test="engineNumber != null and engineNumber !=''">#{engineNumber},</if>
|
||||||
|
<if test="address != null and address !=''">#{address},</if>
|
||||||
|
<if test="vehicleType != null and vehicleType !=''">#{vehicleType},</if>
|
||||||
|
<if test="model != null and model !=''">#{model},</if>
|
||||||
|
<if test="registerDate != null and registerDate !=''">#{registerDate},</if>
|
||||||
|
<if test="lssueDate != null and lssueDate !=''">#{lssueDate},</if>
|
||||||
|
<if test="useCharacter != null and useCharacter !=''">#{useCharacter},</if>
|
||||||
|
<if test="url != null and url !=''">#{url},</if>
|
||||||
sysdate()
|
sysdate()
|
||||||
)
|
)
|
||||||
</insert>
|
</insert>
|
||||||
@ -114,7 +163,24 @@
|
|||||||
select
|
select
|
||||||
vehicle_id as vehicleId,
|
vehicle_id as vehicleId,
|
||||||
app_user_id as appUserId,
|
app_user_id as appUserId,
|
||||||
vehicle_name as vehicleName
|
vehicle_name as vehicleName,
|
||||||
|
vin_spec_code as vinSpecCode,
|
||||||
|
type as type,
|
||||||
|
status as status
|
||||||
from xhpc_user_vehicle where source =#{source} and app_user_id =#{userId} and del_flag=0
|
from xhpc_user_vehicle where source =#{source} and app_user_id =#{userId} and del_flag=0
|
||||||
|
<if test="type !=null">
|
||||||
|
and type =#{type}
|
||||||
|
</if>
|
||||||
|
|
||||||
|
order by create_time desc limit 1
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
<select id="xhpcUserVehicleInformation" resultType="int">
|
||||||
|
select count(vehicle_id) from xhpc_user_vehicle where source =#{source} and app_user_id =#{userId} and del_flag=#{deFlag}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="getVinBlacklist" resultType="int">
|
||||||
|
select count(vehicle_id) from xhpc_user_vehicle where vin_spec_code =#{vinSpecCode} and vin_blacklist =1
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user