Commit a290146b by 吕明尚

修改保洁和设备管理权限

parent df6f054e
package share.web.controller.system;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
......@@ -8,6 +9,8 @@ import share.common.core.controller.BaseController;
import share.common.core.domain.AjaxResult;
import share.common.core.page.TableDataInfo;
import share.common.enums.BusinessType;
import share.common.enums.PositionEnum;
import share.common.enums.RoleTypeEnum;
import share.common.utils.SecurityUtils;
import share.common.utils.poi.ExcelUtil;
import share.system.domain.Device;
......@@ -15,6 +18,7 @@ import share.system.domain.SConsumer;
import share.system.domain.vo.DeviceParamVo;
import share.system.domain.vo.FrontTokenComponent;
import share.system.domain.vo.MqttxVo;
import share.system.mapper.SStoreConsumerMapper;
import share.system.mqtt.MqttGatewayComponent;
import share.system.service.DeviceLogService;
import share.system.service.DeviceService;
......@@ -41,6 +45,8 @@ public class DeviceController extends BaseController {
private MqttGatewayComponent mqttGatewayComponent;
@Autowired
private SConsumerService consumerService;
@Autowired
private SStoreConsumerMapper storeConsumerMapper;
/**
......@@ -49,6 +55,13 @@ public class DeviceController extends BaseController {
@PostMapping(value = "/openOrClose")
public AjaxResult openOrClose(@RequestBody DeviceParamVo deviceParam) {
SConsumer user = consumerService.getInfo();
if (!user.getRoleType().equals(RoleTypeEnum.CLEANER.getCode())) {
throw new RuntimeException("当前用户不是店员");
}
List<Long> longs = storeConsumerMapper.selectByConsumerId(user.getId(), PositionEnum.ADMIN.getCode());
if (CollectionUtils.isEmpty(longs)) {
throw new RuntimeException("当前用户不是管理员");
}
// 获取mqtt的topic、payload
MqttxVo mqttxVo = mqttxService.openOrCloseDevice(deviceParam.getDevId(),
user.getAccount(), deviceParam.getOpType());
......
......@@ -4,6 +4,7 @@ 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;
......@@ -21,9 +22,14 @@ 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.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;
......@@ -42,6 +48,8 @@ public class SCleanRecordsController extends BaseController
{
@Autowired
private ISCleanRecordsService sCleanRecordsService;
@Autowired
private SStoreConsumerMapper storeConsumerMapper;
/**
* 查询保洁记录列表
......@@ -76,13 +84,9 @@ public class SCleanRecordsController extends BaseController
*/
@ApiOperation(value = "已开始的保洁记录列表")
@GetMapping("/myCleanList")
public TableDataInfo myCleanList(SCleanRecords sCleanRecords)
public TableDataInfo myCleanList(SCleanRecordsVo sCleanRecords)
{
SConsumer user = FrontTokenComponent.getWxSConsumerEntry();
sCleanRecords.setConsumerId(user.getId());
startPage();
List<SCleanRecords> list = sCleanRecordsService.myCleanList(sCleanRecords);
return getDataTable(list);
return sCleanRecordsService.myCleanList(sCleanRecords);
}
/**
......@@ -104,10 +108,6 @@ public class SCleanRecordsController extends BaseController
@PostMapping(value = "/startClean")
public AjaxResult startClean(@RequestBody SCleanRecords sCleanRecords)
{
SConsumer user = FrontTokenComponent.getWxSConsumerEntry();
sCleanRecords.setConsumerId(user.getId());
sCleanRecords.setStartDate(DateUtil.date());
sCleanRecords.setStatus(CleaningStatusEnum.CLEANING.getCode());
return toAjax(sCleanRecordsService.startCleanRecords(sCleanRecords));
}
......@@ -119,10 +119,7 @@ public class SCleanRecordsController extends BaseController
@PostMapping(value = "/endClean")
public AjaxResult endClean(@RequestBody SCleanRecords sCleanRecords)
{
SConsumer user = FrontTokenComponent.getWxSConsumerEntry();
sCleanRecords.setConsumerId(user.getId());
sCleanRecords.setEndDate(DateUtil.date());
sCleanRecords.setStatus(CleaningStatusEnum.CLEANED.getCode());
return toAjax(sCleanRecordsService.endCleanRecords(sCleanRecords));
}
......
package share.system.domain.vo;
import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Data;
import share.common.annotation.Excel;
import share.common.core.domain.BaseEntity;
import java.util.List;
@Data
public class SCleanRecordsVo extends BaseEntity {
/**
* 门店ID
*/
private List<Long> storeIds;
/**
* 保洁人员ID
*/
private Long consumerId;
private Integer status;
/**
* 门店名称
*/
private String storeName;
Integer pageNum;
Integer pageSize;
}
......@@ -5,6 +5,7 @@ import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import share.system.domain.SCleanRecords;
import share.system.domain.SRoom;
import share.system.domain.vo.SCleanRecordsVo;
/**
* 保洁记录Mapper接口
......
......@@ -34,5 +34,7 @@ public interface SStoreConsumerMapper extends BaseMapper<SStoreConsumer> {
public int deleteInfos(@Param("storeId") Long storeId, @Param("consumerIds") Long[] consumerIds);
List<Long> selectByConsumerId(Long id);
List<Long> selectByConsumerId(Long id, Integer position);
List<SStoreConsumer> queryByConsumerId(Long id);
}
......@@ -4,7 +4,9 @@ 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;
/**
* 保洁记录Service接口
......@@ -72,7 +74,7 @@ public interface ISCleanRecordsService extends IService<SCleanRecords>
List<SCleanRecords> unCleanList(SCleanRecords sCleanRecords);
List<SCleanRecords> myCleanList(SCleanRecords sCleanRecords);
TableDataInfo myCleanList(SCleanRecordsVo sCleanRecords);
SCleanRecords getByRoomId(Long roomId);
......
......@@ -10,6 +10,7 @@ import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.util.ObjectUtils;
import share.common.enums.DeviceType;
import share.common.enums.PositionEnum;
import share.common.enums.RoleTypeEnum;
import share.common.enums.YesNoEnum;
import share.common.exception.base.BaseException;
......@@ -23,6 +24,7 @@ import share.system.domain.vo.RoomStatusVo;
import share.system.domain.vo.SRoomVo;
import share.system.mapper.DeviceMapper;
import share.system.mapper.SRoomMapper;
import share.system.mapper.SStoreConsumerMapper;
import share.system.service.*;
/**
......@@ -52,6 +54,8 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements
private DeviceOpService deviceOpService;
@Autowired
private RoomStatusService roomStatusService;
@Autowired
private SStoreConsumerMapper storeConsumerMapper;
/**
......@@ -281,6 +285,10 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements
public String openDoor(Long id) {
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("当前用户不是保洁人员");
}
SRoom room = baseMapper.selectById(id);
......
......@@ -368,10 +368,12 @@ public class SStoreServiceImpl extends ServiceImpl<SStoreMapper, SStore> impleme
public List<SStore> listVoByCleaner() {
SConsumer user = FrontTokenComponent.getWxSConsumerEntry();
if (!user.getRoleType().equals(RoleTypeEnum.CLEANER.getCode())) {
throw new BaseException("当前用户不是保洁人员!");
throw new BaseException("当前用户不是店员!");
}
List<Long> storeIdList = storeConsumerMapper.selectByConsumerId(user.getId(), PositionEnum.CLEANER.getCode());
if (CollectionUtils.isEmpty(storeIdList)) {
throw new RuntimeException("当前用户不是保洁人员");
}
//查询保洁人员所属门店
List<Long> storeIdList = storeConsumerMapper.selectByConsumerId(user.getId());
List<SStore> storeList = new ArrayList<>();
if (CollectionUtils.isNotEmpty(storeIdList)) {
// 查询门店信息
......
......@@ -21,7 +21,14 @@
select store_id
from s_store_consumer
where consumer_id = #{consumerId}
and position = '1'
<if test="position != null">
and position = #{position}
</if>
</select>
<select id="queryByConsumerId" resultMap="SStoreConsumerResult">
select store_id, store_id, position
from s_store_consumer
where consumer_id = #{consumerId}
</select>
<delete id="deleteSStoreConsumer" parameterType="Long">
......
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