前端相关界面完善 新增APP设备录入功能

This commit is contained in:
SjS 2025-05-19 18:13:14 +08:00
parent e0c8100eee
commit d79d9fdebe
28 changed files with 183 additions and 123 deletions

View File

@ -17,6 +17,7 @@ public enum LogBizType {
UNIT("5", "单位"), UNIT("5", "单位"),
SHIFT("6", "调班"), SHIFT("6", "调班"),
SUIT("SUIT", "套餐"), SUIT("SUIT", "套餐"),
DEVICE("DEVICE", "设备"),
ARTICLE_CATEGORY("ARTICLE_CATEGORY", "文章分类"), ARTICLE_CATEGORY("ARTICLE_CATEGORY", "文章分类"),
BOOTH("BOOTH", "卡座"); BOOTH("BOOTH", "卡座");

View File

@ -30,10 +30,10 @@ public class Booth extends BaseEntity
@NotNull(message = "分区ID不能为空",groups = ValidGroup.Create.class) @NotNull(message = "分区ID不能为空",groups = ValidGroup.Create.class)
private Long partId; private Long partId;
@Excel(name = "卡座编号") @Excel(name = "卡座")
@ApiModelProperty("卡座编号") @ApiModelProperty("卡座")
@NotBlank(message = "卡座编号不能为空",groups = ValidGroup.Create.class) @NotBlank(message = "卡座不能为空",groups = ValidGroup.Create.class)
private String boothNo; private String boothName;
@Excel(name = "过期时间") @Excel(name = "过期时间")
@ApiModelProperty("过期时间") @ApiModelProperty("过期时间")

View File

@ -23,6 +23,10 @@ public class BoothVO extends Booth{
@ApiModelProperty("店铺名称") @ApiModelProperty("店铺名称")
private String storeName; private String storeName;
@Excel(name = "商户名称")
@ApiModelProperty("商户名称")
private String mchName;
@Excel(name = "店铺ID") @Excel(name = "店铺ID")
@ApiModelProperty("店铺ID") @ApiModelProperty("店铺ID")
private Long storeId; private Long storeId;

View File

@ -12,13 +12,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="userId" column="user_id" /> <result property="userId" column="user_id" />
<result property="expiredTime" column="expired_time" /> <result property="expiredTime" column="expired_time" />
<result property="orderNum" column="order_num" /> <result property="orderNum" column="order_num" />
<result property="boothName" column="booth_name" />
</resultMap> </resultMap>
<sql id="selectBoothVo"> <sql id="selectBoothVo">
select select
bb.booth_id, bb.booth_id,
bb.part_id, bb.part_id,
bb.booth_no, bb.booth_name,
bb.picture, bb.picture,
bb.create_time, bb.create_time,
bb.user_id, bb.user_id,
@ -28,7 +29,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
bp.part_name as part_name, bp.part_name as part_name,
bp_parent.part_name as parent_name, bp_parent.part_name as parent_name,
bs.store_name as store_name, bs.store_name as store_name,
bs.user_id as mch_id bs.user_id as mch_id,
mch_su.user_name as mch_name
from <include refid="searchTables"/> from <include refid="searchTables"/>
</sql> </sql>
@ -37,6 +39,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
left join bst_part bp on bp.part_id = bb.part_id left join bst_part bp on bp.part_id = bb.part_id
left join bst_part bp_parent on bp.parent_id = bp_parent.part_id left join bst_part bp_parent on bp.parent_id = bp_parent.part_id
left join bst_store bs on bp.store_id = bs.store_id left join bst_store bs on bp.store_id = bs.store_id
left join sys_user mch_su on bs.user_id = mch_su.user_id
</sql> </sql>
<sql id="searchCondition"> <sql id="searchCondition">
@ -44,10 +47,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="query.userId != null "> and bb.user_id = #{query.userId}</if> <if test="query.userId != null "> and bb.user_id = #{query.userId}</if>
<if test="query.deleted != null "> and bb.deleted = #{query.deleted}</if> <if test="query.deleted != null "> and bb.deleted = #{query.deleted}</if>
<if test="query.boothId != null "> and bb.booth_id = #{query.boothId}</if> <if test="query.boothId != null "> and bb.booth_id = #{query.boothId}</if>
<if test="query.boothNo != null and query.boothNo != ''"> and bb.booth_no like concat('%', #{query.boothNo}, '%')</if> <if test="query.boothName != null and query.boothName != ''"> and bb.booth_name like concat('%', #{query.boothName}, '%')</if>
<if test="query.picture != null and query.picture != ''"> and bb.picture = #{query.picture}</if> <if test="query.picture != null and query.picture != ''"> and bb.picture = #{query.picture}</if>
<if test="query.partName != null and query.partName != ''"> and bp.part_name like concat('%', #{query.partName}, '%') </if> <if test="query.partName != null and query.partName != ''"> and bp.part_name like concat('%', #{query.partName}, '%') </if>
<if test="query.partName != null and query.partName != ''"> and bp.part_name like concat('%', #{query.partName}, '%') </if>
<if test="query.time != null"> and bb.expired_time &gt;= #{query.time} </if> <if test="query.time != null"> and bb.expired_time &gt;= #{query.time} </if>
<if test="query.storeName != null and query.storeName != ''"> and bs.store_name like concat('%', #{query.storeName}, '%') </if> <if test="query.storeName != null and query.storeName != ''"> and bs.store_name like concat('%', #{query.storeName}, '%') </if>
${@com.ruoyi.framework.util.DataScopeUtil@create(query.scope) ${@com.ruoyi.framework.util.DataScopeUtil@create(query.scope)
@ -73,7 +75,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<!-- selectIdByQuery --> <!-- selectIdByQuery -->
<select id="selectIdByQuery" resultType="Long"> <select id="selectIdByQuery" resultType="Long">
select bb.booth_id <include refid="searchTables"/> select bb.booth_id from
<include refid="searchTables"/>
<where> <where>
<include refid="searchCondition"/> <include refid="searchCondition"/>
</where> </where>
@ -84,7 +87,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
from <include refid="searchTables"/> from <include refid="searchTables"/>
<where> <where>
<if test="query.boothId != null "> and bb.booth_id != #{query.boothId}</if> <if test="query.boothId != null "> and bb.booth_id != #{query.boothId}</if>
<if test="query.boothNo != null "> and bb.booth_no = #{query.boothNo}</if>
</where> </where>
</select> </select>
@ -95,7 +97,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectBoothByBoothNo" resultType="com.ruoyi.bst.booth.domain.BoothVO"> <select id="selectBoothByBoothNo" resultType="com.ruoyi.bst.booth.domain.BoothVO">
<include refid="selectBoothVo"/> <include refid="selectBoothVo"/>
where bb.booth_no = #{boothNo} where bb.booth_name = #{boothName}
</select> </select>
<insert id="insertBooth" parameterType="Booth" useGeneratedKeys="true" keyProperty="boothId"> <insert id="insertBooth" parameterType="Booth" useGeneratedKeys="true" keyProperty="boothId">
@ -105,14 +107,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="picture != null">picture,</if> <if test="picture != null">picture,</if>
<if test="createTime != null">create_time,</if> <if test="createTime != null">create_time,</if>
<if test="orderNum != null">order_num,</if> <if test="orderNum != null">order_num,</if>
<if test="boothNo != null">booth_no,</if> <if test="boothName != null">booth_name,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="partId != null">#{partId},</if> <if test="partId != null">#{partId},</if>
<if test="picture != null">#{picture},</if> <if test="picture != null">#{picture},</if>
<if test="createTime != null">#{createTime},</if> <if test="createTime != null">#{createTime},</if>
<if test="orderNum != null">#{orderNum},</if> <if test="orderNum != null">#{orderNum},</if>
<if test="boothNo != null">#{boothNo},</if> <if test="boothName != null">#{boothName},</if>
</trim> </trim>
</insert> </insert>
@ -199,7 +201,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<sql id="updateColumns"> <sql id="updateColumns">
<if test="data.partId != null">part_id = #{data.partId},</if> <if test="data.partId != null">part_id = #{data.partId},</if>
<if test="data.boothNo != null">booth_no = #{data.boothNo},</if> <if test="data.boothName != null">booth_name = #{data.boothName},</if>
<if test="data.picture != null">picture = #{data.picture},</if> <if test="data.picture != null">picture = #{data.picture},</if>
<if test="data.createTime != null">create_time = #{data.createTime},</if> <if test="data.createTime != null">create_time = #{data.createTime},</if>
<if test="data.userId != null">user_id = #{data.userId},</if> <if test="data.userId != null">user_id = #{data.userId},</if>

View File

@ -86,7 +86,7 @@ public interface BoothService
public int deleteBoothByBoothId(Long boothId); public int deleteBoothByBoothId(Long boothId);
public BoothVO bindUser(Long userId, String boothNo); public BoothVO bindUser(Long userId, Long boothId);
public DeviceIotVO lighting(BoothVO booth, Long userId,boolean requiredIot); public DeviceIotVO lighting(BoothVO booth, Long userId,boolean requiredIot);
@ -96,5 +96,5 @@ public interface BoothService
int unbindUser(BoothVO booth); int unbindUser(BoothVO booth);
int userChangeBind(String usingBoothNo ,String changeBoothNo,Long userId); int userChangeBind(Long usingBoothId ,Long changeBoothId,Long userId);
} }

View File

@ -20,9 +20,5 @@ public interface BoothValidator {
*/ */
boolean canDeleteAll(List<Long> ids); boolean canDeleteAll(List<Long> ids);
/**
* 校验
* @param boothId
*/
void validate(Long boothId,String boothNo);
} }

View File

@ -17,7 +17,7 @@ public class BoothConverterImpl implements BoothConverter {
// 设置基本信息 // 设置基本信息
po.setPartId(data.getPartId()); po.setPartId(data.getPartId());
po.setPicture(data.getPicture()); po.setPicture(data.getPicture());
po.setBoothNo(data.getBoothNo()); po.setBoothName(data.getBoothName());
po.setOrderNum(data.getOrderNum()); po.setOrderNum(data.getOrderNum());
return po; return po;
} }
@ -32,7 +32,7 @@ public class BoothConverterImpl implements BoothConverter {
po.setBoothId(data.getBoothId()); po.setBoothId(data.getBoothId());
po.setPartId(data.getPartId()); po.setPartId(data.getPartId());
po.setPicture(data.getPicture()); po.setPicture(data.getPicture());
po.setBoothNo(data.getBoothNo()); po.setBoothName(data.getBoothName());
po.setOrderNum(data.getOrderNum()); po.setOrderNum(data.getOrderNum());
return po; return po;
} }

View File

@ -100,12 +100,12 @@ public class BoothServiceImpl implements BoothService {
} }
@Override @Override
public BoothVO selectBoothByBoothNo(String boothNo, boolean scope) { public BoothVO selectBoothByBoothNo(String boothName, boolean scope) {
if (boothNo == null) { if (boothName == null) {
return null; return null;
} }
BoothQuery query = new BoothQuery(); BoothQuery query = new BoothQuery();
query.setBoothNo(boothNo); query.setBoothName(boothName);
query.setScope(scope); query.setScope(scope);
query.addStorePermission(StoreStaffPermission.BOOTH_VIEW.getCode()); query.addStorePermission(StoreStaffPermission.BOOTH_VIEW.getCode());
return this.selectOne(query); return this.selectOne(query);
@ -139,15 +139,9 @@ public class BoothServiceImpl implements BoothService {
@Override @Override
public int insertBooth(Booth booth) { public int insertBooth(Booth booth) {
booth.setCreateTime(DateUtils.getNowDate()); booth.setCreateTime(DateUtils.getNowDate());
Integer result = transactionTemplate.execute(status -> { PartVO partVO = partService.selectPartById(booth.getPartId());
int rows = boothMapper.insertBooth(booth); ServiceUtil.assertion(partVO == null, "id为%s的分区信息不存在", booth.getPartId());
if (rows > 0) { return boothMapper.insertBooth(booth);
// 后校验
boothValidator.validate(booth.getBoothId(), booth.getBoothNo());
}
return rows;
});
return result == null ? 0 : result;
} }
/** /**
@ -158,9 +152,9 @@ public class BoothServiceImpl implements BoothService {
*/ */
@Override @Override
public int updateBooth(Booth booth) { public int updateBooth(Booth booth) {
if (booth.getBoothNo() != null) { ServiceUtil.assertion(booth.getPartId() == null, "分区ID不能为空");
boothValidator.validate(booth.getBoothId(), booth.getBoothNo()); PartVO partVO = partService.selectPartById(booth.getPartId());
} ServiceUtil.assertion(partVO == null, "id为%s的分区信息不存在", booth.getPartId());
return boothMapper.updateBooth(booth); return boothMapper.updateBooth(booth);
} }
@ -187,18 +181,19 @@ public class BoothServiceImpl implements BoothService {
} }
@Override @Override
public BoothVO bindUser(Long userId, String boothNo) { public BoothVO bindUser(Long userId, Long boothId) {
boolean lock = redisLock.lock(RedisLockKey.BOOTH_BIND_USER, userId); boolean lock = redisLock.lock(RedisLockKey.BOOTH_BIND_USER, userId);
ServiceUtil.assertion(!lock, "您当前操作过于频繁,请稍后重试"); ServiceUtil.assertion(!lock, "您当前操作过于频繁,请稍后重试");
try { try {
//查询当前用户当前绑定的卡座
BoothQuery query = new BoothQuery(); BoothQuery query = new BoothQuery();
query.setUserId(userId); query.setUserId(userId);
query.setTime(LocalDateTime.now()); query.setTime(LocalDateTime.now());
List<BoothVO> list = boothMapper.selectBoothList(query); List<BoothVO> list = boothMapper.selectBoothList(query);
if (list != null && !list.isEmpty()) { if (list != null && !list.isEmpty()) {
return CollectionUtils.firstElement(list); return CollectionUtils.firstElement(list);
}; }
BoothVO booth = boothMapper.selectBoothByBoothNo(boothNo); BoothVO booth = boothMapper.selectBoothByBoothId(boothId);
ServiceUtil.assertion(booth == null, "当前卡座不存在"); ServiceUtil.assertion(booth == null, "当前卡座不存在");
if (booth.getUserId() != null && booth.getExpiredTime() != null && booth.getExpiredTime().isAfter(LocalDateTime.now())) { if (booth.getUserId() != null && booth.getExpiredTime() != null && booth.getExpiredTime().isAfter(LocalDateTime.now())) {
// 卡座未过期被其他用户绑定 // 卡座未过期被其他用户绑定
@ -233,15 +228,15 @@ public class BoothServiceImpl implements BoothService {
} }
@Override @Override
public int userChangeBind(String usingBoothNo, String changeBoothNo, Long userId) { public int userChangeBind(Long usingBoothId, Long changeBoothId, Long userId) {
BoothVO usingBooth = boothMapper.selectBoothByBoothNo(usingBoothNo); BoothVO usingBooth = boothMapper.selectBoothByBoothId(usingBoothId);
ServiceUtil.assertion(usingBooth == null, "编号为%s的卡座信息不存在", usingBoothNo); ServiceUtil.assertion(usingBooth == null, "ID为%s的卡座信息不存在", usingBoothId);
ServiceUtil.assertion(usingBooth.getUserId() == null, "请先绑定编号为%s的卡座后再进行操作", usingBoothNo); ServiceUtil.assertion(usingBooth.getUserId() == null, "请先绑定ID为%s的卡座后再进行操作", usingBoothId);
ServiceUtil.assertion(!usingBooth.getUserId().equals(userId), "您无权限更改当前卡座信息", usingBoothNo); ServiceUtil.assertion(!usingBooth.getUserId().equals(userId), "您无权限更改当前卡座信息", usingBoothId);
BoothVO changeBooth = boothMapper.selectBoothByBoothNo(changeBoothNo); BoothVO changeBooth = boothMapper.selectBoothByBoothId(changeBoothId);
ServiceUtil.assertion(changeBooth == null, "编号为%s的卡座信息不存在", changeBoothNo); ServiceUtil.assertion(changeBooth == null, "ID为%s的卡座信息不存在", changeBoothId);
boolean lock = redisLock.lock(RedisLockKey.BOOTH_CHANGE_USER, changeBoothNo); boolean lock = redisLock.lock(RedisLockKey.BOOTH_CHANGE_USER, changeBoothId);
ServiceUtil.assertion(!lock, "您当前操作过于频繁,请稍后重试"); ServiceUtil.assertion(!lock, "您当前操作过于频繁,请稍后重试");
try { try {
Integer result = transactionTemplate.execute(status -> { Integer result = transactionTemplate.execute(status -> {
@ -262,7 +257,7 @@ public class BoothServiceImpl implements BoothService {
}); });
return result; return result;
} finally { } finally {
redisLock.unlock(RedisLockKey.BOOTH_CHANGE_USER, changeBoothNo); redisLock.unlock(RedisLockKey.BOOTH_CHANGE_USER, changeBoothId);
} }
} }
@ -283,17 +278,17 @@ public class BoothServiceImpl implements BoothService {
DeviceQuery deviceQuery = new DeviceQuery(); DeviceQuery deviceQuery = new DeviceQuery();
deviceQuery.setBoothId(booth.getBoothId()); deviceQuery.setBoothId(booth.getBoothId());
deviceQuery.setDeleted(false); deviceQuery.setDeleted(false);
deviceQuery.setBoothNo(booth.getBoothNo()); deviceQuery.setBoothId(booth.getBoothId());
List<DeviceVO> deviceVOList = deviceMapper.selectDeviceList(deviceQuery); List<DeviceVO> deviceVOList = deviceMapper.selectDeviceList(deviceQuery);
ServiceUtil.assertion(CollectionUtils.isEmpty(deviceVOList), "当前卡座下无可用设备");
// 设备相关校验 // 设备相关校验
if (deviceVOList != null && !deviceVOList.isEmpty()) {
deviceVOList.forEach(deviceVO -> { deviceVOList.forEach(deviceVO -> {
ServiceUtil.assertion(deviceVO == null || deviceVO.getDeviceId() == null, "设备不存在"); ServiceUtil.assertion(deviceVO == null || deviceVO.getDeviceId() == null, "设备不存在");
ServiceUtil.assertion(StringUtils.isAllBlank(deviceVO.getMac(), deviceVO.getMac2()), "设备MAC号为空"); ServiceUtil.assertion(StringUtils.isAllBlank(deviceVO.getMac(), deviceVO.getMac2()), "设备MAC号为空");
ServiceUtil.assertion(deviceVO.getDuration() == null, "设备编号为%s的设备暂未设置开启时长", deviceVO.getDeviceNo()); ServiceUtil.assertion(deviceVO.getDuration() == null, "设备编号为%s的设备暂未设置开启时长", deviceVO.getDeviceNo());
}); });
}
// 新建IotVO 返回数据库操作与物联网操作结果 // 新建IotVO 返回数据库操作与物联网操作结果
DeviceIotVO iotVO = new DeviceIotVO(); DeviceIotVO iotVO = new DeviceIotVO();

View File

@ -37,28 +37,6 @@ public class BoothValidatorImpl implements BoothValidator {
return canOperate(ids); return canOperate(ids);
} }
@Override
public void validate(Long boothId,String boothNo) {
BoothVO booth = boothMapper.selectBoothByBoothId(boothId);
ServiceUtil.assertion(booth == null, "卡座不存在");
// 判断卡座编号是否重复
this.validateNo(boothId, boothNo);
}
private void validateNo(Long boothId, String boothNo) {
if (StringUtils.isBlank(boothNo)) {
return;
}
BoothQuery query = new BoothQuery();
query.setDeleted(false);
query.setBoothId(boothId);
query.setBoothNo(boothNo);
int count = boothMapper.selectCount(query);
ServiceUtil.assertion(count > 0,"卡座编号已存在");
}
// 是否可以操作卡座 // 是否可以操作卡座
private boolean canOperate(List<Long> boothIds) { private boolean canOperate(List<Long> boothIds) {
return hasPermission(boothIds); return hasPermission(boothIds);

View File

@ -21,8 +21,11 @@ public class DeviceQuery extends DeviceVO{
@ApiModelProperty("店铺id") @ApiModelProperty("店铺id")
private Long storeId; private Long storeId;
@ApiModelProperty("卡座编号") @ApiModelProperty("MAC列表")
private String boothNo; private List<String> macList;
@ApiModelProperty("卡座名称")
private String boothName;
@ApiModelProperty("是否查询未绑定的设备") @ApiModelProperty("是否查询未绑定的设备")
private Boolean isUnbound; private Boolean isUnbound;

View File

@ -0,0 +1,20 @@
package com.ruoyi.bst.device.domain.dto;
import com.ruoyi.iot.domain.IotDeviceDetail;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
@Data
public class DeviceBltUploadDTO {
@ApiModelProperty("设备MAC")
@NotBlank(message = "设备MAC不能为空")
private String mac;
@ApiModelProperty("系统数据")
@NotNull(message = "系统数据不能为空")
private IotDeviceDetail sys;
}

View File

@ -8,5 +8,5 @@ public class DeviceMacSnVO {
// MAC // MAC
private String mac; private String mac;
// SN // SN
private String sn; private String deviceNo;
} }

View File

@ -7,6 +7,7 @@ import com.ruoyi.bst.device.domain.Device;
import com.ruoyi.bst.device.domain.DeviceCountVO; import com.ruoyi.bst.device.domain.DeviceCountVO;
import com.ruoyi.bst.device.domain.DeviceVO; import com.ruoyi.bst.device.domain.DeviceVO;
import com.ruoyi.bst.device.domain.DeviceQuery; import com.ruoyi.bst.device.domain.DeviceQuery;
import com.ruoyi.bst.device.domain.vo.DeviceMacSnVO;
import com.ruoyi.common.domain.vo.LongIntegerVO; import com.ruoyi.common.domain.vo.LongIntegerVO;
import com.ruoyi.common.domain.vo.StringIntegerVO; import com.ruoyi.common.domain.vo.StringIntegerVO;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@ -176,4 +177,13 @@ public interface DeviceMapper
* @return * @return
*/ */
List<StringIntegerVO> selectOnlineStatusCount(@Param("query") DeviceQuery query); List<StringIntegerVO> selectOnlineStatusCount(@Param("query") DeviceQuery query);
/**
* 根据mac查询SN
*
* @param query
* @return
*/
List<DeviceMacSnVO> selectMacSnList(@Param("query") DeviceQuery query);
} }

View File

@ -91,7 +91,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
su.user_name, su.user_name,
bs.store_name, bs.store_name,
bs.store_id, bs.store_id,
bb.booth_no as position bb.booth_name as position
from <include refid="searchTables"/> from <include refid="searchTables"/>
</sql> </sql>
@ -104,16 +104,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</sql> </sql>
<sql id="searchCondition"> <sql id="searchCondition">
<if test="query.deviceNo != null and query.deviceNo != ''"> and bd.device_no = #{query.deviceNo}</if> <if test="query.deviceNo != null and query.deviceNo != ''"> and bd.device_no like concat('%', #{query.deviceNo}, '%')</if>
<if test="query.deviceId != null and query.deviceId != ''"> and bd.device_id = #{query.deviceId}</if> <if test="query.deviceId != null and query.deviceId != ''"> and bd.device_id = #{query.deviceId}</if>
<if test="query.storeId != null and query.storeId != ''"> and bd.store_id = #{query.storeId}</if> <if test="query.storeId != null and query.storeId != ''"> and bd.store_id = #{query.storeId}</if>
<if test="query.boothId != null "> and bd.booth_id = #{query.boothId}</if> <if test="query.boothId != null "> and bd.booth_id = #{query.boothId}</if>
<if test="query.boothNo != null and query.boothNo !=''"> and bb.booth_no = #{query.boothNo}</if> <if test="query.boothName != null and query.boothName !=''"> and bb.booth_name = #{query.boothName}</if>
<if test="query.userId != null "> and bd.user_id = #{query.userId}</if> <if test="query.userId != null "> and bd.user_id = #{query.userId}</if>
<if test="query.modelId != null "> and bd.model_id = #{query.modelId}</if> <if test="query.modelId != null "> and bd.model_id = #{query.modelId}</if>
<if test="query.deviceName != null and query.deviceName != ''"> and bd.device_name like concat('%', #{query.deviceName}, '%')</if> <if test="query.deviceName != null and query.deviceName != ''"> and bd.device_name like concat('%', #{query.deviceName}, '%')</if>
<if test="query.storeName != null and query.storeName != ''"> and bs.store_name like concat('%', #{query.storeName}, '%')</if> <if test="query.storeName != null and query.storeName != ''"> and bs.store_name like concat('%', #{query.storeName}, '%')</if>
<if test="query.mac != null and query.mac != ''"> and bd.mac = #{query.mac}</if> <if test="query.mac != null and query.mac != ''"> and bd.mac like concat('%', #{query.mac}, '%')</if>
<if test="query.mac2 != null and query.mac2 != ''"> and bd.mac2 = #{query.mac2}</if> <if test="query.mac2 != null and query.mac2 != ''"> and bd.mac2 = #{query.mac2}</if>
<if test="query.totalElectriQuantity != null "> and bd.total_electri_quantity = #{query.totalElectriQuantity}</if> <if test="query.totalElectriQuantity != null "> and bd.total_electri_quantity = #{query.totalElectriQuantity}</if>
<if test="query.onlineStatus != null and query.onlineStatus != ''"> and bd.online_status = #{query.onlineStatus}</if> <if test="query.onlineStatus != null and query.onlineStatus != ''"> and bd.online_status = #{query.onlineStatus}</if>
@ -143,6 +143,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="query.wxs != null "> and bd.wxs = #{query.wxs}</if> <if test="query.wxs != null "> and bd.wxs = #{query.wxs}</if>
<if test="query.isUnbound != null and query.isUnbound "> and bd.booth_id IS NULL</if> <if test="query.isUnbound != null and query.isUnbound "> and bd.booth_id IS NULL</if>
<if test="query.lastRecoverTime != null "> and bd.last_recover_time = #{query.lastRecoverTime}</if> <if test="query.lastRecoverTime != null "> and bd.last_recover_time = #{query.lastRecoverTime}</if>
<if test="query.macList != null and query.macList.size() > 0">
and bd.mac in
<foreach collection="query.macList" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
${@com.ruoyi.framework.util.DataScopeUtil@create(query.scope) ${@com.ruoyi.framework.util.DataScopeUtil@create(query.scope)
.userSetAlias("bd.user_id") .userSetAlias("bd.user_id")
.storeAlias("bd.store_id",query.storePermissions) .storeAlias("bd.store_id",query.storePermissions)
@ -262,6 +268,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
group by `key` group by `key`
</select> </select>
<!--selectMacSnList-->
<select id="selectMacSnList" resultType="com.ruoyi.bst.device.domain.vo.DeviceMacSnVO">
select
bd.mac,
bd.device_no
from bst_device bd
<where>
<include refid="searchCondition"/>
</where>
</select>
<insert id="insertDevice" parameterType="Device" useGeneratedKeys="true" keyProperty="deviceId"> <insert id="insertDevice" parameterType="Device" useGeneratedKeys="true" keyProperty="deviceId">
<selectKey resultType="Long" order="AFTER" keyProperty="deviceId"> <selectKey resultType="Long" order="AFTER" keyProperty="deviceId">
select LAST_INSERT_ID() select LAST_INSERT_ID()
@ -880,7 +897,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<update id="unbindStore"> <update id="unbindStore">
update bst_device update bst_device
set store_id = null set store_id = null,booth_id = null
where device_id = #{deviceId} where device_id = #{deviceId}
</update> </update>
@ -901,7 +918,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<update id="unbindBooth"> <update id="unbindBooth">
update bst_device update bst_device
set booth_id = null,store_id = null set booth_id = null
where device_id = #{deviceId} where device_id = #{deviceId}
</update> </update>

View File

@ -12,6 +12,7 @@ import com.ruoyi.bst.booth.domain.BoothVO;
import com.ruoyi.bst.device.domain.Device; import com.ruoyi.bst.device.domain.Device;
import com.ruoyi.bst.device.domain.DeviceVO; import com.ruoyi.bst.device.domain.DeviceVO;
import com.ruoyi.bst.device.domain.DeviceQuery; import com.ruoyi.bst.device.domain.DeviceQuery;
import com.ruoyi.bst.device.domain.vo.DeviceMacSnVO;
import com.ruoyi.bst.store.domain.StoreVO; import com.ruoyi.bst.store.domain.StoreVO;
import com.ruoyi.common.domain.vo.LongIntegerVO; import com.ruoyi.common.domain.vo.LongIntegerVO;
@ -136,10 +137,9 @@ public interface DeviceService
/** /**
* 根据设备ID解除绑定 * 根据设备ID解除绑定
* @param deviceId * @param deviceId
* @param booth
* @return * @return
*/ */
public void unbindBooth(Long deviceId,BoothVO booth); public void unbindBooth(Long deviceId);
/** /**
@ -170,4 +170,13 @@ public interface DeviceService
* @param store * @param store
*/ */
void unbindStore(Long deviceId, StoreVO store); void unbindStore(Long deviceId, StoreVO store);
/**
* 根据mac查询SN
*
* @param macList
* @return
*/
public List<DeviceMacSnVO> listSnByMac(List<String> macList);
} }

View File

@ -22,6 +22,7 @@ import com.ruoyi.bst.device.domain.dto.DeviceWifiDTO;
import com.ruoyi.bst.device.domain.enums.DeviceOnlineStatus; import com.ruoyi.bst.device.domain.enums.DeviceOnlineStatus;
import com.ruoyi.bst.device.domain.enums.DevicePowerStatus; import com.ruoyi.bst.device.domain.enums.DevicePowerStatus;
import com.ruoyi.bst.device.domain.enums.DeviceStatus; import com.ruoyi.bst.device.domain.enums.DeviceStatus;
import com.ruoyi.bst.device.domain.vo.DeviceMacSnVO;
import com.ruoyi.bst.model.domain.ModelVO; import com.ruoyi.bst.model.domain.ModelVO;
import com.ruoyi.bst.model.domain.enums.ModelTag; import com.ruoyi.bst.model.domain.enums.ModelTag;
import com.ruoyi.bst.model.service.ModelService; import com.ruoyi.bst.model.service.ModelService;
@ -378,7 +379,7 @@ public class DeviceServiceImpl implements DeviceService
} }
@Override @Override
public void unbindBooth(Long deviceId, BoothVO booth) { public void unbindBooth(Long deviceId) {
DeviceVO device = deviceMapper.selectDeviceByDeviceId(deviceId); DeviceVO device = deviceMapper.selectDeviceByDeviceId(deviceId);
ServiceUtil.assertion(device == null, "设备未录入"); ServiceUtil.assertion(device == null, "设备未录入");
@ -448,4 +449,14 @@ public class DeviceServiceImpl implements DeviceService
int i = deviceMapper.unbindStore(device.getDeviceId()); int i = deviceMapper.unbindStore(device.getDeviceId());
ServiceUtil.assertion(i==0,"绑定失败"); ServiceUtil.assertion(i==0,"绑定失败");
} }
@Override
public List<DeviceMacSnVO> listSnByMac(List<String> macList) {
if (CollectionUtils.isEmptyElement(macList)) {
return Collections.emptyList();
}
DeviceQuery query = new DeviceQuery();
query.setMacList(macList);
return deviceMapper.selectMacSnList(query);
}
} }

View File

@ -19,12 +19,12 @@ public class LightingNumVO extends LightingNum{
@ApiModelProperty("用户昵称") @ApiModelProperty("用户昵称")
private String nickName; private String nickName;
@Excel(name = "户账号") @Excel(name = "户账号")
@ApiModelProperty("户账号") @ApiModelProperty("户账号")
private String mchName; private String mchName;
@Excel(name = "户昵称") @Excel(name = "户昵称")
@ApiModelProperty("户昵称") @ApiModelProperty("户昵称")
private String mchNickName; private String mchNickName;
} }

View File

@ -38,7 +38,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="query.userId != null "> and bln.user_id = #{query.userId}</if> <if test="query.userId != null "> and bln.user_id = #{query.userId}</if>
<if test="query.storeId != null "> and bln.store_id = #{query.storeId}</if> <if test="query.storeId != null "> and bln.store_id = #{query.storeId}</if>
<if test="query.number != null "> and bln.number = #{query.number}</if> <if test="query.number != null "> and bln.number = #{query.number}</if>
<if test="query.userName != null "> and bs.user_name like concat('%',#{query.userName},'%') </if> <if test="query.userName != null "> and su.user_name like concat('%',#{query.userName},'%') </if>
<if test="query.nickName != null "> and su.nick_name like concat('%',#{query.nickName},'%') </if>
<if test="query.storeName != null "> and bs.store_name like concat('%',#{query.storeName},'%')</if> <if test="query.storeName != null "> and bs.store_name like concat('%',#{query.storeName},'%')</if>
<if test="query.mchId != null "> and bs.user_id = #{query.mchId}</if> <if test="query.mchId != null "> and bs.user_id = #{query.mchId}</if>
${@com.ruoyi.framework.util.DataScopeUtil@create(query.scope) ${@com.ruoyi.framework.util.DataScopeUtil@create(query.scope)

View File

@ -18,6 +18,9 @@ public class OrderQuery extends OrderVO{
@ApiModelProperty("用户id列表") @ApiModelProperty("用户id列表")
private List<Long> userIds; private List<Long> userIds;
@ApiModelProperty("下单用户")
private String userName;
@ApiModelProperty("商户id") @ApiModelProperty("商户id")
private Long mchId; private Long mchId;

View File

@ -59,7 +59,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</sql> </sql>
<sql id="searchCondition"> <sql id="searchCondition">
<if test="query.orderNo != null and query.orderNo != ''"> and bo.order_no = #{query.orderNo}</if> <if test="query.orderNo != null and query.orderNo != ''"> and bo.order_no like concat('%', #{query.orderNo}, '%')</if>
<if test="query.id != null and query.id != ''"> and bo.id = #{query.id}</if> <if test="query.id != null and query.id != ''"> and bo.id = #{query.id}</if>
<if test="query.storeId != null "> and bo.store_id = #{query.storeId}</if> <if test="query.storeId != null "> and bo.store_id = #{query.storeId}</if>
<if test="query.storeName != null and query.storeName != ''"> and bo.store_name like concat('%', #{query.storeName}, '%')</if> <if test="query.storeName != null and query.storeName != ''"> and bo.store_name like concat('%', #{query.storeName}, '%')</if>
@ -78,6 +78,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="query.endTime != null"> and date(bo.create_time) &lt;= #{query.endTime}</if> <if test="query.endTime != null"> and date(bo.create_time) &lt;= #{query.endTime}</if>
<if test="query.createDate != null"> and date(bo.create_time) = #{query.createDate}</if> <if test="query.createDate != null"> and date(bo.create_time) = #{query.createDate}</if>
<if test="query.mchId != null"> and bs.user_id = #{query.mchId}</if> <if test="query.mchId != null"> and bs.user_id = #{query.mchId}</if>
<if test="query.userName != null"> and su.user_name like concat('%', #{query.userName}, '%')</if>
<if test="query.statusList != null and query.statusList.size() > 0"> <if test="query.statusList != null and query.statusList.size() > 0">
and bo.status in and bo.status in
<foreach collection="query.statusList" item="item" open="(" separator="," close=")"> <foreach collection="query.statusList" item="item" open="(" separator="," close=")">

View File

@ -37,7 +37,7 @@ public class PayConverterImpl implements PayConverter {
// 基础信息 // 基础信息
pay.setStatus(PayStatus.WAIT_PAY.getStatus()); pay.setStatus(PayStatus.WAIT_PAY.getStatus());
pay.setExpireTime(LocalDateTime.now().plusMinutes(10)); pay.setExpireTime(LocalDateTime.now().plusMinutes(10));
pay.setRemark("充值订单:"+order.getOrderNo()); pay.setDescription("充值订单:"+order.getOrderNo());
// 订单信息 // 订单信息
pay.setBstType(PayBstType.ORDER.getType()); pay.setBstType(PayBstType.ORDER.getType());

View File

@ -41,6 +41,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="query.storeId != null and query.storeId != ''"> and br.store_id = #{query.storeId}</if> <if test="query.storeId != null and query.storeId != ''"> and br.store_id = #{query.storeId}</if>
<if test="query.month != null">and month(br.create_time) = #{query.month}</if> <if test="query.month != null">and month(br.create_time) = #{query.month}</if>
<if test="query.year != null">and year(br.create_time) = #{query.year}</if> <if test="query.year != null">and year(br.create_time) = #{query.year}</if>
<if test="query.createDate != null">and date(br.create_time) = #{query.createDate}</if>
<if test="query.createDateRange != null and query.createDateRange.size() > 1"> <if test="query.createDateRange != null and query.createDateRange.size() > 1">
and date(br.create_time) &gt;= #{query.createDateRange[0]} and date(br.create_time) &gt;= #{query.createDateRange[0]}
and date(br.create_time) &lt;= #{query.createDateRange[1]} and date(br.create_time) &lt;= #{query.createDateRange[1]}

View File

@ -31,6 +31,7 @@ public class Store extends BaseEntity
@Excel(name = "用户ID") @Excel(name = "用户ID")
@ApiModelProperty("用户ID") @ApiModelProperty("用户ID")
@NotNull(message = "所属用户不能为空",groups = {ValidGroup.Create.class})
private Long userId; private Long userId;
@Excel(name = "店铺名称") @Excel(name = "店铺名称")

View File

@ -14,6 +14,7 @@ public class StoreConverterImpl implements StoreConverter {
Store po = new Store(); Store po = new Store();
// 设置基本信息 // 设置基本信息
po.setStoreName(data.getStoreName()); po.setStoreName(data.getStoreName());
po.setUserId(data.getUserId());
po.setUserName(data.getUserName()); po.setUserName(data.getUserName());
po.setPhone(data.getPhone()); po.setPhone(data.getPhone());
po.setStartTime(data.getStartTime()); po.setStartTime(data.getStartTime());
@ -33,6 +34,7 @@ public class StoreConverterImpl implements StoreConverter {
Store po = new Store(); Store po = new Store();
// 设置基本信息 // 设置基本信息
po.setStoreId(data.getStoreId()); po.setStoreId(data.getStoreId());
po.setUserId(data.getUserId());
po.setStoreName(data.getStoreName()); po.setStoreName(data.getStoreName());
po.setUserName(data.getUserName()); po.setUserName(data.getUserName());
po.setPhone(data.getPhone()); po.setPhone(data.getPhone());

View File

@ -32,12 +32,12 @@ public class AppBoothController extends BaseController {
private BoothService boothService; private BoothService boothService;
@ApiOperation("爆灯") @ApiOperation("爆灯")
@PutMapping("/{boothNo}/lighting") @PutMapping("/{boothId}/lighting")
public AjaxResult lighting(@PathVariable @ApiParam("设备id") String boothNo,boolean requiredIot) { public AjaxResult lighting(@PathVariable @ApiParam("设备id") Long boothId,boolean requiredIot) {
if (boothNo == null) { if (boothId == null) {
return error("卡座编号不能为空"); return error("卡座编号不能为空");
} }
BoothVO booth = boothService.selectBoothByBoothNo(boothNo); BoothVO booth = boothService.selectBoothByBoothId(boothId);
if (booth == null) { if (booth == null) {
return error("当前卡座信息不存在"); return error("当前卡座信息不存在");
} }
@ -51,21 +51,21 @@ public class AppBoothController extends BaseController {
} }
@ApiOperation("用户绑定卡座") @ApiOperation("用户绑定卡座")
@PutMapping("/{boothNo}/bindUser") @PutMapping("/{boothId}/bindUser")
public AjaxResult bindBooth(@PathVariable String boothNo) { public AjaxResult bindBooth(@PathVariable Long boothId) {
if (boothNo == null) { if (boothId == null) {
return error("卡座编号不能为空"); return error("卡座编号不能为空");
}; };
return AjaxResult.success(boothService.bindUser(getUserId(),boothNo)); return AjaxResult.success(boothService.bindUser(getUserId(),boothId));
} }
@ApiOperation("用户解绑卡座") @ApiOperation("用户解绑卡座")
@PutMapping("/{boothNo}/unbind") @PutMapping("/{boothId}/unbind")
public AjaxResult unbindBooth(@PathVariable String boothNo) { public AjaxResult unbindBooth(@PathVariable Long boothId) {
if (boothNo == null) { if (boothId == null) {
return error("卡座编号不能为空"); return error("卡座编号不能为空");
}; };
BoothVO booth = boothService.selectBoothByBoothNo(boothNo); BoothVO booth = boothService.selectBoothByBoothId(boothId);
ServiceUtil.assertion(booth==null,"当前卡座不存在"); ServiceUtil.assertion(booth==null,"当前卡座不存在");
ServiceUtil.assertion(!booth.getUserId().equals(getUserId()),"您无权操作当前卡座设备"); ServiceUtil.assertion(!booth.getUserId().equals(getUserId()),"您无权操作当前卡座设备");
return AjaxResult.success(boothService.unbindUser(booth)); return AjaxResult.success(boothService.unbindUser(booth));
@ -73,11 +73,11 @@ public class AppBoothController extends BaseController {
@ApiOperation("用户换绑卡座") @ApiOperation("用户换绑卡座")
@PutMapping("/userChangeBind") @PutMapping("/userChangeBind")
public AjaxResult userChangeBind( String usingBoothNo ,String changeBoothNo) { public AjaxResult userChangeBind( Long usingBoothId ,Long changeBoothId) {
if (usingBoothNo == null || changeBoothNo == null) { if (usingBoothId == null || changeBoothId == null) {
return error("卡座编号不能为空"); return error("卡座ID不能为空");
}; };
return AjaxResult.success(boothService.userChangeBind(usingBoothNo,changeBoothNo,getUserId())); return AjaxResult.success(boothService.userChangeBind(usingBoothId,changeBoothId,getUserId()));
} }
@ApiOperation("查询用户绑定的卡座和设备信息") @ApiOperation("查询用户绑定的卡座和设备信息")

View File

@ -114,7 +114,6 @@ public class BoothController extends BaseController {
if (!partValidator.canCheckForPart(booth.getPartId())) { if (!partValidator.canCheckForPart(booth.getPartId())) {
return AjaxResult.error("您无权选择ID为" + booth.getPartId() + "的分区"); return AjaxResult.error("您无权选择ID为" + booth.getPartId() + "的分区");
} }
// 卡座编号唯一性校验
return toAjax(boothService.insertBooth(booth)); return toAjax(boothService.insertBooth(booth));
} }
@ -154,7 +153,6 @@ public class BoothController extends BaseController {
if (boothId == null) { if (boothId == null) {
return AjaxResult.error("卡座ID不能为空"); return AjaxResult.error("卡座ID不能为空");
} }
if (!boothValidator.canEdit(boothId)) { if (!boothValidator.canEdit(boothId)) {
return AjaxResult.error("您无更改该卡座相关的权限"); return AjaxResult.error("您无更改该卡座相关的权限");
} }
@ -165,12 +163,10 @@ public class BoothController extends BaseController {
if (!storeValidator.canEdit(booth.getStoreId())) { if (!storeValidator.canEdit(booth.getStoreId())) {
return AjaxResult.error("您无权限操作当前店铺信息"); return AjaxResult.error("您无权限操作当前店铺信息");
} }
// 设备权限校验 // 设备权限校验
if (!deviceValidator.canOperate(device.getDeviceId())) { if (!deviceValidator.canOperate(device.getDeviceId())) {
return AjaxResult.error("您无权限操作当设备信息"); return AjaxResult.error("您无权限操作当设备信息");
} }
// 绑定设备 // 绑定设备
if (device.getDeviceId() != null) { if (device.getDeviceId() != null) {
return AjaxResult.success("操作成功", deviceService.bindBoothById(device.getDeviceId(), booth)); return AjaxResult.success("操作成功", deviceService.bindBoothById(device.getDeviceId(), booth));
@ -209,7 +205,7 @@ public class BoothController extends BaseController {
return AjaxResult.error("您无权限操作当设备信息"); return AjaxResult.error("您无权限操作当设备信息");
} }
deviceService.unbindBooth(device.getDeviceId(), booth); deviceService.unbindBooth(device.getDeviceId());
return AjaxResult.success("操作成功"); return AjaxResult.success("操作成功");
} }
} }

View File

@ -90,7 +90,7 @@ public class ChangeRecordController extends BaseController
@PreAuthorize("@ss.hasPermi('bst:changeRecord:consumeRecord')") @PreAuthorize("@ss.hasPermi('bst:changeRecord:consumeRecord')")
@Log(title = "爆灯次数变化") @Log(title = "消费记录列表")
@GetMapping("/consumeRecord") @GetMapping("/consumeRecord")
public AjaxResult consumeRecord(ChangeRecordQuery query) { public AjaxResult consumeRecord(ChangeRecordQuery query) {
if (query.getUserId() == null) { if (query.getUserId() == null) {

View File

@ -196,5 +196,14 @@ public class DeviceController extends BaseController
return AjaxResult.success(deviceService.updateDeviceStore(device)); return AjaxResult.success(deviceService.updateDeviceStore(device));
} }
/**
* 查询MAC对应的SN
*/
@PreAuthorize("@ss.hasPermi('bst:device:list')")
@PostMapping("/listSnByMac")
public AjaxResult listSnByMac(@RequestBody List<String> macList) {
return success(deviceService.listSnByMac(macList));
}
} }