|
@@ -53,6 +53,13 @@ public class DeviceRemoteController {
|
|
|
@PostMapping("/V2/openLock")
|
|
@PostMapping("/V2/openLock")
|
|
|
public ResultData cabinetV2OpenLock(@RequestBody CabinetV2Lock cabinetV2Lock){
|
|
public ResultData cabinetV2OpenLock(@RequestBody CabinetV2Lock cabinetV2Lock){
|
|
|
|
|
|
|
|
|
|
+ /*try {
|
|
|
|
|
+ Thread.sleep(lockTimer * 1000);
|
|
|
|
|
+ } catch (InterruptedException e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ return ResultData.success("开锁成功");*/
|
|
|
|
|
+
|
|
|
// socket 方式发送
|
|
// socket 方式发送
|
|
|
String instruct = CRCCHECK.getOpenLockOrder(Integer.parseInt(cabinetV2Lock.getLockId()));
|
|
String instruct = CRCCHECK.getOpenLockOrder(Integer.parseInt(cabinetV2Lock.getLockId()));
|
|
|
String relayCode = cabinetV2Lock.getRelayCode();
|
|
String relayCode = cabinetV2Lock.getRelayCode();
|
|
@@ -63,18 +70,24 @@ public class DeviceRemoteController {
|
|
|
ops.flush();
|
|
ops.flush();
|
|
|
logger.info("柜锁开锁指令:" + instruct);
|
|
logger.info("柜锁开锁指令:" + instruct);
|
|
|
|
|
|
|
|
- instruct = CRCCHECK.getReadLockOrder(Integer.parseInt(cabinetV2Lock.getLockId()));
|
|
|
|
|
- Thread.sleep(500);
|
|
|
|
|
|
|
+ Thread.sleep(1000);
|
|
|
|
|
+// ops.write(ReUtil.hexStringToByteArray(instruct));
|
|
|
|
|
+// ops.flush();
|
|
|
|
|
+//
|
|
|
|
|
+// Thread.sleep(1500);
|
|
|
|
|
+// ops.write(ReUtil.hexStringToByteArray(instruct));
|
|
|
|
|
+// ops.flush();
|
|
|
|
|
|
|
|
|
|
+ instruct = CRCCHECK.getReadLockOrder(Integer.parseInt(cabinetV2Lock.getLockId()));
|
|
|
int timer = lockTimer;
|
|
int timer = lockTimer;
|
|
|
Integer status;
|
|
Integer status;
|
|
|
while (timer > 1){
|
|
while (timer > 1){
|
|
|
|
|
|
|
|
ops.write(ReUtil.hexStringToByteArray(instruct));
|
|
ops.write(ReUtil.hexStringToByteArray(instruct));
|
|
|
ops.flush();
|
|
ops.flush();
|
|
|
- timer--;
|
|
|
|
|
|
|
+ timer-=2;
|
|
|
|
|
|
|
|
- Thread.sleep(900);
|
|
|
|
|
|
|
+ Thread.sleep(1900);
|
|
|
status = redisService.getCacheObject(relayCode + ":" + cabinetV2Lock.getLockId());
|
|
status = redisService.getCacheObject(relayCode + ":" + cabinetV2Lock.getLockId());
|
|
|
logger.info("柜锁开锁锁状态查询:" + instruct + ",开锁结果:" + status);
|
|
logger.info("柜锁开锁锁状态查询:" + instruct + ",开锁结果:" + status);
|
|
|
if(status != null && status == 1){
|
|
if(status != null && status == 1){
|
|
@@ -131,32 +144,41 @@ public class DeviceRemoteController {
|
|
|
*/
|
|
*/
|
|
|
@PostMapping("/V2/closeLock")
|
|
@PostMapping("/V2/closeLock")
|
|
|
public ResultData cabinetV2CloseLock(@RequestBody CabinetV2Lock cabinetV2Lock){
|
|
public ResultData cabinetV2CloseLock(@RequestBody CabinetV2Lock cabinetV2Lock){
|
|
|
|
|
+ /*try {
|
|
|
|
|
+ Thread.sleep(5 * 1000);
|
|
|
|
|
+ } catch (InterruptedException e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ return ResultData.success("关锁成功");*/
|
|
|
|
|
|
|
|
// socket 方式发送
|
|
// socket 方式发送
|
|
|
- String instruct = CRCCHECK.getCloseLockOrder(Integer.parseInt(cabinetV2Lock.getLockId()));
|
|
|
|
|
|
|
+// String instruct = CRCCHECK.getCloseLockOrder(Integer.parseInt(cabinetV2Lock.getLockId()));
|
|
|
String relayCode = cabinetV2Lock.getRelayCode();
|
|
String relayCode = cabinetV2Lock.getRelayCode();
|
|
|
OutputStream ops = TCPServer.cacheMap.get(relayCode);
|
|
OutputStream ops = TCPServer.cacheMap.get(relayCode);
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
- ops.write(ReUtil.hexStringToByteArray(instruct));
|
|
|
|
|
|
|
+ /*ops.write(ReUtil.hexStringToByteArray(instruct));
|
|
|
ops.flush();
|
|
ops.flush();
|
|
|
logger.info("柜锁关锁指令:" + instruct);
|
|
logger.info("柜锁关锁指令:" + instruct);
|
|
|
- Thread.sleep(1000);
|
|
|
|
|
|
|
+ Thread.sleep(1000);*/
|
|
|
|
|
|
|
|
- instruct = CRCCHECK.getReadLockOrder(Integer.parseInt(cabinetV2Lock.getLockId()));
|
|
|
|
|
- ops.write(ReUtil.hexStringToByteArray(instruct));
|
|
|
|
|
- ops.flush();
|
|
|
|
|
|
|
+ String instruct = CRCCHECK.getReadLockOrder(Integer.parseInt(cabinetV2Lock.getLockId()));
|
|
|
|
|
+ int timer = lockTimer;
|
|
|
|
|
+ Integer status;
|
|
|
|
|
+ while (timer > 1){
|
|
|
|
|
|
|
|
- Thread.sleep(600);
|
|
|
|
|
- ops.write(ReUtil.hexStringToByteArray(instruct));
|
|
|
|
|
- ops.flush();
|
|
|
|
|
|
|
+ ops.write(ReUtil.hexStringToByteArray(instruct));
|
|
|
|
|
+ ops.flush();
|
|
|
|
|
+ timer-=2;
|
|
|
|
|
|
|
|
- Thread.sleep(1600);
|
|
|
|
|
- Integer status = redisService.getCacheObject(relayCode + ":" + cabinetV2Lock.getLockId());
|
|
|
|
|
- logger.info("柜锁关锁状态查询:" + instruct + ",关锁结果" + status);
|
|
|
|
|
- if(status != null && status == 0){
|
|
|
|
|
- return ResultData.success("关锁成功");
|
|
|
|
|
|
|
+ Thread.sleep(1900);
|
|
|
|
|
+ status = redisService.getCacheObject(relayCode + ":" + cabinetV2Lock.getLockId());
|
|
|
|
|
+ logger.info("柜锁关锁状态查询:" + instruct + ",关锁结果" + status);
|
|
|
|
|
+ if(status != null && status == 0){
|
|
|
|
|
+ return ResultData.success("关锁成功");
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
// return ResultData.success("关锁成功");
|
|
// return ResultData.success("关锁成功");
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|