| | |
| | | |
| | | import React, { useState, useRef, useEffect } from 'react'; |
| | | import { Button, message, Modal, Tag } from 'antd'; |
| | | import { Button, message, Modal, Tag } from 'antd'; |
| | | import { |
| | | FooterToolbar, |
| | | PageContainer, |
| | |
| | | />, |
| | | }, |
| | | { |
| | | title: '模式', |
| | | dataIndex: 'mode', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='mode' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | />, |
| | | }, |
| | | { |
| | | title: '下发时间', |
| | | dataIndex: 'sendTime$', |
| | | valueType: 'text', |
| | |
| | | width: 140, |
| | | filterDropdown: (props) => <DatetimeRangeFilter |
| | | name='sendTime' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | />, |
| | | }, |
| | | { |
| | | title: '命令', |
| | | dataIndex: 'command', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | ellipsis: true, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='command' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | />, |
| | | }, |
| | | { |
| | | title: '系统状态', |
| | | dataIndex: 'systemStatus', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | ellipsis: true, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='systemStatus' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | />, |
| | | }, |
| | | { |
| | | title: '设备工作号', |
| | | dataIndex: 'deviceWrk', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='deviceWrk' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | />, |
| | | }, |
| | | { |
| | | title: '下发状态', |
| | | dataIndex: 'send$', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <SelectFilter |
| | | name='send' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | data={[ |
| | | { label: '未下发', value: 0 }, |
| | | { label: '已下发', value: 1 }, |
| | | ]} |
| | | />, |
| | | }, |
| | | { |
| | | title: '请求响应', |
| | | dataIndex: 'response', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | ellipsis: true, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='response' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | |
| | | width: 140, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='memo' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | />, |
| | | }, |
| | | { |
| | | title: '命令', |
| | | dataIndex: 'command', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='command' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | />, |
| | | }, |
| | | { |
| | | title: '系统状态', |
| | | dataIndex: 'systemStatus', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='systemStatus' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | | />, |
| | | }, |
| | | { |
| | | title: '设备工作号', |
| | | dataIndex: 'deviceWrk', |
| | | valueType: 'text', |
| | | hidden: false, |
| | | width: 140, |
| | | filterDropdown: (props) => <TextFilter |
| | | name='deviceWrk' |
| | | {...props} |
| | | actionRef={actionRef} |
| | | setSearchParam={setSearchParam} |
| | |
| | | import com.zy.asrs.wcs.rcs.News; |
| | | import com.zy.asrs.wcs.rcs.cache.SlaveConnection; |
| | | import com.zy.asrs.wcs.rcs.constant.DeviceRedisConstant; |
| | | import com.zy.asrs.wcs.rcs.entity.BasLiftOpt; |
| | | import com.zy.asrs.wcs.rcs.entity.Device; |
| | | import com.zy.asrs.wcs.rcs.model.CommandResponse; |
| | | import com.zy.asrs.wcs.rcs.model.enums.LiftProtocolStatusType; |
| | | import com.zy.asrs.wcs.rcs.model.enums.SlaveType; |
| | | import com.zy.asrs.wcs.rcs.model.protocol.LiftProtocol; |
| | | import com.zy.asrs.wcs.rcs.service.BasLiftOptService; |
| | | import com.zy.asrs.wcs.rcs.thread.LiftThread; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Component |
| | |
| | | private RedisUtil redisUtil; |
| | | @Autowired |
| | | private TaskService taskService; |
| | | @Autowired |
| | | private BasLiftOptService basLiftOptService; |
| | | |
| | | public synchronized boolean assignWork(Device device, LiftAssignCommand assignCommand) { |
| | | LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, device.getId().intValue()); |
| | |
| | | //取出命令 |
| | | LiftCommand command = commands.get(commandStep); |
| | | |
| | | boolean result = write(command, device); |
| | | if (!result) { |
| | | // 下发命令 |
| | | CommandResponse response = write(command, device); |
| | | |
| | | //保存命令日志 |
| | | BasLiftOpt basLiftOpt = new BasLiftOpt(); |
| | | basLiftOpt.setTaskNo(taskNo); |
| | | basLiftOpt.setLiftNo(liftProtocol.getLiftNo()); |
| | | basLiftOpt.setMode(LiftCommandModeType.get(command.getMode()).desc); |
| | | basLiftOpt.setCommand(JSON.toJSONString(command)); |
| | | basLiftOpt.setSystemStatus(JSON.toJSONString(liftProtocol)); |
| | | basLiftOpt.setDeviceId(device.getId()); |
| | | basLiftOpt.setDeviceWrk(String.valueOf(command.getTaskNo())); |
| | | basLiftOpt.setResponse(response.getMessage());//获取响应 |
| | | basLiftOpt.setSendTime(new Date());//指令下发时间 |
| | | basLiftOpt.setSend(response.getResult() ? 1 : 0); |
| | | basLiftOpt.setHostId(device.getHostId()); |
| | | //保存命令流水 |
| | | basLiftOptService.save(basLiftOpt); |
| | | |
| | | if (!response.getResult()) { |
| | | News.error("提升机命令下发失败,提升机号={},任务数据={}", command.getLiftNo(), JSON.toJSON(command)); |
| | | return false; |
| | | } else { |
| | |
| | | return true; |
| | | } |
| | | |
| | | private synchronized boolean write(LiftCommand command, Device device) { |
| | | private synchronized CommandResponse write(LiftCommand command, Device device) { |
| | | CommandResponse response = new CommandResponse(false); |
| | | if (null == command) { |
| | | News.error("提升机写入命令为空"); |
| | | return false; |
| | | response.setMessage("提升机写入命令为空"); |
| | | return response; |
| | | } |
| | | |
| | | LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, device.getId().intValue()); |
| | | if (liftThread == null) { |
| | | return false; |
| | | return response; |
| | | } |
| | | |
| | | boolean result = false; |
| | | if (command.getMode() == LiftCommandModeType.MOVE.id) { |
| | | result = liftThread.move(command); |
| | | response = liftThread.move(command); |
| | | } else if (command.getMode() == LiftCommandModeType.PALLET_INOUT.id) { |
| | | result = liftThread.palletInOut(command); |
| | | response = liftThread.palletInOut(command); |
| | | } else if (command.getMode() == LiftCommandModeType.LOCK.id) { |
| | | result = liftThread.lock(command); |
| | | response = liftThread.lock(command); |
| | | } else if (command.getMode() == LiftCommandModeType.UNLOCK.id) { |
| | | result = liftThread.unlock(command); |
| | | response = liftThread.unlock(command); |
| | | } else if (command.getMode() == LiftCommandModeType.RESET.id) { |
| | | result = liftThread.reset(command); |
| | | response = liftThread.reset(command); |
| | | } |
| | | return result; |
| | | return response; |
| | | } |
| | | |
| | | } |
| | |
| | | package com.zy.asrs.wcs.system.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.zy.asrs.framework.common.Cools; |
| | | import com.zy.asrs.framework.common.R; |
| | |
| | | public R page(@RequestBody Map<String, Object> map) { |
| | | BaseParam baseParam = buildParam(map, BaseParam.class); |
| | | PageParam<BasLiftOpt, BaseParam> pageParam = new PageParam<>(baseParam, BasLiftOpt.class); |
| | | return R.ok().add(basLiftOptService.page(pageParam, pageParam.buildWrapper(true))); |
| | | QueryWrapper<BasLiftOpt> wrapper = pageParam.buildWrapper(true); |
| | | wrapper.orderByDesc("send_time"); |
| | | return R.ok().add(basLiftOptService.page(pageParam, wrapper)); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('rcs:basLiftOpt:list')") |
| | |
| | | @ApiModelProperty(value= "设备ID") |
| | | private Long deviceId; |
| | | |
| | | /** |
| | | * 模式 |
| | | */ |
| | | @ApiModelProperty(value= "模式") |
| | | private String mode; |
| | | |
| | | /** |
| | | * 下发状态 0: 失败 1: 成功 |
| | | */ |
| | | @ApiModelProperty(value= "下发状态 0: 失败 1: 成功 ") |
| | | private Integer send; |
| | | |
| | | /** |
| | | * 请求响应 |
| | | */ |
| | | @ApiModelProperty(value= "请求响应") |
| | | private String response; |
| | | |
| | | public BasLiftOpt() {} |
| | | |
| | | public BasLiftOpt(Integer taskNo,Integer liftNo,Date sendTime,Date updateTime,Long updateBy,String memo,String command,String systemStatus,String deviceWrk,Integer deleted,Long hostId,Long deviceId) { |
| | |
| | | return null; |
| | | } |
| | | |
| | | public String getSend$(){ |
| | | if (null == this.send){ return null; } |
| | | switch (this.send){ |
| | | case 0: |
| | | return "失败"; |
| | | case 1: |
| | | return "成功"; |
| | | default: |
| | | return String.valueOf(this.send); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | import com.zy.asrs.wcs.core.model.enums.LiftCommandModeType; |
| | | import com.zy.asrs.wcs.core.model.enums.MotionCtgType; |
| | | import com.zy.asrs.wcs.rcs.entity.Device; |
| | | import com.zy.asrs.wcs.rcs.model.CommandResponse; |
| | | import com.zy.asrs.wcs.rcs.model.enums.LiftProtocolStatusType; |
| | | import com.zy.asrs.wcs.rcs.model.protocol.LiftProtocol; |
| | | |
| | |
| | | |
| | | Device getDevice();//获取设备信息 |
| | | |
| | | boolean move(LiftCommand command);//升降移动 |
| | | CommandResponse move(LiftCommand command);//升降移动 |
| | | |
| | | boolean palletInOut(LiftCommand command);//托盘出入 |
| | | CommandResponse palletInOut(LiftCommand command);//托盘出入 |
| | | |
| | | boolean lock(LiftCommand command);//锁定提升机 |
| | | CommandResponse lock(LiftCommand command);//锁定提升机 |
| | | |
| | | boolean unlock(LiftCommand command);//解锁提升机 |
| | | CommandResponse unlock(LiftCommand command);//解锁提升机 |
| | | |
| | | boolean reset(LiftCommand command);//复位 |
| | | CommandResponse reset(LiftCommand command);//复位 |
| | | |
| | | boolean isIdle();//是否空闲 |
| | | |
| | |
| | | import com.zy.asrs.wcs.rcs.cache.OutputQueue; |
| | | import com.zy.asrs.wcs.rcs.entity.Device; |
| | | import com.zy.asrs.wcs.rcs.entity.DeviceDataLog; |
| | | import com.zy.asrs.wcs.rcs.model.CommandResponse; |
| | | import com.zy.asrs.wcs.rcs.model.enums.LiftProtocolStatusType; |
| | | import com.zy.asrs.wcs.rcs.model.protocol.LiftProtocol; |
| | | import com.zy.asrs.wcs.rcs.service.DeviceDataLogService; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public boolean move(LiftCommand command) { |
| | | public CommandResponse move(LiftCommand command) { |
| | | return write(command); |
| | | } |
| | | |
| | | @Override |
| | | public boolean palletInOut(LiftCommand command) { |
| | | public CommandResponse palletInOut(LiftCommand command) { |
| | | return write(command); |
| | | } |
| | | |
| | | private boolean write(LiftCommand command) { |
| | | private CommandResponse write(LiftCommand command) { |
| | | CommandResponse response = new CommandResponse(false); |
| | | if (null == command) { |
| | | News.error("提升机写入命令为空"); |
| | | return false; |
| | | response.setMessage("提升机写入命令为空"); |
| | | return response; |
| | | } |
| | | |
| | | List<Integer> list = JSON.parseArray(command.getBody(), Integer.class); |
| | |
| | | liftProtocol.setSendTime(System.currentTimeMillis());//指令下发时间 |
| | | News.info("提升机命令下发[id:{}] >>>>> {}", device.getId(), JSON.toJSON(command)); |
| | | OutputQueue.LIFT.offer(MessageFormat.format("【{0}】[id:{1}] >>>>> 命令下发: {2}", DateUtils.convert(new Date()), device.getId(), JSON.toJSON(command))); |
| | | return true; |
| | | response.setMessage(MessageFormat.format("【{0}】[id:{1}] >>>>> 命令下发: {2}", DateUtils.convert(new Date()), device.getId(), JSON.toJSON(command))); |
| | | response.setResult(true); |
| | | return response; |
| | | } else { |
| | | OutputQueue.LIFT.offer(MessageFormat.format("【{0}】写入提升机plc数据失败 ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), device.getId(), device.getIp(), device.getPort())); |
| | | News.error("写入提升机plc数据失败 ===>> [id:{}] [ip:{}] [port:{}]", device.getId(), device.getIp(), device.getPort()); |
| | | return false; |
| | | response.setMessage(MessageFormat.format("【{0}】写入提升机plc数据失败 ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), device.getId(), device.getIp(), device.getPort())); |
| | | return response; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public boolean lock(LiftCommand command) { |
| | | public CommandResponse lock(LiftCommand command) { |
| | | return write(command); |
| | | } |
| | | |
| | | @Override |
| | | public boolean unlock(LiftCommand command) { |
| | | public CommandResponse unlock(LiftCommand command) { |
| | | return write(command); |
| | | } |
| | | |
| | | @Override |
| | | public boolean reset(LiftCommand command) { |
| | | return false; |
| | | public CommandResponse reset(LiftCommand command) { |
| | | return new CommandResponse(true); |
| | | } |
| | | |
| | | @Override |
| | |
| | | import com.zy.asrs.wcs.rcs.cache.OutputQueue; |
| | | import com.zy.asrs.wcs.rcs.entity.Device; |
| | | import com.zy.asrs.wcs.rcs.entity.DeviceDataLog; |
| | | import com.zy.asrs.wcs.rcs.model.CommandResponse; |
| | | import com.zy.asrs.wcs.rcs.model.enums.LiftProtocolStatusType; |
| | | import com.zy.asrs.wcs.rcs.model.protocol.LiftProtocol; |
| | | import com.zy.asrs.wcs.rcs.service.DeviceDataLogService; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public boolean move(LiftCommand command) { |
| | | public CommandResponse move(LiftCommand command) { |
| | | return write(command); |
| | | } |
| | | |
| | | @Override |
| | | public boolean palletInOut(LiftCommand command) { |
| | | public CommandResponse palletInOut(LiftCommand command) { |
| | | return write(command); |
| | | } |
| | | |
| | | private boolean write(LiftCommand command) { |
| | | private CommandResponse write(LiftCommand command) { |
| | | CommandResponse response = new CommandResponse(false); |
| | | if (null == command) { |
| | | News.error("提升机写入命令为空"); |
| | | return false; |
| | | response.setMessage("提升机写入命令为空"); |
| | | return response; |
| | | } |
| | | |
| | | List<Short> shorts = JSON.parseArray(command.getBody(), Short.class); |
| | |
| | | liftProtocol.setSendTime(System.currentTimeMillis());//指令下发时间 |
| | | News.info("提升机命令下发[id:{}] >>>>> {}", device.getId(), JSON.toJSON(command)); |
| | | OutputQueue.LIFT.offer(MessageFormat.format("【{0}】[id:{1}] >>>>> 命令下发: {2}", DateUtils.convert(new Date()), device.getId(), JSON.toJSON(command))); |
| | | return true; |
| | | response.setMessage(MessageFormat.format("【{0}】[id:{1}] >>>>> 命令下发: {2}", DateUtils.convert(new Date()), device.getId(), JSON.toJSON(command))); |
| | | response.setResult(true); |
| | | return response; |
| | | } else { |
| | | OutputQueue.LIFT.offer(MessageFormat.format("【{0}】写入提升机plc数据失败 ===>> [id:{1}] [ip:{2}] [port:{3}],次数:{}", DateUtils.convert(new Date()), device.getId(), device.getIp(), device.getPort())); |
| | | News.error("写入提升机plc数据失败 ===>> [id:{}] [ip:{}] [port:{}]", device.getId(), device.getIp(), device.getPort()); |
| | | return false; |
| | | response.setMessage(MessageFormat.format("【{0}】写入提升机plc数据失败 ===>> [id:{1}] [ip:{2}] [port:{3}],次数:{}", DateUtils.convert(new Date()), device.getId(), device.getIp(), device.getPort())); |
| | | return response; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public boolean lock(LiftCommand command) { |
| | | return true; |
| | | public CommandResponse lock(LiftCommand command) { |
| | | return new CommandResponse(true); |
| | | } |
| | | |
| | | @Override |
| | | public boolean unlock(LiftCommand command) { |
| | | return true; |
| | | public CommandResponse unlock(LiftCommand command) { |
| | | return new CommandResponse(true); |
| | | } |
| | | |
| | | @Override |
| | | public boolean reset(LiftCommand command) { |
| | | return false; |
| | | public CommandResponse reset(LiftCommand command) { |
| | | return new CommandResponse(false); |
| | | } |
| | | |
| | | @Override |
| | |
| | | import com.zy.asrs.wcs.rcs.News; |
| | | import com.zy.asrs.wcs.rcs.cache.OutputQueue; |
| | | import com.zy.asrs.wcs.rcs.entity.DeviceDataLog; |
| | | import com.zy.asrs.wcs.rcs.model.CommandResponse; |
| | | import com.zy.asrs.wcs.rcs.model.enums.LiftProtocolStatusType; |
| | | import com.zy.asrs.wcs.rcs.model.protocol.LiftProtocol; |
| | | import com.zy.asrs.wcs.rcs.service.DeviceDataLogService; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public synchronized boolean move(LiftCommand command) { |
| | | public synchronized CommandResponse move(LiftCommand command) { |
| | | CommandResponse response = new CommandResponse(false); |
| | | try { |
| | | String loginToken = requestLoginToken(); |
| | | if (loginToken == null) { |
| | | return false; |
| | | return response; |
| | | } |
| | | |
| | | HashMap<String, Object> headers = new HashMap<>(); |
| | | headers.put("Authorization", "Bearer " + loginToken); |
| | | |
| | | String response = new HttpHandler.Builder() |
| | | String responseStr = new HttpHandler.Builder() |
| | | .setUri(API_URL) |
| | | .setPath("/RDS/lifterTask") |
| | | .setHeaders(headers) |
| | | .setJson(command.getBody()) |
| | | .build() |
| | | .doPost(); |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | JSONObject jsonObject = JSON.parseObject(responseStr); |
| | | Integer code = jsonObject.getInteger("code"); |
| | | response.setMessage(JSON.toJSONString(jsonObject)); |
| | | if (code.equals(200)) { |
| | | return true; |
| | | response.setResult(true); |
| | | return response; |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return false; |
| | | return response; |
| | | } |
| | | |
| | | @Override |
| | | public synchronized boolean palletInOut(LiftCommand command) { |
| | | public synchronized CommandResponse palletInOut(LiftCommand command) { |
| | | CommandResponse response = new CommandResponse(false); |
| | | try { |
| | | String loginToken = requestLoginToken(); |
| | | if (loginToken == null) { |
| | | return false; |
| | | return response; |
| | | } |
| | | |
| | | HashMap<String, Object> headers = new HashMap<>(); |
| | | headers.put("Authorization", "Bearer " + loginToken); |
| | | |
| | | String response = new HttpHandler.Builder() |
| | | String responseStr = new HttpHandler.Builder() |
| | | .setUri(API_URL) |
| | | .setPath("/RDS/lifterTask") |
| | | .setHeaders(headers) |
| | | .setJson(command.getBody()) |
| | | .build() |
| | | .doPost(); |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | JSONObject jsonObject = JSON.parseObject(responseStr); |
| | | Integer code = jsonObject.getInteger("code"); |
| | | response.setMessage(JSON.toJSONString(jsonObject)); |
| | | if (code.equals(200)) { |
| | | return true; |
| | | response.setResult(true); |
| | | return response; |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return false; |
| | | return response; |
| | | } |
| | | |
| | | @Override |
| | | public synchronized boolean lock(LiftCommand command) { |
| | | public synchronized CommandResponse lock(LiftCommand command) { |
| | | CommandResponse response = new CommandResponse(false); |
| | | try { |
| | | String loginToken = requestLoginToken(); |
| | | if (loginToken == null) { |
| | | return false; |
| | | return response; |
| | | } |
| | | |
| | | HashMap<String, Object> headers = new HashMap<>(); |
| | | headers.put("Authorization", "Bearer " + loginToken); |
| | | |
| | | String response = new HttpHandler.Builder() |
| | | String responseStr = new HttpHandler.Builder() |
| | | .setUri(API_URL) |
| | | .setPath("/RDS/lifterOperation") |
| | | .setHeaders(headers) |
| | | .setJson(command.getBody()) |
| | | .build() |
| | | .doPost(); |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | JSONObject jsonObject = JSON.parseObject(responseStr); |
| | | Integer code = jsonObject.getInteger("code"); |
| | | response.setMessage(JSON.toJSONString(jsonObject)); |
| | | if (code.equals(200)) { |
| | | return true; |
| | | response.setResult(true); |
| | | return response; |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return false; |
| | | return response; |
| | | } |
| | | |
| | | @Override |
| | | public synchronized boolean unlock(LiftCommand command) { |
| | | public synchronized CommandResponse unlock(LiftCommand command) { |
| | | CommandResponse response = new CommandResponse(false); |
| | | try { |
| | | String loginToken = requestLoginToken(); |
| | | if (loginToken == null) { |
| | | return false; |
| | | return response; |
| | | } |
| | | |
| | | HashMap<String, Object> headers = new HashMap<>(); |
| | | headers.put("Authorization", "Bearer " + loginToken); |
| | | |
| | | String response = new HttpHandler.Builder() |
| | | String responseStr = new HttpHandler.Builder() |
| | | .setUri(API_URL) |
| | | .setPath("/RDS/lifterOperation") |
| | | .setHeaders(headers) |
| | | .setJson(command.getBody()) |
| | | .build() |
| | | .doPost(); |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | JSONObject jsonObject = JSON.parseObject(responseStr); |
| | | Integer code = jsonObject.getInteger("code"); |
| | | response.setMessage(JSON.toJSONString(jsonObject)); |
| | | if (code.equals(200)) { |
| | | return true; |
| | | response.setResult(true); |
| | | return response; |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return false; |
| | | return response; |
| | | } |
| | | |
| | | @Override |
| | | public synchronized boolean reset(LiftCommand command) { |
| | | public synchronized CommandResponse reset(LiftCommand command) { |
| | | CommandResponse response = new CommandResponse(false); |
| | | try { |
| | | String loginToken = requestLoginToken(); |
| | | if (loginToken == null) { |
| | | return false; |
| | | return response; |
| | | } |
| | | |
| | | HashMap<String, Object> headers = new HashMap<>(); |
| | | headers.put("Authorization", "Bearer " + loginToken); |
| | | |
| | | String response = new HttpHandler.Builder() |
| | | String responseStr = new HttpHandler.Builder() |
| | | .setUri(API_URL) |
| | | .setPath("/RDS/lifterOperation") |
| | | .setHeaders(headers) |
| | | .setJson(command.getBody()) |
| | | .build() |
| | | .doPost(); |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | JSONObject jsonObject = JSON.parseObject(responseStr); |
| | | Integer code = jsonObject.getInteger("code"); |
| | | response.setMessage(JSON.toJSONString(jsonObject)); |
| | | if (code.equals(200)) { |
| | | return true; |
| | | response.setResult(true); |
| | | return response; |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return false; |
| | | return response; |
| | | } |
| | | |
| | | @Override |