修改VIN充电逻辑

This commit is contained in:
18123374652 2024-03-13 14:21:10 +08:00
parent bbd90511d3
commit 66fe25d4e3
6 changed files with 86 additions and 17 deletions

View File

@ -612,8 +612,8 @@ public class XhpcAppUserController extends BaseController {
//小程序用户车牌列表
@ApiOperation("小程序用户车牌列表")
@GetMapping("/getUserVehicleList")
public TableDataInfo getUserVehicleList(HttpServletRequest request,Long userId,Integer source) {
List<Map<String, Object>> list = xhpcUserVehicleService.getUserVehicleList(request,userId,source);
public TableDataInfo getUserVehicleList(HttpServletRequest request,Long appUserId,Integer source) {
List<Map<String, Object>> list = xhpcUserVehicleService.getUserVehicleList(request,appUserId,source);
return getDataTable(list);
}
@ -624,7 +624,7 @@ public class XhpcAppUserController extends BaseController {
//同一个用户一天只有10次机会
Integer number = redisService.getCacheObject("vehicle:userId:"+appUserId+source);
if(number>10){
if(number !=null && number>10){
return R.fail("今天开通VIN码自动识别已达到上线,请手动输入车牌号和VIN开通");
}
com.aliyun.ocr20191230.Client client = createClient(accessKeyId, accessKeySecret);
@ -660,14 +660,17 @@ public class XhpcAppUserController extends BaseController {
map.put("vehicleName",faceResult.getPlateNumber());
map.put("vehicleId",xhpcUserVehicle.getVehicleId());
if(number==null){
redisService.setCacheObject("vehicle:userId:"+appUserId+source,1);
}else{
redisService.setCacheObject("vehicle:userId:"+appUserId+source,number+1);
}
return R.ok(map);
}else{
return R.fail("请重新上传行驶证");
}
}catch (Exception e){
e.printStackTrace();
}
return R.fail("请重新上传行驶证");
}
@ -694,5 +697,23 @@ public class XhpcAppUserController extends BaseController {
}
@ApiOperation("删除VIN或者车牌接口")
@PostMapping("/deleteUserVehicleById")
public R deleteUserVehicleById(@RequestBody XhpcUserVehicle xhpcUserVehicle){
return xhpcUserVehicleService.deleteUserVehicleById(xhpcUserVehicle.getVehicleId());
}
@ApiOperation("默认车辆")
@PostMapping("/defaultUserVehicle")
public R defaultUserVehicle(@RequestBody XhpcUserVehicle xhpcUserVehicle){
return xhpcUserVehicleService.defaultUserVehicle(xhpcUserVehicle.getVehicleId(),xhpcUserVehicle.getAppUserId(),xhpcUserVehicle.getSource());
}
@ApiOperation("开通VIN码")
@PostMapping("/enlightenedUserVehicle")
public R enlightenedUserVehicle(@RequestBody XhpcUserVehicle xhpcUserVehicle){
return xhpcUserVehicleService.enlightenedUserVehicle(xhpcUserVehicle.getVehicleId(),xhpcUserVehicle.getAppUserId(),xhpcUserVehicle.getSource(),xhpcUserVehicle.getStatus());
}
}

View File

@ -29,4 +29,12 @@ public interface XhpcUserVehicleMapper {
//查询黑名单
int getVinBlacklist(@Param("vinSpecCode") String vinSpecCode);
int deleteUserVehicleById(@Param("vehicleId")Long vehicleId);
int defaultUserVehicle(@Param("vehicleId")Long vehicleId);
int defaultUserVehicleList(@Param("vehicleId")Long vehicleId,@Param("userId") Long userId,@Param("source") Integer source);
int enlightenedUserVehicle(@Param("vehicleId")Long vehicleId,@Param("status") Integer status);
}

View File

@ -20,4 +20,10 @@ public interface IXhpcUserVehicleService {
List<Map<String, Object>> getUserVehicleList(HttpServletRequest request,Long userId,Integer source);
R getXhpcUserVehicleMessage(Long userId,Integer source);
R deleteUserVehicleById(Long vehicleId);
R defaultUserVehicle(Long vehicleId,Long appUserId,Integer source);
R enlightenedUserVehicle(Long vehicleId,Long appUserId,Integer source,Integer stauts);
}

View File

@ -84,9 +84,9 @@ public class XhpcUserVehicleServiceImpl extends BaseService implements IXhpcUser
@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);
// LoginUser loginUser = tokenService.getLoginUser(request);
// String tenantId = loginUser.getTenantId();
List<Map<String, Object>> list = xhpcUserVehicleMapper.getUserVehicleList(userId,source,"");
return list;
}
@ -98,4 +98,24 @@ public class XhpcUserVehicleServiceImpl extends BaseService implements IXhpcUser
}
return R.ok(map);
}
@Override
public R deleteUserVehicleById(Long vehicleId) {
xhpcUserVehicleMapper.deleteUserVehicleById(vehicleId);
return R.ok();
}
@Override
public R defaultUserVehicle(Long vehicleId, Long appUserId, Integer source) {
xhpcUserVehicleMapper.defaultUserVehicleList(vehicleId,appUserId,source);
xhpcUserVehicleMapper.defaultUserVehicle(vehicleId);
return R.ok();
}
@Override
public R enlightenedUserVehicle(Long vehicleId, Long appUserId, Integer source,Integer stauts) {
xhpcUserVehicleMapper.enlightenedUserVehicle(vehicleId,stauts);
return R.ok();
}
}

View File

@ -28,11 +28,10 @@
xau.tenant_id tenantId,
xau.soc_protect socProtect,
ten.status tenantStatus,
xuv.vehicle_name as vehicleName,
(select vehicle_name as vehicleName from xhpc_user_vehicle where app_user_id = xau.app_user_id and source=0 and del_flag=0 and vin_blacklist !=1 order by type,create_time desc LIMIT 1) as vehicleName,
xau.create_time as createTime
from xhpc_app_user xau
left join xhpc_tenant ten on ten.tenant_id = xau.tenant_id and ten.is_deleted =0
left join xhpc_user_vehicle xuv on xuv.app_user_id = xau.app_user_id and xuv.source=0 and xuv.del_flag=0
where xau.del_flag=0
<if test="phone !=null and phone !=''">
and xau.phone =#{phone}
@ -43,6 +42,7 @@
<if test="tenantId !=null and tenantId !=''">
and xau.tenant_id =#{tenantId}
</if>
</select>
<select id="getCommunityUser" resultType="map">
@ -66,14 +66,13 @@
xcp.soc_protect socProtect,
ten.status tenantStatus,
concat("ST") as userTypeName,
xuv.vehicle_name as vehicleName,
(select vehicle_name as vehicleName from xhpc_user_vehicle where app_user_id = xau.app_user_id and source=2 and del_flag=0 and vin_blacklist !=1 order by type,create_time desc LIMIT 1) as vehicleName,
<if test="serialNumber !=null and serialNumber !=''">
(select count(charging_station_id) from xhpc_mechanism where community_id=mechanism_id and source=0 and charging_station_id in (select charging_station_id from xhpc_terminal where 1=1 and del_flag=0 and serial_number=#{serialNumber})) as number,
</if>
xcp.create_time as createTime
from xhpc_community_personnel xcp
left join xhpc_tenant ten on ten.tenant_id = xcp.tenant_id and ten.is_deleted =0
left join xhpc_user_vehicle xuv on xuv.app_user_id = xcp.community_personnel_id and xuv.source=2 and xuv.del_flag=0
where xcp.del_flag=0
<if test="phone !=null and phone !=''">
and xcp.account =#{phone}
@ -107,14 +106,13 @@
xcp.soc_protect socProtect,
ten.status tenantStatus,
concat("BE") as userTypeName,
xuv.vehicle_name as vehicleName,
(select vehicle_name as vehicleName from xhpc_user_vehicle where app_user_id = xau.app_user_id and source=3 and del_flag=0 and vin_blacklist !=1 order by type,create_time desc LIMIT 1) as vehicleName,
<if test="serialNumber !=null and serialNumber !=''">
(select count(charging_station_id) from xhpc_mechanism where customers_id=mechanism_id and source=1 and charging_station_id in (select charging_station_id from xhpc_terminal where 1=1 and del_flag=0 and serial_number=#{serialNumber})) as number,
</if>
xcp.create_time as createTime
from xhpc_customers_personnel xcp
left join xhpc_tenant ten on ten.tenant_id = xcp.tenant_id and ten.is_deleted =0
left join xhpc_user_vehicle xuv on xuv.app_user_id = xcp.customers_personnel_id and xuv.source=3 and xuv.del_flag=0
where xcp.del_flag=0
<if test="phone !=null and phone !=''">
and xcp.account =#{phone}

View File

@ -83,7 +83,7 @@
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
from xhpc_user_vehicle where source =#{source} and app_user_id =#{userId} and del_flag=0 order by create_time desc
</select>
@ -183,4 +183,20 @@
<select id="getVinBlacklist" resultType="int">
select count(vehicle_id) from xhpc_user_vehicle where vin_spec_code =#{vinSpecCode} and vin_blacklist =1
</select>
<update id="deleteUserVehicleById">
update xhpc_user_vehicle set del_flag =1 where vehicle_id =#{vehicleId}
</update>
<update id="defaultUserVehicle">
update xhpc_user_vehicle set type =1 where vehicle_id =#{vehicleId}
</update>
<update id="defaultUserVehicleList">
update xhpc_user_vehicle set type =0 where vehicle_id !=#{vehicleId} and source =#{source} and app_user_id =#{userId}
</update>
<update id="enlightenedUserVehicle">
update xhpc_user_vehicle set status =#{status} where vehicle_id =#{vehicleId}
</update>
</mapper>