|
|
|
@ -13,7 +13,9 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
|
|
|
|
|
|
import javax.print.attribute.standard.NumberUp;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <p>
|
|
|
|
@ -73,21 +75,20 @@ public class DriverCarBindingRelationshipService{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ResponseResult unbind(@RequestBody DriverCarBindingRelationship driverCarBindingRelationship){
|
|
|
|
|
QueryWrapper queryWrapper = new QueryWrapper();
|
|
|
|
|
queryWrapper.eq("driver_id",driverCarBindingRelationship.getDriverId());
|
|
|
|
|
queryWrapper.eq("car_id",driverCarBindingRelationship.getCarId());
|
|
|
|
|
int count = driverCarBindingRelationshipMapper.selectCount(queryWrapper);
|
|
|
|
|
Map<String, Object> queryMap = new HashMap<>();
|
|
|
|
|
queryMap.put("driver_id",driverCarBindingRelationship.getDriverId());
|
|
|
|
|
queryMap.put("car_id",driverCarBindingRelationship.getCarId());
|
|
|
|
|
queryMap.put("bind_state",DriverCarConstant.DRIVER_CAR_BIND );
|
|
|
|
|
List<DriverCarBindingRelationship> list = driverCarBindingRelationshipMapper.selectByMap(queryMap);
|
|
|
|
|
int count = list.size();
|
|
|
|
|
if(count == 1){
|
|
|
|
|
driverCarBindingRelationship = driverCarBindingRelationshipMapper.selectOne(queryWrapper);
|
|
|
|
|
if(DriverCarConstant.DRIVER_CAR_UNBIND == driverCarBindingRelationship.getBindState()){
|
|
|
|
|
return ResponseResult.success(CommonStatusEnum.DRIVER_CAR_UNBIND_EXISTS);
|
|
|
|
|
}
|
|
|
|
|
driverCarBindingRelationship = list.get(0);
|
|
|
|
|
driverCarBindingRelationship.setUnBindingTime(CommonUtils.getLocalDateTimeNow() );
|
|
|
|
|
driverCarBindingRelationship.setBindState(DriverCarConstant.DRIVER_CAR_UNBIND);
|
|
|
|
|
driverCarBindingRelationshipMapper.updateById(driverCarBindingRelationship);
|
|
|
|
|
}else if(count > 1){//排除数据库存在脏数据
|
|
|
|
|
return ResponseResult.fail(CommonStatusEnum.FAIL);
|
|
|
|
|
}else{
|
|
|
|
|
}else if(list.isEmpty()){
|
|
|
|
|
return ResponseResult.fail(CommonStatusEnum.DRIVER_CAR_BIND_NOT_EXISTS);
|
|
|
|
|
}
|
|
|
|
|
return ResponseResult.success();
|
|
|
|
|