| | |
| | | import com.doumee.api.BaseController; |
| | | import com.doumee.core.annotation.excel.ExcelExporter; |
| | | import com.doumee.core.annotation.pr.PreventRepeat; |
| | | import com.doumee.core.constants.ResponseStatus; |
| | | import com.doumee.core.exception.BusinessException; |
| | | import com.doumee.core.model.ApiResponse; |
| | | import com.doumee.core.model.PageData; |
| | | import com.doumee.core.model.PageWrap; |
| | |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.ArrayList; |
| | | import java.util.Calendar; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | |
| | | @PreventRepeat |
| | | @ApiOperation("手动同步微信某天账单信息") |
| | | @PostMapping("/syncWxBill") |
| | | // @RequiresPermissions("business:wxbill:create") |
| | | @RequiresPermissions("business:wxbill:create") |
| | | public ApiResponse syncWxBill(@RequestBody WxBill wxBill) { |
| | | wxBillService.getWxBill(wxBill.getCreateDate()); |
| | | if( wxBill.getCreateDate() == null){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime( wxBill.getCreateDate()); |
| | | calendar.set(Calendar.HOUR_OF_DAY,9); |
| | | wxBillService.getWxBill(calendar.getTime()); |
| | | return ApiResponse.success(null); |
| | | } |
| | | |
| | |
| | | } |
| | | return num; |
| | | } |
| | | public static Integer formatIntegerFromStr(String num) { |
| | | try { |
| | | return Integer.parseInt(num); |
| | | }catch (Exception e){ |
| | | |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public interface UserActionsType { |
| | | String cancelPrePay = "CANCEL_PRE_PAY"; |
| | |
| | | |
| | | @ApiModelProperty(value = "当前锁头编码(关联locks)") |
| | | @ExcelColumn(name="当前锁头编码(关联locks)") |
| | | private String lockId; |
| | | private Integer lockId; |
| | | |
| | | @ApiModelProperty(value = "最近租借时间") |
| | | @ExcelColumn(name="最近租借时间") |
| | |
| | | |
| | | @ApiModelProperty(value = "编号") |
| | | @ExcelColumn(name="编号") |
| | | private String code; |
| | | private Integer code; |
| | | |
| | | @ApiModelProperty(value = "状态,0闭合, 1打开,2运行中, 3异常", example = "1") |
| | | @ExcelColumn(name="状态,0闭合, 1打开,2运行中, 3异常") |
| | |
| | | |
| | | @ApiModelProperty(value = "租车锁头编码") |
| | | @ExcelColumn(name="租车锁具",index = 5,width = 10,align = HorizontalAlignment.CENTER) |
| | | private String rentLockId; |
| | | private Integer rentLockId; |
| | | |
| | | @ApiModelProperty(value = "租车时间") |
| | | @ExcelColumn(name="租车时间",index = 6,width = 10,align = HorizontalAlignment.CENTER) |
| | |
| | | |
| | | @ApiModelProperty(value = "还车锁头编码") |
| | | @ExcelColumn(name="归还锁具",index = 8,width = 10,align = HorizontalAlignment.CENTER) |
| | | private String backLockId; |
| | | private Integer backLockId; |
| | | |
| | | @ApiModelProperty(value = "还车时间") |
| | | private Date backDate; |
| | |
| | | .leftJoin(Sites.class,Sites::getId,Bikes::getSiteId) |
| | | .like(StringUtils.isNotBlank(pageWrap.getModel().getSiteId()),Bikes::getSiteId,pageWrap.getModel().getSiteId()) |
| | | .like(StringUtils.isNotBlank(pageWrap.getModel().getSiteName()), Sites::getName,pageWrap.getModel().getSiteName()) |
| | | .like(StringUtils.isNotBlank(pageWrap.getModel().getLockId()),Bikes::getLockId,pageWrap.getModel().getLockId()) |
| | | .like( pageWrap.getModel().getLockId() !=null,Bikes::getLockId,pageWrap.getModel().getLockId()) |
| | | .ne(Bikes::getLockId,collect.get(Constants.FORCE_BACK_LOCK).getCode()) |
| | | .ne(Bikes::getSiteId,collect.get(Constants.FORCE_BACK_SITE).getCode()) |
| | | .isNull(Constants.formatIntegerNum(pageWrap.getModel().getHasBike()) == Constants.ONE,Bikes::getCode) |
| | |
| | | */ |
| | | @Override |
| | | public MqttLog openLock(Locks locks) { |
| | | String topic = Constants.MqttTopic.pub_openLock.replace("{siteId}", locks.getSiteId()).replace("{lockId}", locks.getCode()); |
| | | String topic = Constants.MqttTopic.pub_openLock.replace("{siteId}", locks.getSiteId()).replace("{lockId}", locks.getCode()+""); |
| | | int result = mqttToolService.pubMessage("{}",topic); |
| | | MqttLog mqttLog = createPushLog(topic,result,"请求开锁_"+locks.getId()); |
| | | return mqttLog; |
| | |
| | | */ |
| | | @Override |
| | | public MqttLog getLockInfo(Locks locks) { |
| | | String topic = Constants.MqttTopic.pub_getLockInfo.replace("{siteId}", locks.getSiteId()).replace("{lockId}", locks.getCode()); |
| | | String topic = Constants.MqttTopic.pub_getLockInfo.replace("{siteId}", locks.getSiteId()).replace("{lockId}", locks.getCode()+""); |
| | | int result = mqttToolService.pubMessage("{}",topic); |
| | | MqttLog mqttLog = createPushLog(topic,result,"实时查询锁信息_"+locks.getId()); |
| | | return mqttLog; |
| | |
| | | import com.doumee.dao.business.SitesMapper; |
| | | import com.doumee.dao.business.model.*; |
| | | import com.doumee.service.business.*; |
| | | import io.swagger.models.auth.In; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | } |
| | | if(StringUtils.contains(topic, info)){ |
| | | //如果锁头信息上报 |
| | | String lockid = ss[3];//锁头编码 |
| | | if( StringUtils.isBlank(lockid)){ |
| | | Integer lockid = Constants.formatIntegerFromStr(ss[3]) ;//锁头编码 |
| | | if( lockid == null){ |
| | | //如果锁头编码为空 |
| | | log.error("mqtt消息订阅==============无效数据====="+topic+param); |
| | | return; |
| | |
| | | log.info("mqtt消息订阅=========锁信息==========成功"); |
| | | }else if(StringUtils.contains(topic, closeLock)){ |
| | | //如果还车上报 |
| | | String lockid = ss[3];//锁头编码 |
| | | if( StringUtils.isBlank(lockid)){ |
| | | Integer lockid = Constants.formatIntegerFromStr(ss[3]);//锁头编码 |
| | | if( lockid == null){ |
| | | //如果锁头编码为空 |
| | | log.error("mqtt消息订阅==============无效数据====="+topic+param); |
| | | return; |
| | |
| | | update.setBackType(Constants.ONE); |
| | | update.setStatus(Constants.MEMBER_RIDES_STATUS.BACK_CYCLING.getKey()); |
| | | update.setBackSiteId(collect.get(Constants.FORCE_BACK_SITE).getCode()); |
| | | update.setBackLockId(collect.get(Constants.FORCE_BACK_LOCK).getCode()); |
| | | update.setBackLockId(Constants.formatIntegerFromStr(collect.get(Constants.FORCE_BACK_LOCK).getCode())); |
| | | Integer freeRentTime = Integer.valueOf(collect.get(Constants.FREE_RENT_TIME).getCode()); |
| | | Integer rideTime = DateUtil.betweenMin(model.getRentDate(), update.getBackDate()); |
| | | //计算骑行计费时长 |
| | |
| | | //查询锁头是否存在车辆 以及是否正常 |
| | | if (Constants.formatIntegerNum(locks.getStatus())!=Constants.ZERO) { |
| | | locks =new Locks(); |
| | | locks.setCode(codes[1]); |
| | | locks.setCode(Constants.formatIntegerFromStr(codes[1])); |
| | | locks.setSiteId(codes[0]); |
| | | deviceService.getLockInfo(locks); |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "当前扫码锁头状态错误,已尝试更新锁头状态,请稍后重试!"); |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "当前车辆暂时无法使用,请稍后重试或更换其它车辆~"); |
| | | } |
| | | if (StringUtils.isBlank(locks.getBikeCode())) { |
| | | locks =new Locks(); |
| | | locks.setCode(codes[1]); |
| | | locks.setCode(Constants.formatIntegerFromStr(codes[1])); |
| | | locks.setSiteId(codes[0]); |
| | | deviceService.getLockInfo(locks); |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "当前扫码锁头无车辆信息,已尝试更新锁头状态,请稍后重试!"); |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "当前车辆暂时无法使用,请稍后重试或更换其它车辆!"); |
| | | } |
| | | MemberRides memberRides = new MemberRides(); |
| | | //根据车型查询计价方案 |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = {BusinessException.class,Exception.class}) |
| | | public int mqttLockInfoEvent(Locks locks){ |
| | | if(StringUtils.isBlank(locks.getCode()) ||StringUtils.isBlank(locks.getSiteId())){ |
| | | if( locks.getCode() !=null ||StringUtils.isBlank(locks.getSiteId())){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"锁头信息上报参数错误!"); |
| | | } |
| | | //判断检查处理站点锁头信息 |
| | |
| | | } |
| | | |
| | | private void mqttCloseBikeEventDo(MemberRides bikes) { |
| | | if(StringUtils.isBlank(bikes.getBikeCode()) ||StringUtils.isBlank(bikes.getBackLockId())||StringUtils.isBlank(bikes.getBackSiteId())){ |
| | | if(StringUtils.isBlank(bikes.getBikeCode()) || bikes.getBackLockId() == null ||StringUtils.isBlank(bikes.getBackSiteId())){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"还车上报参数错误!"); |
| | | } |
| | | QueryWrapper<MemberRides> wrapper = new QueryWrapper<>(); |
| | |
| | | //只能同步昨天10之前的数据 |
| | | Calendar caln = Calendar.getInstance(); |
| | | caln.setTime(ydate); |
| | | if(caln.get(Calendar.HOUR_OF_DAY) <= 9){ |
| | | // System.out.println(caln.get(Calendar.HOUR_OF_DAY) ); |
| | | if(caln.get(Calendar.HOUR_OF_DAY) >= 10){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,最近同步时间只能截止到昨天10点前!"); |
| | | } |
| | | } |