|
@@ -28,6 +28,7 @@ import org.bouncycastle.crypto.signers.ECDSASigner;
|
|
import org.joda.time.DateTime;
|
|
import org.joda.time.DateTime;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
+import org.springframework.data.redis.core.ValueOperations;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
@@ -81,6 +82,9 @@ public class DriverApiController {
|
|
@Autowired
|
|
@Autowired
|
|
private VehicleInfoService vehicleInfoService;
|
|
private VehicleInfoService vehicleInfoService;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private ValueOperations<String,Object> valueOperations;
|
|
|
|
+
|
|
@PostMapping("carActivation")
|
|
@PostMapping("carActivation")
|
|
@ApiOperation(value = "司机端激活")
|
|
@ApiOperation(value = "司机端激活")
|
|
@ApiImplicitParams({
|
|
@ApiImplicitParams({
|
|
@@ -449,31 +453,40 @@ public class DriverApiController {
|
|
String photoBase64Data = requestBody.getString("photoBase64Data");
|
|
String photoBase64Data = requestBody.getString("photoBase64Data");
|
|
String recordTime = requestBody.getString("recordTime");
|
|
String recordTime = requestBody.getString("recordTime");
|
|
|
|
|
|
- VehicleInfo vehicleInfo = vehicleInfoService.get(subject);
|
|
|
|
- if (vehicleInfo == null){
|
|
|
|
- throw new Exception("当前车辆不存在");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- List<ShiftInfo> shiftInfoList = shiftInfoService.findByVehicleIdAndStatus(vehicleInfo.getId(),"1");
|
|
|
|
- if (shiftInfoList.size() == 0){
|
|
|
|
- throw new Exception("车辆没有相关班次信息");
|
|
|
|
- }
|
|
|
|
|
|
+ //同一辆车相同乘客上下车登记间隔1分钟
|
|
|
|
+ String key = subject + "_" + personId;
|
|
|
|
+ boolean absent = valueOperations.setIfAbsent(key,true,1,TimeUnit.MINUTES);
|
|
|
|
|
|
- ShiftInfo shiftInfo = shiftInfoList.get(0);
|
|
|
|
|
|
+ if(absent) {
|
|
|
|
+ VehicleInfo vehicleInfo = vehicleInfoService.get(subject);
|
|
|
|
+ if (vehicleInfo == null){
|
|
|
|
+ throw new Exception("当前车辆不存在");
|
|
|
|
+ }
|
|
|
|
|
|
- String retFileUrl = "";
|
|
|
|
|
|
+ List<ShiftInfo> shiftInfoList = shiftInfoService.findByVehicleIdAndStatus(vehicleInfo.getId(),"1");
|
|
|
|
+ if (shiftInfoList.size() == 0){
|
|
|
|
+ throw new Exception("车辆没有相关班次信息");
|
|
|
|
+ }
|
|
|
|
|
|
- //只有第一次上车时返回登记照
|
|
|
|
- if(StringUtils.isNotEmpty(photoBase64Data)){
|
|
|
|
- retFileUrl = OSSUtil.uploadBase64(photoBase64Data,personId+".jpg",ossConfig);
|
|
|
|
- }
|
|
|
|
|
|
+ ShiftInfo shiftInfo = shiftInfoList.get(0);
|
|
|
|
+ String retFileUrl = "";
|
|
|
|
|
|
- passengerInfoService.passengerFace(vehicleInfo,shiftInfo,retFileUrl,recordTime,shiftInfo.getCurrentStationId(),personId);
|
|
|
|
|
|
+ //只有第一次上车时返回登记照
|
|
|
|
+ if(StringUtils.isNotEmpty(photoBase64Data)){
|
|
|
|
+ retFileUrl = OSSUtil.uploadBase64(photoBase64Data,personId+".jpg",ossConfig);
|
|
|
|
+ }
|
|
|
|
|
|
- messageResult.setResult(true);
|
|
|
|
- messageResult.setCode(200);
|
|
|
|
|
|
+ passengerInfoService.passengerFace(vehicleInfo, shiftInfo, retFileUrl, recordTime, shiftInfo.getCurrentStationId(), personId);
|
|
|
|
+ messageResult.setResult(true);
|
|
|
|
+ messageResult.setCode(200);
|
|
|
|
+ }
|
|
|
|
+ else{
|
|
|
|
+ messageResult.setResult(false);
|
|
|
|
+ messageResult.setMessage("乘客刷脸过于频繁,不重复登记!");
|
|
|
|
+ }
|
|
} catch (Exception ex) {
|
|
} catch (Exception ex) {
|
|
log.error(ex.getMessage(),ex);
|
|
log.error(ex.getMessage(),ex);
|
|
|
|
+
|
|
messageResult.setResult(false);
|
|
messageResult.setResult(false);
|
|
messageResult.setMessage(ex.getMessage());
|
|
messageResult.setMessage(ex.getMessage());
|
|
}
|
|
}
|