Commit 21b3972c by wuwenlong

Merge remote-tracking branch 'origin/main'

# Conflicts:
#	share-front/src/main/java/share/web/controller/system/SOrderController.java
#	share-system/src/main/java/share/system/service/ISOrderService.java
#	share-system/src/main/java/share/system/service/impl/SOrderServiceImpl.java
parents 2444383f a8366b42
...@@ -181,5 +181,9 @@ public class SStoreController extends BaseController ...@@ -181,5 +181,9 @@ public class SStoreController extends BaseController
return toAjax(sStoreService.insertStoreConsumers(storeId, consumerIds)); return toAjax(sStoreService.insertStoreConsumers(storeId, consumerIds));
} }
/**
* 数据同步
*/
} }
...@@ -140,6 +140,7 @@ spring: ...@@ -140,6 +140,7 @@ spring:
password: "Mqtt@2023cj" password: "Mqtt@2023cj"
defaultTopic: "ydlink/#" defaultTopic: "ydlink/#"
completion-timeout: 15000 completion-timeout: 15000
is-subscribe-topic: true
# token配置 # token配置
token: token:
......
...@@ -137,6 +137,8 @@ spring: ...@@ -137,6 +137,8 @@ spring:
password: "Mqtt@2023cj" password: "Mqtt@2023cj"
defaultTopic: "ydlink/#" defaultTopic: "ydlink/#"
completion-timeout: 15000 completion-timeout: 15000
is-subscribe-topic: true
# token配置 # token配置
token: token:
# 令牌自定义标识 # 令牌自定义标识
......
...@@ -137,6 +137,7 @@ spring: ...@@ -137,6 +137,7 @@ spring:
password: "Mqtt@2023cj" password: "Mqtt@2023cj"
defaultTopic: "ydlink/#" defaultTopic: "ydlink/#"
completion-timeout: 15000 completion-timeout: 15000
is-subscribe-topic: true
# token配置 # token配置
token: token:
......
package share.common.enums;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
/**
* @className: share.common.enums.MqttOpenType
* @description: 设备类型
* @author: lwj
* @create: 2023-11-04 15:35
*/
public enum DeviceType {
DEVICE_CCEE("CCEE", "门锁"),
DEVICE_0001("0001", "取电开关"),
DEVICE_GATEWAY("7", "网关")
;
private String code;
private String name;
DeviceType(String code, String name) {
this.code = code;
this.name = name;
}
//code转字符串1,2,3,4
public static String getCodeList() {
List<String> list = Arrays.stream(DeviceType.values()).map(DeviceType::getCode).collect(Collectors.toList());
return String.join(",", list);
}
public String getCode() {
return code;
}
public String getName() {
return name;
}
}
...@@ -56,6 +56,9 @@ public class MqttConfig { ...@@ -56,6 +56,9 @@ public class MqttConfig {
@Value("${spring.mqtt.defaultTopic}") @Value("${spring.mqtt.defaultTopic}")
private String defaultTopic; private String defaultTopic;
@Value("${spring.mqtt.is-subscribe-topic}")
private boolean isSubscribeTopic;
private SnowFlakeUtil snowFlakeUtil = new SnowFlakeUtil(0, 0); private SnowFlakeUtil snowFlakeUtil = new SnowFlakeUtil(0, 0);
@Resource @Resource
...@@ -163,8 +166,11 @@ public class MqttConfig { ...@@ -163,8 +166,11 @@ public class MqttConfig {
@ServiceActivator(inputChannel = "mqttInputChannel") @ServiceActivator(inputChannel = "mqttInputChannel")
public MessageHandler handler() { public MessageHandler handler() {
return message -> { return message -> {
//接收到的消息由这个处理器进行处理 // mqtt订阅消息由share_admin服务端处理
mqttMessageHandler.handleMessage(message); if (isSubscribeTopic) {
//接收到的消息由这个处理器进行处理
mqttMessageHandler.handleMessage(message);
}
}; };
} }
......
...@@ -62,6 +62,7 @@ ...@@ -62,6 +62,7 @@
<artifactId>spring-boot-maven-plugin</artifactId> <artifactId>spring-boot-maven-plugin</artifactId>
<version>2.5.15</version> <version>2.5.15</version>
<configuration> <configuration>
<includeSystemScope>true</includeSystemScope>
<fork>true</fork> <!-- 如果没有该配置,devtools不会生效 --> <fork>true</fork> <!-- 如果没有该配置,devtools不会生效 -->
</configuration> </configuration>
<executions> <executions>
......
...@@ -13,12 +13,15 @@ import share.common.core.domain.AjaxResult; ...@@ -13,12 +13,15 @@ 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.request.CreateOrderRequest; import share.system.request.CreateOrderRequest;
import share.system.request.OrderComputedPriceRequest; import share.system.request.OrderComputedPriceRequest;
import share.system.response.ComputedOrderPriceResponse; import share.system.response.ComputedOrderPriceResponse;
import share.system.response.OrderPayResultResponse; import share.system.response.OrderPayResultResponse;
import share.system.service.DeviceLogService;
import share.system.service.ISOrderService; import share.system.service.ISOrderService;
import share.common.core.page.TableDataInfo; import share.common.core.page.TableDataInfo;
...@@ -41,6 +44,10 @@ public class SOrderController extends BaseController ...@@ -41,6 +44,10 @@ public class SOrderController extends BaseController
@Autowired @Autowired
private RedisUtil redisUtil; private RedisUtil redisUtil;
@Autowired
private MqttGatewayComponent mqttGatewayComponent;
@Autowired
private DeviceLogService deviceLogService;
/** /**
* 查询订单列表 * 查询订单列表
...@@ -85,8 +92,12 @@ public class SOrderController extends BaseController ...@@ -85,8 +92,12 @@ 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<String> openDoor(@RequestBody Long id){ public R<Integer> openDoor(@RequestBody String orderNo) {
return R.ok(sOrderService.openDoor(id)); MqttxVo mqttxVo = sOrderService.openDoor(orderNo);
mqttGatewayComponent.sendToMqtt(mqttxVo.getTopic(), 0, mqttxVo.getPayload());
// 写日志记录
int result = deviceLogService.addDeviceLog(mqttxVo);
return R.ok(result);
} }
/** /**
......
...@@ -9,10 +9,13 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -9,10 +9,13 @@ 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.IPackService; import share.system.service.IPackService;
import share.system.service.ISRoomService; import share.system.service.ISRoomService;
import share.common.core.page.TableDataInfo; import share.common.core.page.TableDataInfo;
...@@ -36,6 +39,10 @@ public class SRoomController extends BaseController { ...@@ -36,6 +39,10 @@ public class SRoomController extends BaseController {
@Autowired @Autowired
private IPackService packService; private IPackService packService;
@Autowired
private MqttGatewayComponent mqttGatewayComponent;
@Autowired
private DeviceLogService deviceLogService;
/** /**
* 查询房间列表 * 查询房间列表
...@@ -79,8 +86,12 @@ public class SRoomController extends BaseController { ...@@ -79,8 +86,12 @@ 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<String> openDoor(@RequestBody Long id) { public R<Integer> openDoor(@RequestBody Long id) {
return R.ok(sRoomService.openDoor(id)); MqttxVo mqttxVo = sRoomService.openDoor(id);
mqttGatewayComponent.sendToMqtt(mqttxVo.getTopic(), 0, mqttxVo.getPayload());
// 写日志记录
int result = deviceLogService.addDeviceLog(mqttxVo);
return R.ok(result);
} }
/** /**
......
package share.web.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import share.common.enums.DeviceType;
import share.framework.mqtt.MqttGatewayComponent;
import share.system.domain.Device;
import share.system.domain.SRoom;
import share.system.domain.vo.DeviceParamVo;
import share.system.domain.vo.MqttxVo;
import share.system.mapper.DeviceMapper;
import share.system.mapper.SRoomMapper;
import share.system.service.DeviceLogService;
import share.system.service.MqttxService;
import java.util.List;
/**
* @className: share.web.service.DeviceOpService
* @description: 设备操作接口
* @author: lwj
* @create: 2023-11-09 10:38
*/
@Service
public class DeviceOpService {
@Autowired
private MqttGatewayComponent mqttGatewayComponent;
@Autowired
private SRoomMapper roomMapper;
@Autowired
private MqttxService mqttxService;
@Autowired
private DeviceLogService deviceLogService;
@Autowired
private DeviceMapper deviceMapper;
/**
* 小程序订单开门
* @param deviceParam
*/
public void openDoor(DeviceParamVo deviceParam) {
SRoom room = roomMapper.selectSRoomById(deviceParam.getRoomId());
if (room != null) {
Device param = new Device();
param.setRoomId(room.getId());
List<Device> list = deviceMapper.selectDeviceList(param);
for (Device device : list) {
if (DeviceType.DEVICE_CCEE.getCode().equals(device.getDevType())) {
// 门锁
this.deviceOpInit(device.getDevId(), deviceParam.getPhone(), "10");
}
if (DeviceType.DEVICE_0001.getCode().equals(device.getDevType())) {
// 取电开关
this.deviceOpInit(device.getDevId(), deviceParam.getPhone(), "20");
}
}
}
}
/**
* 小程序订单开门
* @param roomId 房间id
* @param phone 操作用户
*/
public void openDoor(Long roomId, String phone) {
SRoom room = roomMapper.selectSRoomById(roomId);
if (room != null) {
Device param = new Device();
param.setRoomId(room.getId());
List<Device> list = deviceMapper.selectDeviceList(param);
for (Device device : list) {
if (DeviceType.DEVICE_CCEE.getCode().equals(device.getDevType())) {
// 门锁
this.deviceOpInit(device.getDevId(), phone, "10");
}
if (DeviceType.DEVICE_0001.getCode().equals(device.getDevType())) {
// 取电开关
this.deviceOpInit(device.getDevId(), phone, "20");
}
}
}
}
private void deviceOpInit(String devId, String phone, String opType) {
// 获取mqtt的topic、payload
MqttxVo mqttxVo = mqttxService.openOrCloseDevice(devId, phone, opType);
// 发送mqtt消息
mqttGatewayComponent.sendToMqtt(mqttxVo.getTopic(), 0, mqttxVo.getPayload());
// 写日志记录
deviceLogService.addDeviceLog(mqttxVo);
}
}
...@@ -9,7 +9,7 @@ ruoyi: ...@@ -9,7 +9,7 @@ ruoyi:
# 实例演示开关 # 实例演示开关
demoEnabled: true demoEnabled: true
# 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath) # 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath)
profile: /home/gxpt/uploadPath profile: /Users/workspace/uploadPath
# 获取ip地址开关 # 获取ip地址开关
addressEnabled: false addressEnabled: false
# 验证码类型 math 数字计算 char 字符验证 # 验证码类型 math 数字计算 char 字符验证
...@@ -60,9 +60,9 @@ spring: ...@@ -60,9 +60,9 @@ spring:
druid: druid:
# 主库数据源 # 主库数据源
master: master:
url: jdbc:mysql://127.0.0.1:3306/xzdb?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8 url: jdbc:mysql://129.211.46.84:3306/sharedb?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8
username: root username: root
password: 1234 password: whxz2019
# 从库数据源 # 从库数据源
slave: slave:
# 从数据源开关/默认关闭 # 从数据源开关/默认关闭
...@@ -122,7 +122,7 @@ spring: ...@@ -122,7 +122,7 @@ spring:
# 数据库索引 # 数据库索引
database: 0 database: 0
# 密码 # 密码
password: password: 123456
# 连接超时时间 # 连接超时时间
timeout: 10s timeout: 10s
lettuce: lettuce:
...@@ -142,6 +142,7 @@ spring: ...@@ -142,6 +142,7 @@ spring:
password: "Mqtt@2023cj" password: "Mqtt@2023cj"
defaultTopic: "ydlink/#" defaultTopic: "ydlink/#"
completion-timeout: 15000 completion-timeout: 15000
is-subscribe-topic: false
# token配置 # token配置
token: token:
...@@ -190,4 +191,4 @@ dianping: ...@@ -190,4 +191,4 @@ dianping:
appKey: a59ea57cd1eb4737 appKey: a59ea57cd1eb4737
appSecret: 0caaabb7fda1c1be46636171548dcf510d1fb706 appSecret: 0caaabb7fda1c1be46636171548dcf510d1fb706
authCode: abcdefghijklmnopqrstuvwxyz authCode: abcdefghijklmnopqrstuvwxyz
openShoopUuid: 5067d2db1311d32a0ff366c79a73df51 openShoopUuid: cf0eb0891f9e366bcda10cb7f6f23b25
...@@ -142,6 +142,7 @@ spring: ...@@ -142,6 +142,7 @@ spring:
password: "Mqtt@2023cj" password: "Mqtt@2023cj"
defaultTopic: "ydlink/#" defaultTopic: "ydlink/#"
completion-timeout: 15000 completion-timeout: 15000
is-subscribe-topic: false
# token配置 # token配置
token: token:
...@@ -191,4 +192,4 @@ dianping: ...@@ -191,4 +192,4 @@ dianping:
appKey: a59ea57cd1eb4737 appKey: a59ea57cd1eb4737
appSecret: 0caaabb7fda1c1be46636171548dcf510d1fb706 appSecret: 0caaabb7fda1c1be46636171548dcf510d1fb706
authCode: abcdefghijklmnopqrstuvwxyz authCode: abcdefghijklmnopqrstuvwxyz
openShoopUuid: 5067d2db1311d32a0ff366c79a73df51 openShoopUuid: cf0eb0891f9e366bcda10cb7f6f23b25
\ No newline at end of file \ No newline at end of file
...@@ -142,6 +142,7 @@ spring: ...@@ -142,6 +142,7 @@ spring:
password: "Mqtt@2023cj" password: "Mqtt@2023cj"
defaultTopic: "ydlink/#" defaultTopic: "ydlink/#"
completion-timeout: 15000 completion-timeout: 15000
is-subscribe-topic: false
# token配置 # token配置
token: token:
...@@ -191,4 +192,4 @@ dianping: ...@@ -191,4 +192,4 @@ dianping:
appKey: a59ea57cd1eb4737 appKey: a59ea57cd1eb4737
appSecret: 0caaabb7fda1c1be46636171548dcf510d1fb706 appSecret: 0caaabb7fda1c1be46636171548dcf510d1fb706
authCode: abcdefghijklmnopqrstuvwxyz authCode: abcdefghijklmnopqrstuvwxyz
openShoopUuid: 5067d2db1311d32a0ff366c79a73df51 openShoopUuid: cf0eb0891f9e366bcda10cb7f6f23b25
\ No newline at end of file \ No newline at end of file
...@@ -25,4 +25,7 @@ public class DeviceParamVo extends BaseEntity { ...@@ -25,4 +25,7 @@ public class DeviceParamVo extends BaseEntity {
/** 操作用户 */ /** 操作用户 */
private String phone; private String phone;
/** 开门房间ID */
private Long roomId;
} }
...@@ -60,4 +60,6 @@ public interface SOrderMapper extends BaseMapper<SOrder> ...@@ -60,4 +60,6 @@ public interface SOrderMapper extends BaseMapper<SOrder>
* @return 结果 * @return 结果
*/ */
public int deleteSOrderByIds(Long[] ids); public int deleteSOrderByIds(Long[] ids);
SOrder selectSOrderByNo();
} }
...@@ -6,6 +6,7 @@ import java.util.List; ...@@ -6,6 +6,7 @@ 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;
...@@ -98,7 +99,7 @@ public interface ISOrderService extends IService<SOrder> ...@@ -98,7 +99,7 @@ public interface ISOrderService extends IService<SOrder>
*/ */
SOrder getByOrderNo(String orderNo); SOrder getByOrderNo(String orderNo);
String openDoor(Long id); MqttxVo openDoor(String orderNo);
SOrder getInfoByEntity(SOrder orderParam); SOrder getInfoByEntity(SOrder orderParam);
......
...@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.service.IService; ...@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
import share.system.domain.Device; import share.system.domain.Device;
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.SRoomVo; import share.system.domain.vo.SRoomVo;
/** /**
...@@ -84,7 +85,7 @@ public interface ISRoomService extends IService<SRoom> ...@@ -84,7 +85,7 @@ public interface ISRoomService extends IService<SRoom>
List<SRoom> selectSroomListByStroeId(Long storeId); List<SRoom> selectSroomListByStroeId(Long storeId);
String openDoor(Long id); MqttxVo openDoor(Long id);
List<SPack> getPackByRoomId(Long id); List<SPack> getPackByRoomId(Long id);
......
...@@ -22,10 +22,12 @@ import share.common.utils.DateUtil; ...@@ -22,10 +22,12 @@ 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;
import share.system.domain.vo.SOrderVo; import share.system.domain.vo.SOrderVo;
import share.system.domain.vo.MqttxVo;
import share.system.domain.vo.SRoomVo; import share.system.domain.vo.SRoomVo;
import share.system.mapper.SOrderMapper; import share.system.mapper.SOrderMapper;
import share.system.request.CreateOrderRequest; import share.system.request.CreateOrderRequest;
...@@ -75,6 +77,12 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper,SOrder> implemen ...@@ -75,6 +77,12 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper,SOrder> implemen
@Autowired @Autowired
private RedisUtil redisUtil; private RedisUtil redisUtil;
@Autowired
private MqttxService mqttxService;
@Autowired
private DeviceService deviceService;
/** /**
* 查询订单 * 查询订单
* *
...@@ -408,8 +416,8 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper,SOrder> implemen ...@@ -408,8 +416,8 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper,SOrder> implemen
} }
@Override @Override
public String openDoor(Long id) { public MqttxVo openDoor(String orderNo) {
SOrder sOrder = sOrderMapper.selectSOrderById(id); SOrder sOrder = sOrderMapper.selectSOrderByNo();
if (Objects.isNull(sOrder)) { if (Objects.isNull(sOrder)) {
throw new BaseException("订单不存在!"); throw new BaseException("订单不存在!");
} }
...@@ -417,12 +425,15 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper,SOrder> implemen ...@@ -417,12 +425,15 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper,SOrder> implemen
if (Objects.isNull(sRoomVo)) { if (Objects.isNull(sRoomVo)) {
throw new BaseException("房间不存在!"); throw new BaseException("房间不存在!");
} }
//根据门锁编号,电机控制,密码进行开门 LambdaQueryWrapper<Device> queryWrapper = new LambdaQueryWrapper<>();
String doorLockCode = sRoomVo.getDoorLockCode(); queryWrapper.eq(Device::getRoomId, sOrder.getRoomId());
String electricControlCode = sRoomVo.getElectricControlCode(); Device one = deviceService.getOne(queryWrapper);
String password = sRoomVo.getPassword(); if (Objects.isNull(one)) {
if(true){ throw new BaseException("设备不存在!");
//TODO 开门成功 }
SConsumer user = FrontTokenComponent.getWxSConsumerEntry();
MqttxVo mqttxVo = mqttxService.openOrCloseDevice(one.getDevId(), user.getNickName(), "10");
if (sOrder.getStatus().equals(OrderStatusEnum.INUSE.getCode())) {
//更改订单状态,房间状态,开始时间,结束时间 //更改订单状态,房间状态,开始时间,结束时间
sOrder.setStatus(1); sOrder.setStatus(1);
//计算预约开始和结束时间时长 //计算预约开始和结束时间时长
...@@ -431,11 +442,8 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper,SOrder> implemen ...@@ -431,11 +442,8 @@ 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 "开门成功";
}else{
//TODO 开门失败
return "开门失败";
} }
return mqttxVo;
} }
private BigDecimal computeTotalPrice(BigDecimal unitPrice, Date startTime, Date endTime){ private BigDecimal computeTotalPrice(BigDecimal unitPrice, Date startTime, Date endTime){
......
...@@ -8,11 +8,13 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; ...@@ -8,11 +8,13 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import share.common.enums.RoleTypeEnum; import share.common.enums.RoleTypeEnum;
import share.common.exception.base.BaseException;
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.system.domain.*; import share.system.domain.*;
import share.system.domain.vo.FrontTokenComponent; import share.system.domain.vo.FrontTokenComponent;
import share.system.domain.vo.MqttxVo;
import share.system.domain.vo.SRoomVo; import share.system.domain.vo.SRoomVo;
import share.system.mapper.DeviceMapper; import share.system.mapper.DeviceMapper;
import share.system.mapper.SRoomMapper; import share.system.mapper.SRoomMapper;
...@@ -39,6 +41,10 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements ...@@ -39,6 +41,10 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements
private IRoomPackService roomPackService; private IRoomPackService roomPackService;
@Autowired @Autowired
private DeviceMapper deviceMapper; private DeviceMapper deviceMapper;
@Autowired
private DeviceService deviceService;
@Autowired
private MqttxService mqttxService;
/** /**
...@@ -211,7 +217,7 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements ...@@ -211,7 +217,7 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements
} }
@Override @Override
public String openDoor(Long id) { public MqttxVo 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("当前用户不是保洁人员");
...@@ -220,12 +226,14 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements ...@@ -220,12 +226,14 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements
if (Objects.isNull(room)) { if (Objects.isNull(room)) {
throw new RuntimeException("房间不存在"); throw new RuntimeException("房间不存在");
} }
//TODO 调用开门接口 LambdaQueryWrapper<Device> queryWrapper = new LambdaQueryWrapper<>();
if (true) { queryWrapper.eq(Device::getRoomId, id);
return "开门成功"; Device one = deviceService.getOne(queryWrapper);
} else { if (Objects.isNull(one)) {
return "开门失败"; throw new BaseException("设备不存在!");
} }
MqttxVo mqttxVo = mqttxService.openOrCloseDevice(one.getDevId(), user.getNickName(), "10");
return mqttxVo;
} }
@Override @Override
......
...@@ -125,6 +125,10 @@ ...@@ -125,6 +125,10 @@
<include refid="selectSOrderVo"/> <include refid="selectSOrderVo"/>
where id = #{id} where id = #{id}
</select> </select>
<select id="selectSOrderByNo" resultMap="SOrderResult" parameterType="String">
<include refid="selectSOrderVo"/>
where order_no=#{orderNo}
</select>
<insert id="insertSOrder" parameterType="SOrder" useGeneratedKeys="true" keyProperty="id"> <insert id="insertSOrder" parameterType="SOrder" useGeneratedKeys="true" keyProperty="id">
insert into s_order insert into s_order
......
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