|
@@ -1,6 +1,7 @@
|
|
|
package com.ylx.massage.service.impl;
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.ylx.common.exception.ServiceException;
|
|
@@ -8,16 +9,19 @@ import com.ylx.common.utils.StringUtils;
|
|
|
import com.ylx.massage.domain.TJs;
|
|
|
import com.ylx.massage.domain.TOrder;
|
|
|
import com.ylx.massage.domain.YlxAlarm;
|
|
|
+import com.ylx.massage.enums.OrderStatusEnum;
|
|
|
import com.ylx.massage.mapper.YlxAlarmMapper;
|
|
|
import com.ylx.massage.service.TJsService;
|
|
|
import com.ylx.massage.service.TOrderService;
|
|
|
import com.ylx.massage.service.YlxAlarmService;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.data.domain.PageImpl;
|
|
|
import org.springframework.data.domain.PageRequest;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* 报警记录表(YlxAlarm)表服务实现类
|
|
@@ -25,6 +29,7 @@ import javax.annotation.Resource;
|
|
|
* @author makejava
|
|
|
* @since 2024-04-28 09:19:05
|
|
|
*/
|
|
|
+@Slf4j
|
|
|
@Service("ylxAlarmService")
|
|
|
public class YlxAlarmServiceImpl extends ServiceImpl<YlxAlarmMapper, YlxAlarm> implements YlxAlarmService {
|
|
|
@Resource
|
|
@@ -92,17 +97,25 @@ public class YlxAlarmServiceImpl extends ServiceImpl<YlxAlarmMapper, YlxAlarm> i
|
|
|
|
|
|
@Override
|
|
|
public YlxAlarm addAlarm(YlxAlarm ylxAlarm) {
|
|
|
- if(StringUtils.isBlank(ylxAlarm.getOrderNo())){
|
|
|
- throw new ServiceException("订单号不能为空");
|
|
|
+ if(StringUtils.isBlank(ylxAlarm.getJsId())){
|
|
|
+ throw new ServiceException("技师ID不能为空");
|
|
|
}
|
|
|
- LambdaQueryWrapper<YlxAlarm> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
- queryWrapper.eq(YlxAlarm::getOrderNo,ylxAlarm.getOrderNo());
|
|
|
- YlxAlarm one = this.getOne(queryWrapper);
|
|
|
- if(one != null){
|
|
|
- throw new ServiceException("该订单已报警");
|
|
|
+ LambdaQueryWrapper<TOrder> tOrderLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ tOrderLambdaQueryWrapper.eq(TOrder::getcJsId,ylxAlarm.getJsId()).eq(TOrder::getnStatus, OrderStatusEnum.SERVICE);
|
|
|
+ List<TOrder> orders = orderService.list(tOrderLambdaQueryWrapper);
|
|
|
+
|
|
|
+ if(CollectionUtil.isEmpty(orders)) {
|
|
|
+ throw new ServiceException("没有服务中的订单");
|
|
|
}
|
|
|
- TOrder order = orderService.getByNo(ylxAlarm.getOrderNo());
|
|
|
+ log.info("addAlarm-订单信息:{}", orders);
|
|
|
+ TOrder order = orders.get(0);
|
|
|
if(order!=null){
|
|
|
+ LambdaQueryWrapper<YlxAlarm> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(YlxAlarm::getOrderNo,order.getOrderNo());
|
|
|
+ YlxAlarm one = this.getOne(queryWrapper);
|
|
|
+ if(one != null){
|
|
|
+ throw new ServiceException("该订单已报警");
|
|
|
+ }
|
|
|
YlxAlarm ylxAlarm1 = new YlxAlarm();
|
|
|
TJs js = jsService.getById(order.getcJsId());
|
|
|
ylxAlarm1.setJsId(order.getcJsId());
|