¶Ô±ÈÐÂÎļþ |
| | |
| | | INSERT INTO `SYSTEM_PERMISSION`(`CODE`, `NAME`, `REMARK`, `FIXED`, `CREATE_USER`, `CREATE_TIME`, `UPDATE_USER`, `UPDATE_TIME`, `DELETED`) VALUES ('business:mqttlog:create', 'æ°å»ºç³»ç»è¡ä¸ºæä½è®°å½è¡¨', '', 0, 1, CURRENT_TIMESTAMP, NULL, NULL, 0); |
| | | INSERT INTO `SYSTEM_PERMISSION`(`CODE`, `NAME`, `REMARK`, `FIXED`, `CREATE_USER`, `CREATE_TIME`, `UPDATE_USER`, `UPDATE_TIME`, `DELETED`) VALUES ('business:mqttlog:delete', 'å é¤ç³»ç»è¡ä¸ºæä½è®°å½è¡¨', '', 0, 1, CURRENT_TIMESTAMP, NULL, NULL, 0); |
| | | INSERT INTO `SYSTEM_PERMISSION`(`CODE`, `NAME`, `REMARK`, `FIXED`, `CREATE_USER`, `CREATE_TIME`, `UPDATE_USER`, `UPDATE_TIME`, `DELETED`) VALUES ('business:mqttlog:update', 'ä¿®æ¹ç³»ç»è¡ä¸ºæä½è®°å½è¡¨', '', 0, 1, CURRENT_TIMESTAMP, NULL, NULL, 0); |
| | | INSERT INTO `SYSTEM_PERMISSION`(`CODE`, `NAME`, `REMARK`, `FIXED`, `CREATE_USER`, `CREATE_TIME`, `UPDATE_USER`, `UPDATE_TIME`, `DELETED`) VALUES ('business:mqttlog:query', 'æ¥è¯¢ç³»ç»è¡ä¸ºæä½è®°å½è¡¨', '', 0, 1, CURRENT_TIMESTAMP, NULL, NULL, 0); |
| | | INSERT INTO `SYSTEM_PERMISSION`(`CODE`, `NAME`, `REMARK`, `FIXED`, `CREATE_USER`, `CREATE_TIME`, `UPDATE_USER`, `UPDATE_TIME`, `DELETED`) VALUES ('business:mqttlog:exportExcel', '导åºç³»ç»è¡ä¸ºæä½è®°å½è¡¨(Excel)', '', 0, 1, CURRENT_TIMESTAMP, NULL, NULL, 0); |
| | | |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.api; |
| | | |
| | | import com.doumee.api.BaseController; |
| | | import com.doumee.core.annotation.excel.ExcelExporter; |
| | | import com.doumee.core.annotation.pr.PreventRepeat; |
| | | import com.doumee.core.model.ApiResponse; |
| | | import com.doumee.core.model.PageWrap; |
| | | import com.doumee.core.model.PageData; |
| | | import com.doumee.dao.business.model.MqttLog; |
| | | import com.doumee.service.business.MqttLogService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.apache.shiro.authz.annotation.RequiresPermissions; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author æ±è¹è¹ |
| | | * @date 2023/10/12 14:25 |
| | | */ |
| | | @Api(tags = "ç³»ç»è¡ä¸ºæä½è®°å½è¡¨") |
| | | @RestController |
| | | @RequestMapping("/business/mqttLog") |
| | | public class MqttLogController extends BaseController { |
| | | |
| | | @Autowired |
| | | private MqttLogService mqttLogService; |
| | | |
| | | @PreventRepeat |
| | | @ApiOperation("æ°å»º") |
| | | @PostMapping("/create") |
| | | @RequiresPermissions("business:mqttlog:create") |
| | | public ApiResponse create(@RequestBody MqttLog mqttLog) { |
| | | return ApiResponse.success(mqttLogService.create(mqttLog)); |
| | | } |
| | | |
| | | @ApiOperation("æ ¹æ®IDå é¤") |
| | | @GetMapping("/delete/{id}") |
| | | @RequiresPermissions("business:mqttlog:delete") |
| | | public ApiResponse deleteById(@PathVariable String id) { |
| | | mqttLogService.deleteById(id); |
| | | return ApiResponse.success(null); |
| | | } |
| | | |
| | | @ApiOperation("æ¹éå é¤") |
| | | @GetMapping("/delete/batch") |
| | | @RequiresPermissions("business:mqttlog:delete") |
| | | public ApiResponse deleteByIdInBatch(@RequestParam String ids) { |
| | | String [] idArray = ids.split(","); |
| | | List<String> idList = new ArrayList<>(); |
| | | for (String id : idArray) { |
| | | idList.add(id); |
| | | } |
| | | mqttLogService.deleteByIdInBatch(idList); |
| | | return ApiResponse.success(null); |
| | | } |
| | | |
| | | @ApiOperation("æ ¹æ®IDä¿®æ¹") |
| | | @PostMapping("/updateById") |
| | | @RequiresPermissions("business:mqttlog:update") |
| | | public ApiResponse updateById(@RequestBody MqttLog mqttLog) { |
| | | mqttLogService.updateById(mqttLog); |
| | | return ApiResponse.success(null); |
| | | } |
| | | |
| | | @ApiOperation("å页æ¥è¯¢") |
| | | @PostMapping("/page") |
| | | @RequiresPermissions("business:mqttlog:query") |
| | | public ApiResponse<PageData<MqttLog>> findPage (@RequestBody PageWrap<MqttLog> pageWrap) { |
| | | return ApiResponse.success(mqttLogService.findPage(pageWrap)); |
| | | } |
| | | |
| | | @ApiOperation("导åºExcel") |
| | | @PostMapping("/exportExcel") |
| | | @RequiresPermissions("business:mqttlog:exportExcel") |
| | | public void exportExcel (@RequestBody PageWrap<MqttLog> pageWrap, HttpServletResponse response) { |
| | | ExcelExporter.build(MqttLog.class).export(mqttLogService.findPage(pageWrap).getRecords(), "ç³»ç»è¡ä¸ºæä½è®°å½è¡¨", response); |
| | | } |
| | | |
| | | @ApiOperation("æ ¹æ®IDæ¥è¯¢") |
| | | @GetMapping("/{id}") |
| | | @RequiresPermissions("business:mqttlog:query") |
| | | public ApiResponse findById(@PathVariable String id) { |
| | | return ApiResponse.success(mqttLogService.findById(id)); |
| | | } |
| | | } |
| | |
| | | return ApiResponse.success(null); |
| | | } |
| | | |
| | | @ApiOperation("宿¶è½¦ä½ä¿¡æ¯_å页æ¥è¯¢") |
| | | @ApiOperation("å页æ¥è¯¢") |
| | | @PostMapping("/page") |
| | | @RequiresPermissions("business:locks:query") |
| | | public ApiResponse<PageData<Locks>> findPage(@RequestBody PageWrap<Locks> pageWrap) { |
| | |
| | | public static final String PROJECT_FILE = "PROJECT_FILE"; |
| | | public static String REDIS_DEBUG_STR="test_"; |
| | | public interface MqttTopic{ |
| | | //å¼é |
| | | String openLock = "OPENLOCK"; |
| | | //å
³éé头 |
| | | String closeLock = "CLOSELOCK"; |
| | | //å¼éï¼åå¸ï¼ |
| | | String topic_index = "device/lock/"; |
| | | String openLock = "device/lock/+/unlock"; |
| | | //éä¿¡æ¯ï¼å¨åå§åãç¶æåæ´æ¶ä¼æ¨ééç宿´ç¶æ(订é
ï¼ |
| | | String lockInfo = "device/lock/+/info"; |
| | | //è¿è½¦é头ï¼è®¢é
ï¼ |
| | | String closeLock = "device/lock/+/bike"; |
| | | //宿¶è·åéä¿¡æ¯ï¼åå¸ï¼ |
| | | String getLockInfo = "device/lock/+/getInfo"; |
| | | } |
| | | |
| | | /** |
| | |
| | | int all =2; |
| | | int partful = 3; |
| | | } |
| | | public interface LockStatus{ |
| | | // //ç¶æï¼0éå, 1æå¼ï¼2è¿è¡ä¸, 3å¼å¸¸ |
| | | int closed =0; |
| | | int open =1; |
| | | int running =2; |
| | | int error= 3; |
| | | } |
| | | public interface goodsorderStatus{ |
| | | int waitPay =0; |
| | | int pay =1; |
| | |
| | | * @param message |
| | | * @param topic |
| | | */ |
| | | public void pubMessage(String message,String topic){ |
| | | public int pubMessage(String message,String topic){ |
| | | MqttMessage mess = new MqttMessage(); |
| | | mess.setQos(1); |
| | | mess.setRetained(true); |
| | | mess.setPayload(message.getBytes()); |
| | | try { |
| | | MqttClientInit.getInstance(config,callBack).publish(topic, mess); |
| | | return 1; |
| | | } catch (Exception e) { |
| | | //LOGGER.error(e.getLocalizedMessage()); |
| | | } |
| | | return 0; |
| | | } |
| | | public static void main(String[] args) { |
| | | MqttToolService client1 = new MqttToolService(); |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.dao.business; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.doumee.dao.business.model.MqttLog; |
| | | |
| | | /** |
| | | * @author æ±è¹è¹ |
| | | * @date 2023/10/12 14:25 |
| | | */ |
| | | public interface MqttLogMapper extends BaseMapper<MqttLog> { |
| | | |
| | | } |
| | |
| | | package com.doumee.dao.business.model; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.doumee.core.annotation.excel.ExcelColumn; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | |
| | | @ExcelColumn(name="ç¼å·") |
| | | private String code; |
| | | |
| | | @ApiModelProperty(value = "ç¶æ 0æ£å¸¸ 1å¼å¸¸", example = "1") |
| | | @ExcelColumn(name="ç¶æ 0æ£å¸¸ 1å¼å¸¸") |
| | | @ApiModelProperty(value = "ç¶æï¼0éå, 1æå¼ï¼2è¿è¡ä¸, 3å¼å¸¸", example = "1") |
| | | @ExcelColumn(name="ç¶æï¼0éå, 1æå¼ï¼2è¿è¡ä¸, 3å¼å¸¸") |
| | | private Integer status; |
| | | |
| | | @ApiModelProperty(value = "ç«ç¹ç¼ç (å
³èsites)") |
| | |
| | | @ApiModelProperty(value = "å½åéå®èªè¡è½¦ç¼å·") |
| | | @ExcelColumn(name="å½åéå®èªè¡è½¦ç¼å·") |
| | | private String bikeCode; |
| | | @ApiModelProperty(value = "å½åéå®èªè¡è½¦ç¼å·") |
| | | @TableField(select = false) |
| | | private Sites sites; |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.dao.business.model; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableLogic; |
| | | import com.doumee.core.annotation.excel.ExcelColumn; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * ç³»ç»è¡ä¸ºæä½è®°å½è¡¨ |
| | | * @author æ±è¹è¹ |
| | | * @date 2023/10/12 14:25 |
| | | */ |
| | | @Data |
| | | @ApiModel("ç³»ç»è¡ä¸ºæä½è®°å½è¡¨") |
| | | @TableName("`mqtt_log`") |
| | | public class MqttLog { |
| | | |
| | | @ApiModelProperty(value = "ç¼ç ") |
| | | @ExcelColumn(name="ç¼ç ") |
| | | private String id; |
| | | |
| | | @ApiModelProperty(value = "å建æ¶é´") |
| | | @ExcelColumn(name="å建æ¶é´") |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | private Date createDate; |
| | | |
| | | @ApiModelProperty(value = "å建人") |
| | | @ExcelColumn(name="å建人") |
| | | private String creator; |
| | | |
| | | @ApiModelProperty(value = "ç¼è¾æ¶é´") |
| | | @ExcelColumn(name="ç¼è¾æ¶é´") |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | private Date editDate; |
| | | |
| | | @ApiModelProperty(value = "ç¼è¾äºº") |
| | | @ExcelColumn(name="ç¼è¾äºº") |
| | | private String editor; |
| | | |
| | | @ApiModelProperty(value = "æ¯å¦å·²å é¤ 0æªå é¤ 1å·²å é¤", example = "1") |
| | | @ExcelColumn(name="æ¯å¦å·²å é¤ 0æªå é¤ 1å·²å é¤") |
| | | @TableLogic |
| | | private Integer isdeleted; |
| | | |
| | | @ApiModelProperty(value = "夿³¨") |
| | | @ExcelColumn(name="夿³¨") |
| | | private String info; |
| | | |
| | | @ApiModelProperty(value = "ç±»å 0订é
1åå¸", example = "1") |
| | | @ExcelColumn(name="ç±»å 0订é
1åå¸") |
| | | private Integer type; |
| | | |
| | | @ApiModelProperty(value = "客æ·ç«¯ç¼ç ") |
| | | @ExcelColumn(name="客æ·ç«¯ç¼ç ") |
| | | private String clientid; |
| | | @ApiModelProperty(value = "æå¡å¨ä¿¡æ¯") |
| | | @ExcelColumn(name="æå¡å¨ä¿¡æ¯") |
| | | private String hostInfo; |
| | | |
| | | @ApiModelProperty(value = "主é¢") |
| | | @ExcelColumn(name="主é¢") |
| | | private String topic; |
| | | |
| | | @ApiModelProperty(value = "æ¶æ¯å
容") |
| | | @ExcelColumn(name="æ¶æ¯å
容") |
| | | private String msg; |
| | | |
| | | @ApiModelProperty(value = "ç»æ 0æå 1失败", example = "1") |
| | | @ExcelColumn(name="ç»æ 0æå 1失败") |
| | | private Integer result; |
| | | |
| | | } |
| | |
| | | @ApiModelProperty(value = "卿¶è½¦è¾æ°") |
| | | @TableField(exist = false) |
| | | private Integer bikeCount; |
| | | @ApiModelProperty(value = "卿¶è½¦è¾æ°") |
| | | @TableField(exist = false) |
| | | private Integer allLockNum; |
| | | |
| | | @ApiModelProperty(value = "满æ¶ç") |
| | | @TableField(exist = false) |
| | |
| | | long count(Bikes bikes); |
| | | |
| | | PageData<Bikes> findJoinPage(PageWrap<Bikes> pageWrap); |
| | | |
| | | } |
| | |
| | | package com.doumee.service.business; |
| | | |
| | | import com.doumee.dao.business.model.Locks; |
| | | import com.doumee.dao.business.model.MqttLog; |
| | | |
| | | /** |
| | | * ä¸ç¡¬ä»¶å¯¹æ¥æå¡ |
| | |
| | | * ä¸åå¼è½¦å¼éæä»¤ |
| | | * @return String |
| | | */ |
| | | boolean openLock(Locks locks); |
| | | MqttLog openLock(Locks locks); |
| | | |
| | | void startSubcribe(); |
| | | |
| | | MqttLog getLockInfo(Locks locks); |
| | | |
| | | } |
| | |
| | | * @return long |
| | | */ |
| | | long count(Locks locks); |
| | | |
| | | } |
| | |
| | | |
| | | import com.doumee.core.model.PageData; |
| | | import com.doumee.core.model.PageWrap; |
| | | import com.doumee.dao.business.model.Locks; |
| | | import com.doumee.dao.business.model.MemberRides; |
| | | import com.doumee.dao.business.web.request.MemberRidesQuery; |
| | | import com.doumee.dao.business.web.response.BikeLogDTO; |
| | |
| | | void updateDuration(MemberRides memberRides); |
| | | |
| | | void forceBack(MemberRides memberRides); |
| | | |
| | | int mqttCloseBikeEvent(MemberRides bikes); |
| | | |
| | | int mqttLockInfoEvent(Locks locks); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.service.business; |
| | | |
| | | import com.doumee.core.model.PageData; |
| | | import com.doumee.core.model.PageWrap; |
| | | import com.doumee.dao.business.model.MqttLog; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * ç³»ç»è¡ä¸ºæä½è®°å½è¡¨Serviceå®ä¹ |
| | | * @author æ±è¹è¹ |
| | | * @date 2023/10/12 14:25 |
| | | */ |
| | | public interface MqttLogService { |
| | | |
| | | /** |
| | | * å建 |
| | | * |
| | | * @param mqttLog å®ä½å¯¹è±¡ |
| | | * @return String |
| | | */ |
| | | String create(MqttLog mqttLog); |
| | | |
| | | /** |
| | | * 主é®å é¤ |
| | | * |
| | | * @param id ä¸»é® |
| | | */ |
| | | void deleteById(String id); |
| | | |
| | | /** |
| | | * å é¤ |
| | | * |
| | | * @param mqttLog å®ä½å¯¹è±¡ |
| | | */ |
| | | void delete(MqttLog mqttLog); |
| | | |
| | | /** |
| | | * æ¹é主é®å é¤ |
| | | * |
| | | * @param ids 主é®é |
| | | */ |
| | | void deleteByIdInBatch(List<String> ids); |
| | | |
| | | /** |
| | | * 䏻鮿´æ° |
| | | * |
| | | * @param mqttLog å®ä½å¯¹è±¡ |
| | | */ |
| | | void updateById(MqttLog mqttLog); |
| | | |
| | | /** |
| | | * æ¹é䏻鮿´æ° |
| | | * |
| | | * @param mqttLogs å®ä½é |
| | | */ |
| | | void updateByIdInBatch(List<MqttLog> mqttLogs); |
| | | |
| | | /** |
| | | * 䏻鮿¥è¯¢ |
| | | * |
| | | * @param id ä¸»é® |
| | | * @return MqttLog |
| | | */ |
| | | MqttLog findById(String id); |
| | | |
| | | /** |
| | | * æ¡ä»¶æ¥è¯¢åæ¡è®°å½ |
| | | * |
| | | * @param mqttLog å®ä½å¯¹è±¡ |
| | | * @return MqttLog |
| | | */ |
| | | MqttLog findOne(MqttLog mqttLog); |
| | | |
| | | /** |
| | | * æ¡ä»¶æ¥è¯¢ |
| | | * |
| | | * @param mqttLog å®ä½å¯¹è±¡ |
| | | * @return List<MqttLog> |
| | | */ |
| | | List<MqttLog> findList(MqttLog mqttLog); |
| | | |
| | | /** |
| | | * å页æ¥è¯¢ |
| | | * |
| | | * @param pageWrap å页对象 |
| | | * @return PageData<MqttLog> |
| | | */ |
| | | PageData<MqttLog> findPage(PageWrap<MqttLog> pageWrap); |
| | | |
| | | /** |
| | | * æ¡ä»¶ç»è®¡ |
| | | * |
| | | * @param mqttLog å®ä½å¯¹è±¡ |
| | | * @return long |
| | | */ |
| | | long count(MqttLog mqttLog); |
| | | } |
| | |
| | | package com.doumee.service.business.impl; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.doumee.core.constants.Constants; |
| | | import com.doumee.core.mqtt.config.MqttConfig; |
| | | import com.doumee.core.mqtt.service.MqttToolService; |
| | | import com.doumee.dao.business.MqttLogMapper; |
| | | import com.doumee.dao.business.model.Locks; |
| | | import com.doumee.dao.business.model.MqttLog; |
| | | import com.doumee.service.business.DeviceService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import javax.annotation.PostConstruct; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * ä¸ç¡¬ä»¶å¯¹æ¥æå¡ |
| | |
| | | public class DeviceServiceImpl implements DeviceService { |
| | | @Autowired |
| | | private MqttToolService mqttToolService; |
| | | @Autowired |
| | | private MqttLogMapper mqttLogMapper; |
| | | @Autowired |
| | | private MqttConfig mqttConfig; |
| | | @Override |
| | | @PostConstruct |
| | | public void startSubcribe() { |
| | | mqttToolService.subscribe(new String[]{ Constants.MqttTopic.openLock, Constants.MqttTopic.closeLock}); |
| | | } |
| | | |
| | | /** |
| | | * åèµ·å¼éæä»¤ |
| | | * @param locks |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean openLock(Locks locks) { |
| | | mqttToolService.pubMessage(locks.getName(), Constants.MqttTopic.openLock); |
| | | return true; |
| | | public MqttLog openLock(Locks locks) { |
| | | String topic = Constants.MqttTopic.openLock.replace("+", locks.getId()); |
| | | int result = mqttToolService.pubMessage("{}",topic); |
| | | MqttLog mqttLog = createPushLog(topic,result,"请æ±å¼é_"+locks.getId()); |
| | | return mqttLog; |
| | | } |
| | | /** |
| | | * 宿¶æ¥è¯¢éä¿¡æ¯ |
| | | * @param locks |
| | | * @return |
| | | */ |
| | | @Override |
| | | public MqttLog getLockInfo(Locks locks) { |
| | | String topic = Constants.MqttTopic.getLockInfo.replace("+", locks.getId()); |
| | | int result = mqttToolService.pubMessage("{}",topic); |
| | | MqttLog mqttLog = createPushLog(topic,result,"宿¶æ¥è¯¢éä¿¡æ¯_"+locks.getId()); |
| | | return mqttLog; |
| | | } |
| | | |
| | | private MqttLog createPushLog(String topic, int result,String info) { |
| | | MqttLog log = new MqttLog(); |
| | | log.setId(Constants.getUUID()); |
| | | log.setCreateDate(new Date()); |
| | | log.setResult(result); |
| | | log.setTopic(topic); |
| | | log.setClientid(mqttConfig.getClientid()); |
| | | log.setHostInfo(mqttConfig.getHost()); |
| | | log.setInfo(JSONObject.toJSONString(mqttConfig)); |
| | | log.setType(Constants.ONE); |
| | | log.setMsg(""); |
| | | log.setInfo(info); |
| | | mqttLogMapper.insert(log); |
| | | return log; |
| | | } |
| | | } |
| | |
| | | package com.doumee.service.business.impl; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.doumee.core.constants.Constants; |
| | | import com.doumee.core.exception.BusinessException; |
| | | import com.doumee.core.mqtt.config.MqttConfig; |
| | | import com.doumee.core.mqtt.service.MqttToolService; |
| | | import com.doumee.dao.business.MqttLogMapper; |
| | | import com.doumee.dao.business.model.Bikes; |
| | | import com.doumee.dao.business.model.Locks; |
| | | import com.doumee.service.business.DeviceService; |
| | | import com.doumee.service.business.DeviceSubcribeService; |
| | | import com.doumee.dao.business.model.MemberRides; |
| | | import com.doumee.dao.business.model.MqttLog; |
| | | import com.doumee.service.business.*; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.PostConstruct; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * ä¸ç¡¬ä»¶å¯¹æ¥æå¡ |
| | |
| | | * @date 2023/10/09 18:06 |
| | | */ |
| | | @Service |
| | | @Slf4j |
| | | public class DeviceSubscribeServiceImpl implements DeviceSubcribeService { |
| | | |
| | | @Autowired |
| | | MemberRidesService memberRidesService; |
| | | @Autowired |
| | | private MqttLogMapper mqttLogMapper; |
| | | @Autowired |
| | | private MqttConfig mqttConfig; |
| | | @Override |
| | | public void listener(String param,String topic) { |
| | | System.out.println("mqttæ¶æ¯è®¢é
==================="+param); |
| | | log.info("mqttæ¶æ¯è®¢é
==================="+param); |
| | | String info = Constants.MqttTopic.lockInfo.substring(Constants.MqttTopic.lockInfo.lastIndexOf("/")+1) ; |
| | | String closeLock = Constants.MqttTopic.lockInfo.substring(Constants.MqttTopic.closeLock.lastIndexOf("/")+1) ; |
| | | if(topic.indexOf(Constants.MqttTopic.topic_index)!=0 |
| | | || (!StringUtils.contains(topic, info) |
| | | &&!StringUtils.contains(topic,closeLock))){ |
| | | log.error("mqttæ¶æ¯è®¢é
===========æ ææ°æ®========"+param); |
| | | return; |
| | | } |
| | | String lockid = getLockIdFromTopic(topic); |
| | | if(StringUtils.isBlank(lockid)){ |
| | | //妿é头ç¼ç 为空 |
| | | log.error("mqttæ¶æ¯è®¢é
==============æ ææ°æ®====="+param); |
| | | return; |
| | | } |
| | | String logId =Constants.getUUID(); |
| | | String logInfo = ""; |
| | | int result =0; |
| | | try { |
| | | |
| | | if(StringUtils.contains(topic, info)){ |
| | | //妿é头信æ¯ä¸æ¥ |
| | | Locks locks = JSONObject.parseObject(param, Locks.class); |
| | | locks.setId(lockid); |
| | | locks.setInfo(logId); |
| | | result = memberRidesService.mqttLockInfoEvent(locks); |
| | | logInfo = "䏿¥é头信æ¯"; |
| | | log.info("mqttæ¶æ¯è®¢é
=========éä¿¡æ¯==========æå"); |
| | | } |
| | | if(StringUtils.contains(topic, closeLock)){ |
| | | //妿è¿è½¦ä¸æ¥ |
| | | JSONObject pjson = JSONObject.parseObject(param); |
| | | String bikeCode = pjson.getString("bikeCode"); |
| | | MemberRides bikes = new MemberRides(); |
| | | bikes.setBikeCode(bikeCode); |
| | | bikes.setBackLockId(lockid); |
| | | bikes.setBackCommondId(logId); |
| | | result = memberRidesService.mqttCloseBikeEvent(bikes); |
| | | logInfo = "䏿¥è¿è½¦æ¶æ¯"; |
| | | log.info("mqttæ¶æ¯è®¢é
=========è¿è½¦==========æå"); |
| | | } |
| | | }catch (BusinessException e){ |
| | | result =1; |
| | | }catch (Exception e){ |
| | | result =1; |
| | | } |
| | | createSubLog(topic,logId,result,param,logInfo); |
| | | } |
| | | private void createSubLog(String topic, String logId, int result,String param,String info) { |
| | | MqttLog log = new MqttLog(); |
| | | log.setId(logId); |
| | | log.setCreateDate(new Date()); |
| | | log.setResult(result); |
| | | log.setTopic(topic); |
| | | log.setClientid(mqttConfig.getClientid()); |
| | | log.setHostInfo(mqttConfig.getHost()); |
| | | log.setInfo(JSONObject.toJSONString(mqttConfig)); |
| | | log.setType(Constants.ZERO); |
| | | log.setMsg(param); |
| | | log.setInfo(info); |
| | | mqttLogMapper.insert(log); |
| | | } |
| | | private String getLockIdFromTopic(String topic) { |
| | | topic = topic.substring(0,topic.lastIndexOf("/")); |
| | | String id = topic.substring( topic.lastIndexOf("/")+1); |
| | | return id; |
| | | } |
| | | } |
| | |
| | | BigDecimal closeMoney = new BigDecimal(0.00); |
| | | int durationSum = 0; |
| | | //åæé«è½¦åè®¡ç®æ¹æ¡ç»ç®è®¢å |
| | | MemberRides topRides =null; |
| | | for(MemberRides rides : memberRides){ |
| | | if ( isClose && Constants.MEMBER_RIDES_STATUS.BACK_CYCLING.getKey()!=(Constants.formatIntegerNum(rides.getStatus()))){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"å½åè®¢åææªå®æçéªè¡ï¼æ æ³å¼ºå¶ç»ç®"); |
| | | } |
| | | durationSum += Constants.formatIntegerNum(rides.getDuration());//累计éªè¡ï¼è®¡è´¹ï¼æ¶é¿ |
| | | } |
| | | MemberRides topRides =memberRides.get(0); |
| | | if(durationSum > 0 && topRides != null){ |
| | | int baseTime =Constants.formatIntegerNum(topRides.getBaseTime()); |
| | | closeMoney = Constants.formatDecimalNum(topRides.getBasePrice()); |
| | |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.doumee.service.business.SitesService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | |
| | | QueryWrapper<Locks> wrapper = new QueryWrapper<>(locks); |
| | | return locksMapper.selectCount(wrapper); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | import com.doumee.core.model.PageWrap; |
| | | import com.doumee.core.utils.DateUtil; |
| | | import com.doumee.core.utils.Utils; |
| | | import com.doumee.dao.business.ActionLogMapper; |
| | | import com.doumee.dao.business.LocksMapper; |
| | | import com.doumee.dao.business.MemberRidesMapper; |
| | | import com.doumee.dao.business.*; |
| | | import com.doumee.dao.business.join.MemberRidesJoinMapper; |
| | | import com.doumee.dao.business.model.*; |
| | | import com.doumee.dao.business.web.request.MemberRidesQuery; |
| | |
| | | |
| | | @Autowired |
| | | private LocksMapper locksMapper; |
| | | @Autowired |
| | | private SitesMapper sitesMapper; |
| | | @Autowired |
| | | private BikesMapper bikesMapper; |
| | | |
| | | @Autowired |
| | | private GoodsorderService goodsorderService; |
| | |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"åå¨éªè¡ä¸è½¦è¾ï¼æ æ³æ«ç "); |
| | | }; |
| | | Locks locks = locksMapper.selectOne(new QueryWrapper<Locks>().eq("code",code).eq("isdeleted", Constants.ZERO).last("limit 1")); |
| | | Boolean flag = deviceService.openLock(locks); |
| | | if(!flag){ |
| | | MqttLog flag = deviceService.openLock(locks); |
| | | if(flag.getResult() == 0){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"å¼é失败"); |
| | | } |
| | | //åå¨éªè¡è®°å½ |
| | |
| | | return memberRidesDetailResponse; |
| | | |
| | | } |
| | | |
| | | /** |
| | | * é头信æ¯ä¸æ¥ |
| | | * @param locks |
| | | * @return |
| | | */ |
| | | @Override |
| | | public int mqttLockInfoEvent(Locks locks){ |
| | | //å¤ææ£æ¥å¤çç«ç¹éå¤´ä¿¡æ¯ |
| | | Locks model = dealLockAndSite(locks); |
| | | //车è¾è®°å½ |
| | | Bikes bikes = dealBikesByParam(model); |
| | | |
| | | //ç¶æï¼0éå, 1æå¼ï¼2è¿è¡ä¸, 3å¼å¸¸ |
| | | if(model.getStatus() == Constants.LockStatus.open){ |
| | | //妿æ¯å¼éä¸å¡ï¼å¤ææ¯å¦æå¼éä¸çä¿¡æ¯ |
| | | if(StringUtils.isNotBlank(locks.getBikeCode())){ |
| | | |
| | | } |
| | | MemberRides memberRides = new MemberRides(); |
| | | memberRides.setBikeCode(model.getBikeCode()); |
| | | |
| | | |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | private Bikes dealBikesByParam(Locks model) { |
| | | QueryWrapper<Bikes> wrapper = new QueryWrapper<>(); |
| | | wrapper.lambda().eq(Bikes::getLockId, model.getId()); |
| | | wrapper.lambda().eq(Bikes::getSiteId, model.getSiteId()); |
| | | Bikes bikes = bikesMapper.selectOne(wrapper.last("last 1")); |
| | | if(bikes != null ) { |
| | | if ( StringUtils.equals(model.getBikeCode(), bikes.getCode())){ |
| | | //妿ç»å®è½¦è¾ä¿¡æ¯åçç¼å·ï¼æ´æ¢ç»å®å
³ç³» |
| | | bikes.setCode(model.getBikeCode()); |
| | | bikes.setParamId(getBileTypeByCode(model.getBikeCode())); |
| | | UpdateWrapper<Bikes> updateWrapper = new UpdateWrapper<>(); |
| | | updateWrapper.lambda().set(Bikes::getId, bikes.getId()); |
| | | |
| | | //æ´æ°èªè¡ç«ç¹é头ç»å®èªè¡è½¦ä¿¡æ¯ |
| | | bikesMapper.updateById(bikes); |
| | | } |
| | | }else{ |
| | | bikes = new Bikes(); |
| | | bikes.setId(Constants.getUUID()); |
| | | bikes.setIsdeleted(Constants.ZERO); |
| | | bikes.setCreateDate(new Date()); |
| | | bikes.setSiteId(model.getSiteId()); |
| | | bikes.setLockId(model.getId()); |
| | | bikes.setCode(model.getBikeCode()); |
| | | bikes.setParamId(getBileTypeByCode(model.getBikeCode())); |
| | | bikesMapper.insert(bikes); |
| | | } |
| | | return bikes; |
| | | |
| | | } |
| | | |
| | | //TODO-----JP------------æ ¹æ®è½¦è¾codeåæè½¦è¾ç±»åï¼å¾
ç¡®è®¤æ¹æ¡------------------- |
| | | private String getBileTypeByCode(String bikeCode) { |
| | | return null; |
| | | } |
| | | |
| | | private Locks dealLockAndSite(Locks locks) { |
| | | Locks model = locksMapper.selectById(locks.getId()); |
| | | Date date =new Date(); |
| | | //æ£æ¥ç«ç¹ä¿¡æ¯ï¼ä¸åå¨åæ°å¢ |
| | | // boolean newSite =false; |
| | | Sites sites = sitesMapper.selectById(locks.getSiteId()); |
| | | if(sites == null){ |
| | | sites = new Sites(); |
| | | sites.setIsdeleted(Constants.ZERO); |
| | | sites.setCode(locks.getSiteId()); |
| | | sites.setId(locks.getSiteId()); |
| | | sites.setCreateDate(date); |
| | | sites.setStatus(Constants.ZERO); |
| | | sites.setLockNum(1); |
| | | //æ°å¢é头 |
| | | sitesMapper.insert(sites); |
| | | // newSite =true; |
| | | } |
| | | |
| | | if(model == null){ |
| | | //妿é头ä¸åå¨ï¼å¤æåå¨ |
| | | model = new Locks(); |
| | | model.setId(locks.getId()); |
| | | model.setSiteId(locks.getSiteId()); |
| | | model.setIsdeleted(Constants.ZERO); |
| | | model.setCode(locks.getCode()); |
| | | model.setSiteId(locks.getSiteId()); |
| | | model.setBikeCode(locks.getBikeCode()); |
| | | model.setCreateDate(date); |
| | | model.setStatus(locks.getStatus()); |
| | | locksMapper.insert(model); |
| | | /* UpdateWrapper<Sites> wrapper = new UpdateWrapper(); |
| | | wrapper.eq("id",sites.getId()); |
| | | wrapper.lambda().setSql("lock_num = COALESCE(lock_num,0) + 1"); |
| | | wrapper.lambda().set(Sites::getEditDate,date); |
| | | sitesMapper.update(null,wrapper);//累计é头æ°é*/ |
| | | }else{ |
| | | /* if(!StringUtils.equals(model.getId(),locks.getId())){ |
| | | //妿ç«ç¹åçååï¼åæ¥çç«ç¹é头æ°é-1 |
| | | UpdateWrapper<Sites> wrapper = new UpdateWrapper(); |
| | | wrapper.eq("id",model.getId()); |
| | | wrapper.lambda().setSql("lock_num = COALESCE(lock_num,0) - 1"); |
| | | wrapper.lambda().set(Sites::getEditDate,date); |
| | | sitesMapper.update(null,wrapper);//累计é头æ°é |
| | | } |
| | | if(!newSite){ |
| | | //妿ç«ç¹æªåçååï¼ å¹¶ä¸ä¸æ¯æ°ç«ç¹ï¼ç«ç¹é头+1 |
| | | UpdateWrapper<Sites> wrapper = new UpdateWrapper(); |
| | | wrapper.eq("id",model.getId()); |
| | | wrapper.lambda().setSql("lock_num = COALESCE(lock_num,0) - 1"); |
| | | wrapper.lambda().set(Sites::getEditDate,date); |
| | | sitesMapper.update(null,wrapper);//累计é头æ°é |
| | | }*/ |
| | | model.setSiteId(locks.getSiteId()); |
| | | model.setIsdeleted(Constants.ZERO); |
| | | model.setCode(locks.getCode()); |
| | | model.setId(locks.getSiteId()); |
| | | model.setEditDate(date); |
| | | model.setBikeCode(locks.getBikeCode()); |
| | | model.setStatus(locks.getStatus()); |
| | | locksMapper.update(null, new QueryWrapper<>(model)); |
| | | |
| | | } |
| | | model.setSites(sites); |
| | | return model; |
| | | } |
| | | |
| | | @Override |
| | | public int mqttCloseBikeEvent(MemberRides bikes){ |
| | | return 0; |
| | | |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.service.business.impl; |
| | | |
| | | import com.doumee.core.model.PageData; |
| | | import com.doumee.core.model.PageWrap; |
| | | import com.doumee.core.utils.Utils; |
| | | import com.doumee.dao.business.MqttLogMapper; |
| | | import com.doumee.dao.business.model.MqttLog; |
| | | import com.doumee.service.business.MqttLogService; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * ç³»ç»è¡ä¸ºæä½è®°å½è¡¨Serviceå®ç° |
| | | * @author æ±è¹è¹ |
| | | * @date 2023/10/12 14:25 |
| | | */ |
| | | @Service |
| | | public class MqttLogServiceImpl implements MqttLogService { |
| | | |
| | | @Autowired |
| | | private MqttLogMapper mqttLogMapper; |
| | | |
| | | @Override |
| | | public String create(MqttLog mqttLog) { |
| | | mqttLogMapper.insert(mqttLog); |
| | | return mqttLog.getId(); |
| | | } |
| | | |
| | | @Override |
| | | public void deleteById(String id) { |
| | | mqttLogMapper.deleteById(id); |
| | | } |
| | | |
| | | @Override |
| | | public void delete(MqttLog mqttLog) { |
| | | UpdateWrapper<MqttLog> deleteWrapper = new UpdateWrapper<>(mqttLog); |
| | | mqttLogMapper.delete(deleteWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public void deleteByIdInBatch(List<String> ids) { |
| | | if (CollectionUtils.isEmpty(ids)) { |
| | | return; |
| | | } |
| | | mqttLogMapper.deleteBatchIds(ids); |
| | | } |
| | | |
| | | @Override |
| | | public void updateById(MqttLog mqttLog) { |
| | | mqttLogMapper.updateById(mqttLog); |
| | | } |
| | | |
| | | @Override |
| | | public void updateByIdInBatch(List<MqttLog> mqttLogs) { |
| | | if (CollectionUtils.isEmpty(mqttLogs)) { |
| | | return; |
| | | } |
| | | for (MqttLog mqttLog: mqttLogs) { |
| | | this.updateById(mqttLog); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public MqttLog findById(String id) { |
| | | return mqttLogMapper.selectById(id); |
| | | } |
| | | |
| | | @Override |
| | | public MqttLog findOne(MqttLog mqttLog) { |
| | | QueryWrapper<MqttLog> wrapper = new QueryWrapper<>(mqttLog); |
| | | return mqttLogMapper.selectOne(wrapper); |
| | | } |
| | | |
| | | @Override |
| | | public List<MqttLog> findList(MqttLog mqttLog) { |
| | | QueryWrapper<MqttLog> wrapper = new QueryWrapper<>(mqttLog); |
| | | return mqttLogMapper.selectList(wrapper); |
| | | } |
| | | |
| | | @Override |
| | | public PageData<MqttLog> findPage(PageWrap<MqttLog> pageWrap) { |
| | | IPage<MqttLog> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity()); |
| | | QueryWrapper<MqttLog> queryWrapper = new QueryWrapper<>(); |
| | | Utils.MP.blankToNull(pageWrap.getModel()); |
| | | if (pageWrap.getModel().getId() != null) { |
| | | queryWrapper.lambda().eq(MqttLog::getId, pageWrap.getModel().getId()); |
| | | } |
| | | if (pageWrap.getModel().getCreateDate() != null) { |
| | | queryWrapper.lambda().ge(MqttLog::getCreateDate, Utils.Date.getStart(pageWrap.getModel().getCreateDate())); |
| | | queryWrapper.lambda().le(MqttLog::getCreateDate, Utils.Date.getEnd(pageWrap.getModel().getCreateDate())); |
| | | } |
| | | if (pageWrap.getModel().getCreator() != null) { |
| | | queryWrapper.lambda().eq(MqttLog::getCreator, pageWrap.getModel().getCreator()); |
| | | } |
| | | if (pageWrap.getModel().getEditDate() != null) { |
| | | queryWrapper.lambda().ge(MqttLog::getEditDate, Utils.Date.getStart(pageWrap.getModel().getEditDate())); |
| | | queryWrapper.lambda().le(MqttLog::getEditDate, Utils.Date.getEnd(pageWrap.getModel().getEditDate())); |
| | | } |
| | | if (pageWrap.getModel().getEditor() != null) { |
| | | queryWrapper.lambda().eq(MqttLog::getEditor, pageWrap.getModel().getEditor()); |
| | | } |
| | | if (pageWrap.getModel().getIsdeleted() != null) { |
| | | queryWrapper.lambda().eq(MqttLog::getIsdeleted, pageWrap.getModel().getIsdeleted()); |
| | | } |
| | | if (pageWrap.getModel().getInfo() != null) { |
| | | queryWrapper.lambda().eq(MqttLog::getInfo, pageWrap.getModel().getInfo()); |
| | | } |
| | | if (pageWrap.getModel().getType() != null) { |
| | | queryWrapper.lambda().eq(MqttLog::getType, pageWrap.getModel().getType()); |
| | | } |
| | | if (pageWrap.getModel().getClientid() != null) { |
| | | queryWrapper.lambda().eq(MqttLog::getClientid, pageWrap.getModel().getClientid()); |
| | | } |
| | | if (pageWrap.getModel().getTopic() != null) { |
| | | queryWrapper.lambda().eq(MqttLog::getTopic, pageWrap.getModel().getTopic()); |
| | | } |
| | | if (pageWrap.getModel().getMsg() != null) { |
| | | queryWrapper.lambda().eq(MqttLog::getMsg, pageWrap.getModel().getMsg()); |
| | | } |
| | | if (pageWrap.getModel().getResult() != null) { |
| | | queryWrapper.lambda().eq(MqttLog::getResult, pageWrap.getModel().getResult()); |
| | | } |
| | | for(PageWrap.SortData sortData: pageWrap.getSorts()) { |
| | | if (sortData.getDirection().equalsIgnoreCase(PageWrap.DESC)) { |
| | | queryWrapper.orderByDesc(sortData.getProperty()); |
| | | } else { |
| | | queryWrapper.orderByAsc(sortData.getProperty()); |
| | | } |
| | | } |
| | | return PageData.from(mqttLogMapper.selectPage(page, queryWrapper)); |
| | | } |
| | | |
| | | @Override |
| | | public long count(MqttLog mqttLog) { |
| | | QueryWrapper<MqttLog> wrapper = new QueryWrapper<>(mqttLog); |
| | | return mqttLogMapper.selectCount(wrapper); |
| | | } |
| | | } |
| | |
| | | IPage<Sites> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity()); |
| | | QueryWrapper<Sites> queryWrapper = new QueryWrapper<>(); |
| | | Utils.MP.blankToNull(pageWrap.getModel()); |
| | | // queryWrapper.select("*,(select count(r.id) from locks r where r.site_id = sites.id) as localCount" + |
| | | queryWrapper.select("*,(select count(r.bike_code) from locks r where r.site_id = sites.id and r.bike_code is null and r.bike_code !='' ) as bikeCount"); |
| | | queryWrapper.select("*,(select count(r.id) from locks r where r.site_id = sites.id) as all_lock_num" + |
| | | ",(select count(r.bike_code) from locks r where r.site_id = sites.id and r.bike_code is null and r.bike_code !='' ) as bikeCount"); |
| | | // Page<SitesMonitorDTO> sitesMonitorDTO = sitesMapper.getSitesMonitorDTO(page, pageWrap.getModel().getCode(), pageWrap.getModel().getName()); |
| | | queryWrapper.lambda().like(StringUtils.isNotBlank(pageWrap.getModel().getCode()),Sites::getCode,pageWrap.getModel().getCode()); |
| | | queryWrapper.lambda().like(StringUtils.isNotBlank(pageWrap.getModel().getName()),Sites::getCode,pageWrap.getModel().getName()); |
| | |
| | | |
| | | if (!CollectionUtils.isEmpty(sitesMonitorDTO.getRecords())){ |
| | | sitesMonitorDTO.getRecords().forEach(s->{ |
| | | s.setRate(new BigDecimal(s.getBikeCount()).divide(new BigDecimal(s.getLockNum()).setScale(2))); |
| | | s.setRate(new BigDecimal(s.getBikeCount()).divide(new BigDecimal(s.getAllLockNum()).setScale(2))); |
| | | }); |
| | | } |
| | | |
¶Ô±ÈÐÂÎļþ |
| | |
| | | # èªè¡è½¦ mqtt åè®®ææ¡£ |
| | | |
| | | ## éä¿¡è§è |
| | | - æ¯ä¸ªç«ç¹ä¸ä¸ª mqtt è¿æ¥ï¼clientId 为 SITE_ç«ç¹ç¼å· |
| | | - ä¸ä¸ªç«ç¹ç±é¨ç½²å¨ä¸ä½æºä¸ç软件éè¿canæ»çº¿ä¸å¤ä¸ªééä¿¡ï¼å¹¶ä¸æå¡å¨éè¿mqttåæ¶æ¯è½¬å |
| | | |
| | | |
| | | ## sub: device/lock/{id}/info |
| | | > **éä¿¡æ¯ï¼å¨åå§åãç¶æåæ´æ¶ä¼æ¨ééç宿´ç¶æ** |
| | | - æ°æ® |
| | | ```json |
| | | { |
| | | "siteId": "1015", // ç«ç¹ç¼å· |
| | | "code": "01", // éç¼å· |
| | | "id": "123456789103", // éå¯ä¸id,å主é¢{id} |
| | | "status": 1, // ç¶æï¼0éå, 1æå¼ï¼2è¿è¡ä¸, 3å¼å¸¸ |
| | | "bikeCode": "1234567890" // èªè¡è½¦icå¡å·ï¼æ 车为空 |
| | | } |
| | | ``` |
| | | |
| | | ## pub: device/lock/{id}/getInfo |
| | | > 宿¶è·åéä¿¡æ¯ |
| | | - æ°æ® |
| | | ```json |
| | | {} |
| | | ``` |
| | | |
| | | ## pub: device/lock/{id}/unlock |
| | | > å¼éï¼æå失败å¯å
³æ³¨infoæ¶æ¯æ¨é |
| | | - æ°æ® |
| | | ```json |
| | | {} |
| | | ``` |
| | | |
| | | ## sub: device/lock/{id}/bike |
| | | > è¿è½¦, è¿è½¦æåæ¶ï¼è·å¾æè¿è½¦è¾icå¡å·æ¨é |
| | | - æ°æ® |
| | | ```json |
| | | { |
| | | "bikeCode": "1234567890", |
| | | "time": "2023-10-13 10:12:90" // ç«ç¹ä¸ä½æºæ¶å°è¿è½¦æä»¤çæ¶é´ï¼ä»
ååèï¼è¯·ä»¥æå¡å¨æ¶é´ä¸ºå |
| | | } |
| | | ``` |