Commit e0dcf3b0 by 吕明尚

更改开门操作为Service

parent 9a99cf75
......@@ -13,7 +13,6 @@ import share.common.core.domain.AjaxResult;
import share.common.core.domain.R;
import share.common.core.redis.RedisUtil;
import share.common.utils.JsonConvertUtil;
import share.framework.mqtt.MqttGatewayComponent;
import share.system.domain.SOrder;
import share.system.domain.vo.SOrderVo;
import share.system.domain.vo.MqttxVo;
......@@ -45,8 +44,6 @@ public class SOrderController extends BaseController
@Autowired
private RedisUtil redisUtil;
@Autowired
private MqttGatewayComponent mqttGatewayComponent;
@Autowired
private DeviceLogService deviceLogService;
/**
......@@ -92,12 +89,8 @@ public class SOrderController extends BaseController
*/
@ApiOperation(value = "开门")
@RequestMapping(value = "/open/door", method = RequestMethod.POST)
public R<Integer> openDoor(@RequestBody String orderNo) {
MqttxVo mqttxVo = sOrderService.openDoor(orderNo);
mqttGatewayComponent.sendToMqtt(mqttxVo.getTopic(), 0, mqttxVo.getPayload());
// 写日志记录
int result = deviceLogService.addDeviceLog(mqttxVo);
return R.ok(result);
public R<String> openDoor(@RequestBody String orderNo) {
return R.ok(sOrderService.openDoor(orderNo));
}
/**
......
......@@ -9,10 +9,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import share.common.core.controller.BaseController;
import share.common.core.domain.R;
import share.framework.mqtt.MqttGatewayComponent;
import share.system.domain.SPack;
import share.system.domain.SRoom;
import share.system.domain.vo.MqttxVo;
import share.system.domain.vo.RoomStatusVo;
import share.system.domain.vo.SRoomVo;
import share.system.service.DeviceLogService;
......@@ -40,8 +38,6 @@ public class SRoomController extends BaseController {
@Autowired
private IPackService packService;
@Autowired
private MqttGatewayComponent mqttGatewayComponent;
@Autowired
private DeviceLogService deviceLogService;
/**
......@@ -86,12 +82,8 @@ public class SRoomController extends BaseController {
*/
@ApiOperation(value = "专属保洁的开门操作")
@RequestMapping(value = "/open/door", method = RequestMethod.POST)
public R<Integer> openDoor(@RequestBody Long id) {
MqttxVo mqttxVo = sRoomService.openDoor(id);
mqttGatewayComponent.sendToMqtt(mqttxVo.getTopic(), 0, mqttxVo.getPayload());
// 写日志记录
int result = deviceLogService.addDeviceLog(mqttxVo);
return R.ok(result);
public R<String> openDoor(@RequestBody Long id) {
return R.ok(sRoomService.openDoor(id));
}
/**
......
......@@ -6,7 +6,6 @@ import java.util.List;
import com.baomidou.mybatisplus.extension.service.IService;
import share.system.domain.SOrder;
import share.system.domain.vo.SOrderVo;
import share.system.domain.vo.MqttxVo;
import share.system.request.CreateOrderRequest;
import share.system.request.OrderComputedPriceRequest;
import share.system.request.OrderRefundRequest;
......@@ -99,7 +98,7 @@ public interface ISOrderService extends IService<SOrder>
*/
SOrder getByOrderNo(String orderNo);
MqttxVo openDoor(String orderNo);
String openDoor(String orderNo);
SOrder getInfoByEntity(SOrder orderParam);
......
......@@ -85,7 +85,7 @@ public interface ISRoomService extends IService<SRoom>
List<SRoom> selectSroomListByStroeId(Long storeId);
MqttxVo openDoor(Long id);
String openDoor(Long id);
List<SPack> getPackByRoomId(Long id);
......
......@@ -30,6 +30,7 @@ import share.system.service.ISConsumerCouponService;
import share.system.service.ISCouponService;
import share.system.service.QPService;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
......
......@@ -22,7 +22,6 @@ import share.common.utils.DateUtil;
import share.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import share.common.utils.SecurityUtils;
import share.common.utils.bean.BeanUtils;
import share.system.domain.*;
import share.system.domain.vo.FrontTokenComponent;
......@@ -78,10 +77,10 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper,SOrder> implemen
private RedisUtil redisUtil;
@Autowired
private MqttxService mqttxService;
private DeviceService deviceService;
@Autowired
private DeviceService deviceService;
private DeviceOpService deviceOpService;
/**
* 查询订单
......@@ -416,7 +415,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper,SOrder> implemen
}
@Override
public MqttxVo openDoor(String orderNo) {
public String openDoor(String orderNo) {
SOrder sOrder = sOrderMapper.selectSOrderByNo(orderNo);
if (Objects.isNull(sOrder)) {
throw new BaseException("订单不存在!");
......@@ -431,8 +430,6 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper,SOrder> implemen
if (Objects.isNull(one)) {
throw new BaseException("设备不存在!");
}
SConsumer user = FrontTokenComponent.getWxSConsumerEntry();
MqttxVo mqttxVo = mqttxService.openOrCloseDevice(one.getDevId(), user.getNickName(), "10");
if (sOrder.getStatus().equals(OrderStatusEnum.UNUSED.getCode())) {
//更改订单状态,房间状态,开始时间,结束时间
sOrder.setStatus(1);
......@@ -443,7 +440,9 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper,SOrder> implemen
sOrder.setEndDate(DateUtils.addHours(new Date(), bigDecimal.intValue()));
sOrderMapper.updateById(sOrder);
}
return mqttxVo;
SConsumer user = FrontTokenComponent.getWxSConsumerEntry();
deviceOpService.openDoor(sRoomVo.getId(), user.getNickName());
return "开锁成功";
}
private BigDecimal computeTotalPrice(BigDecimal unitPrice, Date startTime, Date endTime){
......
......@@ -45,6 +45,8 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements
private DeviceService deviceService;
@Autowired
private MqttxService mqttxService;
@Autowired
private DeviceOpService deviceOpService;
/**
......@@ -217,7 +219,7 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements
}
@Override
public MqttxVo openDoor(Long id) {
public String openDoor(Long id) {
SConsumer user = FrontTokenComponent.getWxSConsumerEntry();
if (!user.getRoleType().equals(RoleTypeEnum.CLEANER.getCode())) {
throw new RuntimeException("当前用户不是保洁人员");
......@@ -232,8 +234,8 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements
if (Objects.isNull(one)) {
throw new BaseException("设备不存在!");
}
MqttxVo mqttxVo = mqttxService.openOrCloseDevice(one.getDevId(), user.getNickName(), "10");
return mqttxVo;
deviceOpService.openDoor(id, user.getNickName());
return "开锁成功";
}
@Override
......
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