Commit da293421 by 吕明尚

Merge branch 'dev' into test

parents 6bddadb9 c82abfbd
......@@ -216,3 +216,6 @@ dianping:
appSecret: 0caaabb7fda1c1be46636171548dcf510d1fb706
order:
allow-refund-time: 3600
mqtt:
device-op-last-time: -5
device-gateway-last-report-time: -10
\ No newline at end of file
......@@ -213,4 +213,6 @@ dianping:
#订单
order:
allow-refund-time: 3600
mqtt:
device-op-last-time: -5
device-gateway-last-report-time: -10
......@@ -80,11 +80,11 @@ public class SRoom extends BaseEntity
@Excel(name = "其他可能硬件接入参数(备用2)")
private String params2;
// /**
// * 是否脏房
// */
// @Excel(name = "是否脏房(0:否,1:是)")
// private Integer isDirtyRoom;
/**
* 是否脏房
*/
@Excel(name = "是否脏房(0:否,1:是)")
private Integer isDirtyRoom;
/**
* 套餐ID
......
......@@ -115,6 +115,12 @@ public class SRoomVo extends BaseEntity
private Long recordsId;
/**
* 是否脏房
*/
private Integer isDirtyRoom;
/**
* 订单时间
*/
/**
......
......@@ -6,6 +6,7 @@ import java.util.List;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Value;
import share.common.enums.DeviceStatusEnum;
import share.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -26,6 +27,9 @@ public class DeviceGatewayServiceImpl extends ServiceImpl<DeviceGatewayMapper, D
@Autowired
private DeviceGatewayMapper deviceGatewayMapper;
@Value("${mqtt.device-gateway-last-report-time}")
private Integer deviceGatewayLastReportTime;
/**
* 查询设备网关信息
*
......@@ -110,7 +114,7 @@ public class DeviceGatewayServiceImpl extends ServiceImpl<DeviceGatewayMapper, D
list.stream().forEach(gateway -> {
Date lastReportDate = gateway.getLastReportDate();
// 网关上报(最近10分钟内没有上报数据,网关设备离线)
Date startDate = DateUtil.offsetMinute(DateUtil.date(), -10);
Date startDate = DateUtil.offsetMinute(DateUtil.date(), deviceGatewayLastReportTime);
if (lastReportDate != null && lastReportDate.compareTo(startDate) > 0) {
gateway.setStatus(DeviceStatusEnum.DEVICE_ONLINE.getCode());
} else {
......
......@@ -8,6 +8,7 @@ import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import share.common.constant.MqttConstants;
import share.common.enums.*;
......@@ -48,6 +49,8 @@ public class MqttxServiceImpl implements MqttxService {
private DeviceLogMapper deviceLogMapper;
@Autowired
private DeviceStatusLogService deviceStatusLogService;
@Value("${mqtt.device-op-last-time}")
private Integer deviceOpLastTime;
/**
* 清除网关锁id列表
......@@ -557,7 +560,7 @@ public class MqttxServiceImpl implements MqttxService {
Map<String, Device> map = deviceList.stream()
.collect(Collectors.toMap(Device::getDevId, Function.identity()));
// 设备操作日志(最近3分钟内的最新操作日志)
Date startDate = DateUtil.offsetMinute(DateUtil.date(), -5);
Date startDate = DateUtil.offsetMinute(DateUtil.date(), deviceOpLastTime);
List<DeviceLog> deviceLogList = deviceLogMapper.selectListByMaxId(devIds, startDate);
// 将List转换为Map
Map<String, DeviceLog> deviceLogMap = deviceLogList.stream()
......
......@@ -6,6 +6,7 @@ import java.util.stream.Collectors;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.collections4.CollectionUtils;
import share.common.constant.Constants;
......@@ -46,6 +47,8 @@ public class SCleanRecordsServiceImpl extends ServiceImpl<SCleanRecordsMapper,SC
private ISOrderService orderService;
@Autowired
private SStoreConsumerMapper storeConsumerMapper;
@Autowired
private SConsumerMapper consumerMapper;
//管理员手机号
private static final String phone = "13888888888";
......@@ -312,8 +315,8 @@ public class SCleanRecordsServiceImpl extends ServiceImpl<SCleanRecordsMapper,SC
if (list.size() == 0) {
return Boolean.FALSE;
}
//获取List的房间集合
List<Long> roomIds = list.stream().map(SCleanRecords::getRoomId).collect(Collectors.toList());
//获取List的房间集合
LambdaQueryWrapper<SOrder> sOrderLambdaQueryWrapper = new LambdaQueryWrapper<>();
sOrderLambdaQueryWrapper.eq(SOrder::getPayStatus, YesNoEnum.yes.getIndex());
sOrderLambdaQueryWrapper.in(SOrder::getRoomId, roomIds);
......@@ -321,11 +324,10 @@ public class SCleanRecordsServiceImpl extends ServiceImpl<SCleanRecordsMapper,SC
sOrderLambdaQueryWrapper.notIn(SOrder::getRefundStatus, RefundStatusEnum.getRefundedStatus());
sOrderLambdaQueryWrapper.between(SOrder::getPreStartDate, now, DateUtil.offsetMinute(now, CLEANING));
List<SOrder> orderList = orderService.list(sOrderLambdaQueryWrapper);
//30分钟未完成保洁并且5分钟内有预约订单
if (CollectionUtils.isNotEmpty(orderList)) {
List<Long> orderRoomIds = orderList.stream().map(SOrder::getRoomId).collect(Collectors.toList());
list = list.stream().filter(item -> orderRoomIds.contains(item.getRoomId())).collect(Collectors.toList());
}
//查询当前房间当前时间加5分钟有没有预约订单
for (SCleanRecords sCleanRecords : list) {
sCleanRecords.setStatus(2);
......@@ -340,6 +342,46 @@ public class SCleanRecordsServiceImpl extends ServiceImpl<SCleanRecordsMapper,SC
// }
}
return 0 < baseMapper.updateBatch(list);
} else {
List<Long> roomIdList = list.stream().map(SCleanRecords::getRoomId).collect(Collectors.toList());
//查找改房间门店的保洁人员和管理员
List<SRoom> sRoomList = sRoomMapper.selectBatchIds(roomIdList);
//获取门店id,去重
List<Long> storeIds = sRoomList.stream().map(SRoom::getStoreId).distinct().collect(Collectors.toList());
List<SStore> sStoreList = sStoreMapper.selectBatchIds(storeIds);
//获取门店的保洁人员和管理员
List<SStoreConsumer> sStoreConsumers = storeConsumerMapper.selectList(new LambdaQueryWrapper<SStoreConsumer>().in(SStoreConsumer::getStoreId, storeIds));
List<SConsumer> sConsumers = consumerMapper.selectBatchIds(sStoreConsumers.stream().map(SStoreConsumer::getConsumerId).collect(Collectors.toList()));
List<Long> roomId = new ArrayList<>();
sStoreConsumers.stream().forEach(item -> {
//循环门店和店员的关系表
sStoreList.stream().forEach(store -> {
//循环门店
sRoomList.stream().forEach(room -> {
//循环房间
//判断当前房间是否是当前门店的房间,并且是未打扫的房间
if (item.getStoreId().equals(store.getId()) && room.getStoreId().equals(store.getId()) && room.getIsDirtyRoom().equals(YesNoEnum.no.getIndex())) {
//发送短信
sConsumers.stream().forEach(consumer -> {
if (consumer.getId().equals(item.getConsumerId())) {
roomId.add(room.getId());
smsService.sendSmsCleanRecords(consumer.getPhone(), store, room);
}
});
}
});
});
});
if (CollectionUtils.isEmpty(roomId)) {
return false;
}
//修改房间为脏房
UpdateWrapper<SRoom> updateWrapper = new UpdateWrapper<>();
updateWrapper.set("is_dirty_room", YesNoEnum.yes.getIndex());
updateWrapper.in("id", roomId);
sRoomMapper.update(null, updateWrapper);
return false;
}
}
@Override
......@@ -408,7 +450,10 @@ public class SCleanRecordsServiceImpl extends ServiceImpl<SCleanRecordsMapper,SC
isCleaner(sCleanRecords);
sCleanRecords.setEndDate(DateUtil.date());
sCleanRecords.setStatus(CleaningStatusEnum.CLEANED.getCode());
SRoom sRoom = new SRoom();
sRoom.setIsDirtyRoom(YesNoEnum.no.getIndex());
sRoom.setId(sCleanRecords.getRoomId());
sRoomMapper.updateById(sRoom);
SCleanRecords records = baseMapper.selectSCleanRecordsById(sCleanRecords.getId());
if (records == null) {
throw new RuntimeException("当前保洁任务不存在!");
......
......@@ -1095,6 +1095,9 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
// 计算各种价格
ComputedOrderPriceResponse priceResponse = new ComputedOrderPriceResponse();
SRoom room = roomService.getById(request.getRoomId());
if (ObjectUtil.isNotEmpty(room) && room.getIsDirtyRoom().equals(YesNoEnum.yes.getIndex())) {
throw new BaseException("当前房间未保洁,请选择其他房间");
}
BigDecimal totalPrice = computeTotalPrice(room.getPrice(), request.getPreStartDate(), request.getPreEndDate());
BigDecimal payPrice;
BuyTypeEnum buyTypeEnum = BuyTypeEnum.getEnumByCode(request.getBuyType());
......
......@@ -506,6 +506,7 @@ public class SStoreServiceImpl extends ServiceImpl<SStoreMapper, SStore> impleme
put("id", store.getId());
put("name", store.getName());
put("storeType", store.getStoreType());
put("deviceGroup", store.getDeviceGroup());
}};
return map;
}).collect(Collectors.toList());
......
......@@ -23,27 +23,34 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectDeviceLogVo">
select id, dev_mac, dev_id, seq, mqtt_type, mqtt_describe, payload, topic, create_by, create_time,
update_by, update_time, remark, `result`, description from s_device_log
select s1.id, s1.dev_mac, s1.dev_id, s1.seq, s1.mqtt_type, s1.mqtt_describe, s1.payload, s1.topic,
s1.create_by, s1.create_time,
s1.update_by, s1.update_time, s1.remark, s1.`result`, s1.description
from s_device_log s1
left join s_device s2 on s1.dev_id = s2.dev_id
left join s_room s3 on s2.room_id = s3.id
left join s_store s4 on s3.store_id = s4.id
</sql>
<select id="selectDeviceLogList" parameterType="DeviceLog" resultMap="DeviceLogResult">
<include refid="selectDeviceLogVo"/>
<where>
<if test="devMac != null and devMac != ''"> and dev_mac = #{devMac}</if>
<if test="devId != null and devId != ''"> and dev_id = #{devId}</if>
<if test="seq != null and seq != ''"> and seq = #{seq}</if>
<if test="mqttType != null and mqttType != ''"> and mqtt_type = #{mqttType}</if>
<if test="mqttDescribe != null and mqttDescribe != ''"> and mqtt_describe = #{mqttDescribe}</if>
<if test="payload != null and payload != ''"> and payload = #{payload}</if>
<if test="topic != null and topic != ''"> and topic = #{topic}</if>
<if test="devMac != null and devMac != ''"> and s1.dev_mac = #{devMac}</if>
<if test="devId != null and devId != ''"> and s1.dev_id = #{devId}</if>
<if test="seq != null and seq != ''"> and s1.seq = #{seq}</if>
<if test="mqttType != null and mqttType != ''"> and s1.mqtt_type = #{mqttType}</if>
<if test="mqttDescribe != null and mqttDescribe != ''"> and s1.mqtt_describe = #{mqttDescribe}</if>
<if test="payload != null and payload != ''"> and s1.payload = #{payload}</if>
<if test="topic != null and topic != ''"> and s1.topic = #{topic}</if>
<if test="storeName != null and storeName != ''"> and s4.name like concat('%', #{storeName}, '%')</if>
<if test="roomName != null and roomName != ''"> and s3.name like concat('%', #{roomName}, '%')</if>
</where>
order by create_time desc
order by s1.create_time desc
</select>
<select id="selectDeviceLogById" parameterType="Long" resultMap="DeviceLogResult">
<include refid="selectDeviceLogVo"/>
where id = #{id}
where s1.id = #{id}
</select>
<select id="selectListByMaxId" resultMap="DeviceLogResult">
SELECT t1.id, t1.dev_mac, t1.dev_id, t1.seq, t1.mqtt_type, t1.mqtt_describe, t1.payload, t1.topic,
......
......@@ -22,29 +22,36 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectDeviceStatusLogVo">
select id, dev_id, dev_mac, is_abnormal, status, room_id, voltage, signal_value, create_time, update_time,
remark, operate_log_id, is_send_sms, previous_status from s_device_status_log
select s1.id, s1.dev_id, s1.dev_mac, s1.is_abnormal, s1.status, s1.room_id, s1.voltage,
s1.signal_value, s1.create_time, s1.update_time,
s1.remark, s1.operate_log_id, s1.is_send_sms, s1.previous_status
from s_device_status_log s1
left join s_device s2 on s1.dev_id = s2.dev_id
left join s_room s3 on s2.room_id = s3.id
left join s_store s4 on s3.store_id = s4.id
</sql>
<select id="selectDeviceStatusLogList" parameterType="DeviceStatusLog" resultMap="DeviceStatusLogResult">
<include refid="selectDeviceStatusLogVo"/>
<where>
<if test="devId != null and devId != ''"> and dev_id = #{devId}</if>
<if test="devMac != null and devMac != ''"> and dev_mac = #{devMac}</if>
<if test="isAbnormal != null "> and is_abnormal = #{isAbnormal}</if>
<if test="status != null and status != ''"> and status = #{status}</if>
<if test="roomId != null "> and room_id = #{roomId}</if>
<if test="voltage != null and voltage != ''"> and voltage = #{voltage}</if>
<if test="signalValue != null and signalValue != ''"> and signal_value = #{signalValue}</if>
<if test="operateLogId != null "> and operate_log_id = #{operateLogId}</if>
<if test="isSendSms != null "> and is_send_sms = #{isSendSms}</if>
<if test="devId != null and devId != ''"> and s1.dev_id = #{devId}</if>
<if test="devMac != null and devMac != ''"> and s1.dev_mac = #{devMac}</if>
<if test="isAbnormal != null "> and s1.is_abnormal = #{isAbnormal}</if>
<if test="status != null and status != ''"> and s1.status = #{status}</if>
<if test="roomId != null "> and s1.room_id = #{roomId}</if>
<if test="voltage != null and voltage != ''"> and s1.voltage = #{voltage}</if>
<if test="signalValue != null and signalValue != ''"> and s1.signal_value = #{signalValue}</if>
<if test="operateLogId != null "> and s1.operate_log_id = #{operateLogId}</if>
<if test="isSendSms != null "> and s1.is_send_sms = #{isSendSms}</if>
<if test="storeName != null and storeName != ''"> and s4.name like concat('%', #{storeName}, '%')</if>
<if test="roomName != null and roomName != ''"> and s3.name like concat('%', #{roomName}, '%')</if>
</where>
order by create_time desc
order by s1.create_time desc
</select>
<select id="selectDeviceStatusLogById" parameterType="Long" resultMap="DeviceStatusLogResult">
<include refid="selectDeviceStatusLogVo"/>
where id = #{id}
where s1.id = #{id}
</select>
<insert id="insertDeviceStatusLog" parameterType="DeviceStatusLog">
......
......@@ -14,7 +14,7 @@
<result property="info" column="info" />
<result property="status" column="status" />
<result property="price" column="price" />
<!-- <result property="isDirtyRoom" column="is_dirty_room"/>-->
<result property="isDirtyRoom" column="is_dirty_room"/>
<result property="doorLockCode" column="door_lock_code" />
<result property="electricControlCode" column="electric_control_code" />
<result property="password" column="password" />
......@@ -37,7 +37,7 @@
info,
status,
price,
<!-- is_dirty_room,-->
is_dirty_room,
door_lock_code,
electric_control_code,
password,
......@@ -62,7 +62,7 @@
<if test="info != null and info != ''"> and info = #{info}</if>
<if test="status != null and status != '' or status ==0">and status = #{status}</if>
<if test="price != null "> and price = #{price}</if>
<!-- <if test="isDirtyRoom != null ">and is_dirty_room = #{isDirtyRoom}</if>-->
<if test="isDirtyRoom != null ">and is_dirty_room = #{isDirtyRoom}</if>
<if test="doorLockCode != null and doorLockCode != ''"> and door_lock_code = #{doorLockCode}</if>
<if test="electricControlCode != null and electricControlCode != ''"> and electric_control_code = #{electricControlCode}</if>
<if test="password != null and password != ''"> and password = #{password}</if>
......@@ -87,7 +87,7 @@
<if test="info != null">info,</if>
<if test="status != null">status,</if>
<if test="price != null">price,</if>
<!-- <if test="isDirtyRoom != null">is_dirty_room,</if> -->
<if test="isDirtyRoom != null">is_dirty_room,</if>
<if test="doorLockCode != null">door_lock_code,</if>
<if test="electricControlCode != null">electric_control_code,</if>
<if test="password != null">password,</if>
......@@ -108,7 +108,7 @@
<if test="info != null">#{info},</if>
<if test="status != null">#{status},</if>
<if test="price != null">#{price},</if>
<!-- <if test="isDirtyRoom != null">#{isDirtyRoom},</if> -->
<if test="isDirtyRoom != null">#{isDirtyRoom},</if>
<if test="doorLockCode != null">#{doorLockCode},</if>
<if test="electricControlCode != null">#{electricControlCode},</if>
<if test="password != null">#{password},</if>
......@@ -133,7 +133,7 @@
<if test="info != null">info = #{info},</if>
<if test="status != null">status = #{status},</if>
<if test="price != null">price = #{price},</if>
<!-- <if test="isDirtyRoom != null">is_dirty_room = #{isDirtyRoom},</if> -->
<if test="isDirtyRoom != null">is_dirty_room = #{isDirtyRoom},</if>
<if test="doorLockCode != null">door_lock_code = #{doorLockCode},</if>
<if test="electricControlCode != null">electric_control_code = #{electricControlCode},</if>
<if test="password != null">password = #{password},</if>
......@@ -149,7 +149,9 @@
</update>
<delete id="deleteSRoomById" parameterType="Long">
delete from s_room where id = #{id}
delete
from s_room
where id = #{id}
</delete>
<delete id="deleteSRoomByIds" parameterType="String">
......
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