|
@@ -11,6 +11,7 @@ import com.zd.model.domain.ResultData;
|
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
@@ -32,6 +33,9 @@ public class DeviceRemoteController {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private RedisService redisService;
|
|
private RedisService redisService;
|
|
|
|
|
|
|
|
|
|
+ @Value("${sys.lockTimer:30}")
|
|
|
|
|
+ private Integer lockTimer;
|
|
|
|
|
+
|
|
|
|
|
|
|
|
@PostMapping("/cabinetLock")
|
|
@PostMapping("/cabinetLock")
|
|
|
public ResultData cabinetLock(@RequestBody @Valid CabinetLock cabinetLock){
|
|
public ResultData cabinetLock(@RequestBody @Valid CabinetLock cabinetLock){
|
|
@@ -54,44 +58,30 @@ public class DeviceRemoteController {
|
|
|
ops.flush();
|
|
ops.flush();
|
|
|
logger.info("柜锁开锁指令:" + instruct);
|
|
logger.info("柜锁开锁指令:" + instruct);
|
|
|
|
|
|
|
|
- Thread.sleep(1500);
|
|
|
|
|
- /*ops.write(ReUtil.hexStringToByteArray(instruct));
|
|
|
|
|
- ops.flush();
|
|
|
|
|
-
|
|
|
|
|
- Thread.sleep(300);
|
|
|
|
|
- ops.write(ReUtil.hexStringToByteArray(instruct));
|
|
|
|
|
- ops.flush();
|
|
|
|
|
- Thread.sleep(500);
|
|
|
|
|
- ops.write(ReUtil.hexStringToByteArray(instruct));
|
|
|
|
|
- ops.flush();
|
|
|
|
|
- Thread.sleep(300);
|
|
|
|
|
- ops.write(ReUtil.hexStringToByteArray(instruct));
|
|
|
|
|
- ops.flush();
|
|
|
|
|
|
|
+ instruct = CRCCHECK.getReadLockOrder(Integer.parseInt(cabinetV2Lock.getLockId()));
|
|
|
Thread.sleep(500);
|
|
Thread.sleep(500);
|
|
|
- ops.write(ReUtil.hexStringToByteArray(instruct));
|
|
|
|
|
- ops.flush();
|
|
|
|
|
- Thread.sleep(300);
|
|
|
|
|
- ops.write(ReUtil.hexStringToByteArray(instruct));
|
|
|
|
|
- ops.flush();
|
|
|
|
|
|
|
|
|
|
- instruct = CRCCHECK.getReadLockOrder(Integer.parseInt(cabinetV2Lock.getLockId()));
|
|
|
|
|
- ops.write(ReUtil.hexStringToByteArray(instruct));
|
|
|
|
|
- ops.flush();
|
|
|
|
|
|
|
+ int timer = lockTimer;
|
|
|
|
|
+ Integer status;
|
|
|
|
|
+ while (timer > 1){
|
|
|
|
|
|
|
|
- Thread.sleep(500);
|
|
|
|
|
- Integer status = redisService.getCacheObject(relayCode + ":" + cabinetV2Lock.getLockId());
|
|
|
|
|
- logger.info("柜锁开锁锁状态查询:" + instruct + ",开锁结果:" + status);*/
|
|
|
|
|
- /*if(status != null && status == 1){
|
|
|
|
|
- return ResultData.success("开锁成功");
|
|
|
|
|
- }*/
|
|
|
|
|
- // TODO 因样件锁 发送开锁指令后锁未主动弹开,先不关注锁的状态
|
|
|
|
|
- return ResultData.success("开锁成功");
|
|
|
|
|
|
|
+ ops.write(ReUtil.hexStringToByteArray(instruct));
|
|
|
|
|
+ ops.flush();
|
|
|
|
|
+ timer--;
|
|
|
|
|
+
|
|
|
|
|
+ Thread.sleep(900);
|
|
|
|
|
+ status = redisService.getCacheObject(relayCode + ":" + cabinetV2Lock.getLockId());
|
|
|
|
|
+ logger.info("柜锁开锁锁状态查询:" + instruct + ",开锁结果:" + status);
|
|
|
|
|
+ if(status != null && status == 1){
|
|
|
|
|
+ return ResultData.success("开锁成功");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
logger.error("柜锁连接失败:" + e.getMessage());
|
|
logger.error("柜锁连接失败:" + e.getMessage());
|
|
|
return ResultData.fail("柜锁连接失败!");
|
|
return ResultData.fail("柜锁连接失败!");
|
|
|
}
|
|
}
|
|
|
- //return ResultData.fail("开锁失败");
|
|
|
|
|
|
|
+ return ResultData.fail("开锁失败");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|