Commit c82abfbd by 吕明尚

房间表增加是否脏房字段,在自动完成保洁订单的自动任务中,保洁任务是否超过30分钟,且5分钟后没有订单修改房间的是否脏房字段为是,通知门店保洁及管理员

parent fc274294
...@@ -80,11 +80,11 @@ public class SRoom extends BaseEntity ...@@ -80,11 +80,11 @@ public class SRoom extends BaseEntity
@Excel(name = "其他可能硬件接入参数(备用2)") @Excel(name = "其他可能硬件接入参数(备用2)")
private String params2; private String params2;
// /** /**
// * 是否脏房 * 是否脏房
// */ */
// @Excel(name = "是否脏房(0:否,1:是)") @Excel(name = "是否脏房(0:否,1:是)")
// private Integer isDirtyRoom; private Integer isDirtyRoom;
/** /**
* 套餐ID * 套餐ID
......
...@@ -115,6 +115,12 @@ public class SRoomVo extends BaseEntity ...@@ -115,6 +115,12 @@ public class SRoomVo extends BaseEntity
private Long recordsId; private Long recordsId;
/** /**
* 是否脏房
*/
private Integer isDirtyRoom;
/**
* 订单时间 * 订单时间
*/ */
/** /**
......
...@@ -6,6 +6,7 @@ import java.util.stream.Collectors; ...@@ -6,6 +6,7 @@ import java.util.stream.Collectors;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; 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 com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import share.common.constant.Constants; import share.common.constant.Constants;
...@@ -46,6 +47,8 @@ public class SCleanRecordsServiceImpl extends ServiceImpl<SCleanRecordsMapper,SC ...@@ -46,6 +47,8 @@ public class SCleanRecordsServiceImpl extends ServiceImpl<SCleanRecordsMapper,SC
private ISOrderService orderService; private ISOrderService orderService;
@Autowired @Autowired
private SStoreConsumerMapper storeConsumerMapper; private SStoreConsumerMapper storeConsumerMapper;
@Autowired
private SConsumerMapper consumerMapper;
//管理员手机号 //管理员手机号
private static final String phone = "13888888888"; private static final String phone = "13888888888";
...@@ -312,8 +315,8 @@ public class SCleanRecordsServiceImpl extends ServiceImpl<SCleanRecordsMapper,SC ...@@ -312,8 +315,8 @@ public class SCleanRecordsServiceImpl extends ServiceImpl<SCleanRecordsMapper,SC
if (list.size() == 0) { if (list.size() == 0) {
return Boolean.FALSE; return Boolean.FALSE;
} }
//获取List的房间集合
List<Long> roomIds = list.stream().map(SCleanRecords::getRoomId).collect(Collectors.toList()); List<Long> roomIds = list.stream().map(SCleanRecords::getRoomId).collect(Collectors.toList());
//获取List的房间集合
LambdaQueryWrapper<SOrder> sOrderLambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<SOrder> sOrderLambdaQueryWrapper = new LambdaQueryWrapper<>();
sOrderLambdaQueryWrapper.eq(SOrder::getPayStatus, YesNoEnum.yes.getIndex()); sOrderLambdaQueryWrapper.eq(SOrder::getPayStatus, YesNoEnum.yes.getIndex());
sOrderLambdaQueryWrapper.in(SOrder::getRoomId, roomIds); sOrderLambdaQueryWrapper.in(SOrder::getRoomId, roomIds);
...@@ -321,11 +324,10 @@ public class SCleanRecordsServiceImpl extends ServiceImpl<SCleanRecordsMapper,SC ...@@ -321,11 +324,10 @@ public class SCleanRecordsServiceImpl extends ServiceImpl<SCleanRecordsMapper,SC
sOrderLambdaQueryWrapper.notIn(SOrder::getRefundStatus, RefundStatusEnum.getRefundedStatus()); sOrderLambdaQueryWrapper.notIn(SOrder::getRefundStatus, RefundStatusEnum.getRefundedStatus());
sOrderLambdaQueryWrapper.between(SOrder::getPreStartDate, now, DateUtil.offsetMinute(now, CLEANING)); sOrderLambdaQueryWrapper.between(SOrder::getPreStartDate, now, DateUtil.offsetMinute(now, CLEANING));
List<SOrder> orderList = orderService.list(sOrderLambdaQueryWrapper); List<SOrder> orderList = orderService.list(sOrderLambdaQueryWrapper);
//30分钟未完成保洁并且5分钟内有预约订单
if (CollectionUtils.isNotEmpty(orderList)) { if (CollectionUtils.isNotEmpty(orderList)) {
List<Long> orderRoomIds = orderList.stream().map(SOrder::getRoomId).collect(Collectors.toList()); List<Long> orderRoomIds = orderList.stream().map(SOrder::getRoomId).collect(Collectors.toList());
list = list.stream().filter(item -> orderRoomIds.contains(item.getRoomId())).collect(Collectors.toList()); list = list.stream().filter(item -> orderRoomIds.contains(item.getRoomId())).collect(Collectors.toList());
}
//查询当前房间当前时间加5分钟有没有预约订单 //查询当前房间当前时间加5分钟有没有预约订单
for (SCleanRecords sCleanRecords : list) { for (SCleanRecords sCleanRecords : list) {
sCleanRecords.setStatus(2); sCleanRecords.setStatus(2);
...@@ -340,6 +342,46 @@ public class SCleanRecordsServiceImpl extends ServiceImpl<SCleanRecordsMapper,SC ...@@ -340,6 +342,46 @@ public class SCleanRecordsServiceImpl extends ServiceImpl<SCleanRecordsMapper,SC
// } // }
} }
return 0 < baseMapper.updateBatch(list); 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 @Override
...@@ -408,7 +450,10 @@ public class SCleanRecordsServiceImpl extends ServiceImpl<SCleanRecordsMapper,SC ...@@ -408,7 +450,10 @@ public class SCleanRecordsServiceImpl extends ServiceImpl<SCleanRecordsMapper,SC
isCleaner(sCleanRecords); isCleaner(sCleanRecords);
sCleanRecords.setEndDate(DateUtil.date()); sCleanRecords.setEndDate(DateUtil.date());
sCleanRecords.setStatus(CleaningStatusEnum.CLEANED.getCode()); 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()); SCleanRecords records = baseMapper.selectSCleanRecordsById(sCleanRecords.getId());
if (records == null) { if (records == null) {
throw new RuntimeException("当前保洁任务不存在!"); throw new RuntimeException("当前保洁任务不存在!");
......
...@@ -1095,6 +1095,9 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -1095,6 +1095,9 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
// 计算各种价格 // 计算各种价格
ComputedOrderPriceResponse priceResponse = new ComputedOrderPriceResponse(); ComputedOrderPriceResponse priceResponse = new ComputedOrderPriceResponse();
SRoom room = roomService.getById(request.getRoomId()); 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 totalPrice = computeTotalPrice(room.getPrice(), request.getPreStartDate(), request.getPreEndDate());
BigDecimal payPrice; BigDecimal payPrice;
BuyTypeEnum buyTypeEnum = BuyTypeEnum.getEnumByCode(request.getBuyType()); BuyTypeEnum buyTypeEnum = BuyTypeEnum.getEnumByCode(request.getBuyType());
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
<result property="info" column="info" /> <result property="info" column="info" />
<result property="status" column="status" /> <result property="status" column="status" />
<result property="price" column="price" /> <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="doorLockCode" column="door_lock_code" />
<result property="electricControlCode" column="electric_control_code" /> <result property="electricControlCode" column="electric_control_code" />
<result property="password" column="password" /> <result property="password" column="password" />
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
info, info,
status, status,
price, price,
<!-- is_dirty_room,--> is_dirty_room,
door_lock_code, door_lock_code,
electric_control_code, electric_control_code,
password, password,
...@@ -62,7 +62,7 @@ ...@@ -62,7 +62,7 @@
<if test="info != null and info != ''"> and info = #{info}</if> <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="status != null and status != '' or status ==0">and status = #{status}</if>
<if test="price != null "> and price = #{price}</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="doorLockCode != null and doorLockCode != ''"> and door_lock_code = #{doorLockCode}</if>
<if test="electricControlCode != null and electricControlCode != ''"> and electric_control_code = #{electricControlCode}</if> <if test="electricControlCode != null and electricControlCode != ''"> and electric_control_code = #{electricControlCode}</if>
<if test="password != null and password != ''"> and password = #{password}</if> <if test="password != null and password != ''"> and password = #{password}</if>
...@@ -87,7 +87,7 @@ ...@@ -87,7 +87,7 @@
<if test="info != null">info,</if> <if test="info != null">info,</if>
<if test="status != null">status,</if> <if test="status != null">status,</if>
<if test="price != null">price,</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="doorLockCode != null">door_lock_code,</if>
<if test="electricControlCode != null">electric_control_code,</if> <if test="electricControlCode != null">electric_control_code,</if>
<if test="password != null">password,</if> <if test="password != null">password,</if>
...@@ -108,7 +108,7 @@ ...@@ -108,7 +108,7 @@
<if test="info != null">#{info},</if> <if test="info != null">#{info},</if>
<if test="status != null">#{status},</if> <if test="status != null">#{status},</if>
<if test="price != null">#{price},</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="doorLockCode != null">#{doorLockCode},</if>
<if test="electricControlCode != null">#{electricControlCode},</if> <if test="electricControlCode != null">#{electricControlCode},</if>
<if test="password != null">#{password},</if> <if test="password != null">#{password},</if>
...@@ -133,7 +133,7 @@ ...@@ -133,7 +133,7 @@
<if test="info != null">info = #{info},</if> <if test="info != null">info = #{info},</if>
<if test="status != null">status = #{status},</if> <if test="status != null">status = #{status},</if>
<if test="price != null">price = #{price},</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="doorLockCode != null">door_lock_code = #{doorLockCode},</if>
<if test="electricControlCode != null">electric_control_code = #{electricControlCode},</if> <if test="electricControlCode != null">electric_control_code = #{electricControlCode},</if>
<if test="password != null">password = #{password},</if> <if test="password != null">password = #{password},</if>
...@@ -149,7 +149,9 @@ ...@@ -149,7 +149,9 @@
</update> </update>
<delete id="deleteSRoomById" parameterType="Long"> <delete id="deleteSRoomById" parameterType="Long">
delete from s_room where id = #{id} delete
from s_room
where id = #{id}
</delete> </delete>
<delete id="deleteSRoomByIds" parameterType="String"> <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