Commit 74b5e660 by 吕明尚

订单结束增加断电操作

parent 15aa66e6
package share.common.enums;
public enum OpTypeEnum {
//10:开门,20:取电,30:锁门,40:断电
OPEN_DOOR("10", "开门"),
GET_ELECTRIC("20", "取电"),
LOCK_DOOR("30", "锁门"),
CUT_ELECTRIC("40", "断电");
private String code;
private String name;
OpTypeEnum() {
}
OpTypeEnum(String code, String name) {
this.code = code;
this.name = name;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
......@@ -59,6 +59,11 @@ public class OrderTask {
@Autowired
private RedisUtil redisUtils;
@Autowired
private DeviceOpService deviceOpService;
final int ZERO = 0;
public void autoCancel() {
String redisKey = Constants.ORDER_AUTO_CANCEL_KEY;
Long size = redisUtil.getListSize(redisKey);
......@@ -230,10 +235,11 @@ public class OrderTask {
room.setUpdateTime(new Date());
}
});
//到达预定时间进行通电
deviceOpService.openOrCloseDevice(item.getRoomId(), item.getConsumerPhone(), OpTypeEnum.GET_ELECTRIC.getCode(), false, ZERO);
}
});
Boolean execute = transactionTemplate.execute(e -> {
//TODO 取电开始
orderService.updateBatchById(sOrders,sOrders.size());
roomService.updateBatchById(roomList,roomList.size());
return true;
......
......@@ -161,7 +161,8 @@ public class RedisTask {
deviceOpService.actionExecute(sOrder.getRoomId(), sOrder.getConsumerPhone(), VoiceEnum.SEND_CUSTOMER.getCode(),
DateUtil.format(new Date(), DatePattern.NORM_DATETIME_PATTERN),
DateUtil.format(DateUtil.offsetMinute(new Date(), 1), DatePattern.NORM_DATETIME_PATTERN), "1");
//延时5分钟断电
deviceOpService.openOrCloseDevice(sOrder.getRoomId(), sOrder.getConsumerPhone(), OpTypeEnum.CUT_ELECTRIC.getCode(), true, FIVE_MINUTES);
}
}
});
......
......@@ -6,6 +6,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import share.common.enums.DeviceType;
import share.common.enums.OpTypeEnum;
import share.common.utils.SecurityUtils;
import share.system.mqtt.MqttGatewayComponent;
import share.system.domain.Device;
......@@ -56,11 +57,11 @@ public class DeviceOpServiceImpl implements DeviceOpService {
for (Device device : list) {
if (DeviceType.DEVICE_CCEE.getCode().equals(device.getDevType())) {
// 门锁
this.deviceOpInit(device.getDevId(), deviceParam.getPhone(), "10", false, 0L);
this.deviceOpInit(device.getDevId(), deviceParam.getPhone(), OpTypeEnum.OPEN_DOOR.getCode(), false, 0L);
}
if (DeviceType.DEVICE_0001.getCode().equals(device.getDevType())) {
// 取电开关
this.deviceOpInit(device.getDevId(), deviceParam.getPhone(), "20", true, 2L);
this.deviceOpInit(device.getDevId(), deviceParam.getPhone(), OpTypeEnum.GET_ELECTRIC.getCode(), true, 2L);
}
}
......@@ -81,11 +82,11 @@ public class DeviceOpServiceImpl implements DeviceOpService {
for (Device device : list) {
if (DeviceType.DEVICE_CCEE.getCode().equals(device.getDevType())) {
// 门锁
this.deviceOpInit(device.getDevId(), phone, "10", false, 0L);
this.deviceOpInit(device.getDevId(), phone, OpTypeEnum.OPEN_DOOR.getCode(), false, 0L);
}
if (DeviceType.DEVICE_0001.getCode().equals(device.getDevType())) {
// 取电开关
this.deviceOpInit(device.getDevId(), phone, "20", true, 3L);
this.deviceOpInit(device.getDevId(), phone, OpTypeEnum.GET_ELECTRIC.getCode(), true, 3L);
}
}
......@@ -236,9 +237,9 @@ public class DeviceOpServiceImpl implements DeviceOpService {
if (room != null) {
LambdaQueryWrapper<Device> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(Device::getRoomId, room.getId());
if ("10".equals(opType) || "30".equals(opType)) {
if (OpTypeEnum.OPEN_DOOR.getCode().equals(opType) || OpTypeEnum.LOCK_DOOR.getCode().equals(opType)) {
queryWrapper.eq(Device::getDevType, DeviceType.DEVICE_CCEE.getCode());
} else if ("20".equals(opType) || "40".equals(opType)) {
} else if (OpTypeEnum.GET_ELECTRIC.getCode().equals(opType) || OpTypeEnum.CUT_ELECTRIC.getCode().equals(opType)) {
queryWrapper.eq(Device::getDevType, DeviceType.DEVICE_0001.getCode());
} else {
return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment