Commit e0dcf3b0 by 吕明尚

更改开门操作为Service

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