Commit a88ffbac by 吕明尚

保洁管理增加门店一健领取保洁记录

parent 68247ee2
package share.web.controller.system;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import share.common.annotation.Log;
import org.springframework.web.bind.annotation.*;
import share.common.core.controller.BaseController;
import share.common.core.domain.AjaxResult;
import share.common.enums.BusinessType;
import share.common.enums.CleaningStatusEnum;
import share.common.enums.PositionEnum;
import share.common.enums.RoleTypeEnum;
import share.common.core.page.TableDataInfo;
import share.system.domain.SCleanRecords;
import share.system.domain.SConsumer;
import share.system.domain.SStoreConsumer;
import share.system.domain.vo.FrontTokenComponent;
import share.system.domain.vo.SCleanRecordsVo;
import share.system.mapper.SStoreConsumerMapper;
import share.system.service.DeviceOpService;
import share.system.service.ISCleanRecordsService;
import share.common.utils.poi.ExcelUtil;
import share.common.core.page.TableDataInfo;
import java.util.List;
/**
* 保洁记录Controller
......@@ -141,5 +121,11 @@ public class SCleanRecordsController extends BaseController
return success(sCleanRecordsService.getByCleanerId());
}
//领取门店下所有房间的保洁记录
@GetMapping("/startCleanByStore")
public AjaxResult startCleanByStore(Long storeId) {
return success(sCleanRecordsService.startCleanByStore(storeId));
}
}
package share.system.service;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.extension.service.IService;
import share.common.core.page.TableDataInfo;
import share.system.domain.SCleanRecords;
import share.system.domain.vo.SCleanRecordsVo;
import java.util.List;
import java.util.Map;
/**
* 保洁记录Service接口
*
......@@ -100,4 +100,6 @@ public interface ISCleanRecordsService extends IService<SCleanRecords>
* @return
*/
int endCleanRecords(SCleanRecords sCleanRecords);
int startCleanByStore(Long storeId);
}
......@@ -2,6 +2,7 @@ package share.system.service.impl;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -473,6 +474,32 @@ public class SCleanRecordsServiceImpl extends ServiceImpl<SCleanRecordsMapper,SC
return index;
}
@Override
public int startCleanByStore(Long storeId) {
SConsumer user = FrontTokenComponent.getWxSConsumerEntry();
if (!user.getRoleType().equals(RoleTypeEnum.CLEANER.getCode())) {
throw new RuntimeException("当前用户不是店员");
}
List<Long> longs = storeConsumerMapper.selectByConsumerId(user.getId(), PositionEnum.CLEANER.getCode());
if (CollectionUtils.isEmpty(longs)) {
throw new RuntimeException("当前用户不是保洁人员");
}
LambdaQueryWrapper<SCleanRecords> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SCleanRecords::getStoreId, storeId);
queryWrapper.eq(SCleanRecords::getStatus, CleaningStatusEnum.UNCLEAN.getCode());
List<SCleanRecords> sCleanRecords = baseMapper.selectList(queryWrapper);
if (CollectionUtils.isEmpty(sCleanRecords)) {
throw new RuntimeException("当前门店没有未保洁的保洁任务");
}
LambdaUpdateWrapper<SCleanRecords> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.in(SCleanRecords::getId, sCleanRecords.stream().map(SCleanRecords::getId).collect(Collectors.toList()));
SCleanRecords cleanRecords = new SCleanRecords();
cleanRecords.setStatus(CleaningStatusEnum.CLEANING.getCode());
cleanRecords.setStartDate(DateUtil.date());
cleanRecords.setConsumerId(user.getId());
return baseMapper.update(cleanRecords, updateWrapper);
}
private void isCleaner(SCleanRecords sCleanRecords) {
SConsumer user = FrontTokenComponent.getWxSConsumerEntry();
if (!user.getRoleType().equals(RoleTypeEnum.CLEANER.getCode())) {
......
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