Merge branch 'master' of http://120.76.84.145:10101/gitblit/r/java/mx_charging_pile into dev
| | |
| | | |
| | | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.ruoyi.account.api.dto.CouponListDto; |
| | | import com.ruoyi.account.api.dto.GrantCouponDto; |
| | |
| | | @PostMapping(value = "/scan/addCar") |
| | | public AjaxResult addCar(@RequestBody TAppUserCar dto) { |
| | | dto.setAppUserId(tokenService.getLoginUserApplet().getUserId()); |
| | | TAppUserCar one = appUserCarService.getOne(new LambdaQueryWrapper<TAppUserCar>().eq(TAppUserCar::getLicensePlate, dto.getLicensePlate()) |
| | | .eq(TAppUserCar::getDelFlag, 0)); |
| | | if(null != one){ |
| | | return AjaxResult.error("车辆已存在"); |
| | | } |
| | | appUserCarService.save(dto); |
| | | return AjaxResult.success(); |
| | | } |
| | |
| | | return R.ok(collect); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 手动删除重复数据 |
| | | * @return |
| | | */ |
| | | @PostMapping(value = "/t-app-user-car/delRepetitiveVehicles") |
| | | public R delRepetitiveVehicles(){ |
| | | List<String> list = appUserCarService.queryRepetitiveVehicles(); |
| | | for (String s : list) { |
| | | List<TAppUserCar> list1 = appUserCarService.list(new LambdaQueryWrapper<TAppUserCar>().eq(TAppUserCar::getLicensePlate, s) |
| | | .eq(TAppUserCar::getDelFlag, 0).orderByDesc(TAppUserCar::getCreateTime)); |
| | | for (int i = 0; i < list1.size(); i++) { |
| | | if(i == list1.size() - 1){ |
| | | break; |
| | | } |
| | | appUserCarService.removeById(list1.get(i).getId()); |
| | | } |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | } |
| | | |
| | |
| | | return R.fail("权限不足"); |
| | | } |
| | | } |
| | | TAppUserCar one1 = appUserCarService.getOne(new LambdaQueryWrapper<TAppUserCar>().eq(TAppUserCar::getLicensePlate, appUserCar.getLicensePlate()) |
| | | .eq(TAppUserCar::getDelFlag, 0)); |
| | | if(null != one1){ |
| | | return R.fail("车辆已存在"); |
| | | } |
| | | LoginUserApplet loginUserApplet = tokenService.getLoginUserApplet(); |
| | | Long userId = loginUserApplet.getUserId(); |
| | | TAppUser byId = appUserService.getById(userId); |
| | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.ruoyi.account.api.model.TAppUserCar; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | | * Mapper 接口 |
| | |
| | | */ |
| | | public interface TAppUserCarMapper extends BaseMapper<TAppUserCar> { |
| | | |
| | | List<String> queryRepetitiveVehicles(); |
| | | |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.account.api.model.TAppUserCar; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | | * 服务类 |
| | |
| | | */ |
| | | public interface TAppUserCarService extends IService<TAppUserCar> { |
| | | |
| | | |
| | | List<String> queryRepetitiveVehicles(); |
| | | |
| | | } |
| | |
| | | import com.ruoyi.account.service.TAppUserCarService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | | * 服务实现类 |
| | |
| | | @Service |
| | | public class TAppUserCarServiceImpl extends ServiceImpl<TAppUserCarMapper, TAppUserCar> implements TAppUserCarService { |
| | | |
| | | |
| | | @Override |
| | | public List<String> queryRepetitiveVehicles() { |
| | | return this.baseMapper.queryRepetitiveVehicles(); |
| | | } |
| | | } |
| | |
| | | id, app_user_id, license_plate, vehicle_brand, vehicle_model, vehicle_use, endurance, create_time, del_flag |
| | | </sql> |
| | | |
| | | |
| | | <select id="queryRepetitiveVehicles" resultType="String"> |
| | | select license_plate from (select license_plate, count(license_plate) as num from t_app_user_car where del_flag = 0 group by license_plate) as aa where aa.num > 1 |
| | | </select> |
| | | </mapper> |
| | |
| | | }else{ |
| | | tParkingRecordVO.setFeeDuration(tParkingRecordVO.getParkingDuration()-tParkingRecordVO.getFreeDuration()); |
| | | } |
| | | tParkingRecordVO.setOrderAmount(tParkingRecordVO.getOrderAmount()!=null?tParkingRecordVO.getOrderAmount():new BigDecimal("0") |
| | | .add(tParkingRecordVO.getTimeoutAmount()!=null?tParkingRecordVO.getTimeoutAmount():new BigDecimal("0"))); |
| | | tParkingRecordVO.setParkingFee(tParkingRecordVO.getOrderAmount()); |
| | | } |
| | | pageInfo.setRecords(list); |
| | | // 查询总数 |
| | |
| | | <select id="pageList" resultType="com.ruoyi.chargingPile.api.vo.TParkingRecordVO"> |
| | | select |
| | | tpr.id, tpr.code,tpr.app_user_id, tpr.license_plate, tpr.vehicle_color, tpr.charging_order_id, tpr.parking_lot_id, tpr.in_parking_time, tpr.out_parking_time, |
| | | tpr.parking_duration, tpr.order_amount, tpr.status, tpr.out_parking_type, tpr.create_time,(tpr.order_amount + tpr.timeout_amount) as parkingFee,tpr.timeout_amount, |
| | | tpr.parking_duration, tpr.order_amount, tpr.status, tpr.out_parking_type, tpr.create_time,tpr.payment as parkingFee,(tpr.order_amount - tpr.payment) as timeout_amount, |
| | | tpr.free_duration,(tpr.parking_duration - tpr.free_duration) as feeDuration,ts.name as siteName |
| | | from t_parking_record tpr |
| | | left join t_parking_lot tpl on tpr.parking_lot_id = tpl.id |
| | |
| | | mqttClient.setCallback(new MqttCallback() { |
| | | @Override |
| | | public void connectionLost(Throwable cause) { |
| | | System.out.println("Connection lost, reconnecting..."); |
| | | log.info("Connection lost, reconnecting..."); |
| | | reconnect(); |
| | | } |
| | | |
| | | @Override |
| | | public void messageArrived(String topic, MqttMessage message) throws Exception { |
| | | System.out.println("Message arrived: " + new String(message.getPayload())); |
| | | log.info("Message arrived: " + new String(message.getPayload())); |
| | | } |
| | | |
| | | @Override |
| | | public void deliveryComplete(IMqttDeliveryToken token) { |
| | | System.out.println("Delivery complete"); |
| | | log.info("Delivery complete"); |
| | | } |
| | | }); |
| | | mqttClient.connect(options); |
| | |
| | | // 设置会话心跳时间 单位为秒 服务器会每隔1.5*20秒的时间向客户端发送个消息判断客户端是否在线,但这个方法并没有重连的机制 |
| | | options.setKeepAliveInterval(KEEP_ALIVE);//默认:60 |
| | | mqttClient.connect(options); |
| | | System.out.println("重连成功"); |
| | | log.info("重连成功"); |
| | | } catch (MqttException e) { |
| | | System.out.println("重连失败"); |
| | | log.info("重连失败"); |
| | | log.info("connectionLost e:{}", e.getMessage()); |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | message.setPayload(message1.getBytes()); |
| | | MqttTopic mTopic = mqttClient.getTopic(topic); |
| | | if (null == mTopic) { |
| | | System.err.println("topic not exist"); |
| | | log.info("topic not exist"); |
| | | log.error("topic not exist"); |
| | | } |
| | | MqttDeliveryToken token; |
| | |
| | | public TChargingOrder getChargingOrderByLicensePlate(GetChargingOrderByLicensePlate query) { |
| | | TChargingOrder one = this.getOne(new LambdaQueryWrapper<TChargingOrder>().eq(TChargingOrder::getPlateNum, query.getLicensePlate()) |
| | | .eq(TChargingOrder::getDelFlag, 0).between(TChargingOrder::getStartTime, query.getStartTime(), LocalDateTime.now()) |
| | | .eq(TChargingOrder::getRechargePaymentStatus, 2).in(TChargingOrder::getStatus, Arrays.asList(4, 5))); |
| | | .eq(TChargingOrder::getRechargePaymentStatus, 2).in(TChargingOrder::getStatus, Arrays.asList(4, 5)) |
| | | .last(" order by start_time desc limit 0, 1")); |
| | | return one; |
| | | } |
| | | |