mirror of
https://gitee.com/beecue/fastbee.git
synced 2025-12-18 00:45:55 +08:00
设备授权添加状态和筛选
This commit is contained in:
@@ -42,6 +42,10 @@ public class ProductAuthorize extends BaseEntity
|
||||
@Excel(name = "用户名称")
|
||||
private String userName;
|
||||
|
||||
/** 状态(1-未发布,2-已发布,不能修改) */
|
||||
@Excel(name = "状态", readConverterExp = "1=-未分配,2-使用中")
|
||||
private Integer status;
|
||||
|
||||
/** 删除标志(0代表存在 2代表删除) */
|
||||
private String delFlag;
|
||||
|
||||
@@ -53,6 +57,14 @@ public class ProductAuthorize extends BaseEntity
|
||||
this.productId = productId;
|
||||
}
|
||||
|
||||
public void setStatus(Integer status)
|
||||
{
|
||||
this.status = status;
|
||||
}
|
||||
public Integer getStatus()
|
||||
{
|
||||
return status;
|
||||
}
|
||||
public void setAuthorizeId(Long authorizeId)
|
||||
{
|
||||
this.authorizeId = authorizeId;
|
||||
|
||||
@@ -116,4 +116,11 @@ public interface ProductMapper
|
||||
* @return 结果
|
||||
*/
|
||||
public int thingsCountInProduct(Long productId);
|
||||
|
||||
/**
|
||||
* 产品下的物模型标识符重复数
|
||||
* @param productId 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int thingsRepeatCountInProduct(Long productId);
|
||||
}
|
||||
|
||||
@@ -60,6 +60,8 @@ public class ProductAuthorizeServiceImpl implements IProductAuthorizeService {
|
||||
*/
|
||||
@Override
|
||||
public int insertProductAuthorize(ProductAuthorize productAuthorize) {
|
||||
// 1=未使用,2=使用中
|
||||
productAuthorize.setStatus(1);
|
||||
productAuthorize.setCreateTime(DateUtils.getNowDate());
|
||||
return productAuthorizeMapper.insertProductAuthorize(productAuthorize);
|
||||
}
|
||||
@@ -72,6 +74,10 @@ public class ProductAuthorizeServiceImpl implements IProductAuthorizeService {
|
||||
*/
|
||||
@Override
|
||||
public int updateProductAuthorize(ProductAuthorize productAuthorize) {
|
||||
if(productAuthorize.getDeviceId()!=null && productAuthorize.getDeviceId()!=0){
|
||||
// 1=未使用,2=使用中
|
||||
productAuthorize.setStatus(2);
|
||||
}
|
||||
productAuthorize.setUpdateTime(DateUtils.getNowDate());
|
||||
return productAuthorizeMapper.updateProductAuthorize(productAuthorize);
|
||||
}
|
||||
@@ -113,6 +119,8 @@ public class ProductAuthorizeServiceImpl implements IProductAuthorizeService {
|
||||
SysUser user = getLoginUser().getUser();
|
||||
for (int i = 0; i < createNum; i++) {
|
||||
ProductAuthorize authorize = new ProductAuthorize();
|
||||
// 1=未使用,2=使用中
|
||||
authorize.setStatus(1);
|
||||
authorize.setProductId(productId);
|
||||
authorize.setCreateBy(user.getUserName());
|
||||
authorize.setCreateTime(DateUtils.getNowDate());
|
||||
|
||||
@@ -154,6 +154,11 @@ public class ProductServiceImpl implements IProductService
|
||||
if(thingsCount==0){
|
||||
return AjaxResult.error("发布失败,请先添加产品的物模型");
|
||||
}
|
||||
// 产品下物模型的标识符必须唯一
|
||||
int repeatCount=productMapper.thingsRepeatCountInProduct(model.getProductId());
|
||||
if(repeatCount>1){
|
||||
return AjaxResult.error("发布失败,产品物模型的标识符必须唯一");
|
||||
}
|
||||
}else{
|
||||
return AjaxResult.error("状态更新失败,状态值有误");
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="serialNumber" column="serial_number" />
|
||||
<result property="userId" column="user_id" />
|
||||
<result property="userName" column="user_name" />
|
||||
<result property="status" column="status" />
|
||||
<result property="delFlag" column="del_flag" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
@@ -21,7 +22,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectProductAuthorizeVo">
|
||||
select authorize_id, authorize_code, product_id, device_id, serial_number, user_id, user_name, del_flag, create_by, create_time, update_by, update_time, remark from iot_product_authorize
|
||||
select authorize_id, authorize_code, product_id, device_id, serial_number, user_id, user_name,status, del_flag, create_by, create_time, update_by, update_time, remark from iot_product_authorize
|
||||
</sql>
|
||||
|
||||
<select id="selectProductAuthorizeList" parameterType="com.ruoyi.iot.domain.ProductAuthorize" resultMap="ProductAuthorizeResult">
|
||||
@@ -30,12 +31,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="authorizeCode != null and authorizeCode != ''"> and authorize_code = #{authorizeCode}</if>
|
||||
<if test="productId != null "> and product_id = #{productId}</if>
|
||||
<if test="deviceId != null "> and device_id = #{deviceId}</if>
|
||||
<if test="status != null "> and status = #{status}</if>
|
||||
<if test="serialNumber != null and serialNumber != ''"> and serial_number = #{serialNumber}</if>
|
||||
<if test="userId != null "> and user_id = #{userId}</if>
|
||||
<if test="userName != null and userName != ''"> and user_name like concat('%', #{userName}, '%')</if>
|
||||
</where>
|
||||
order by
|
||||
device_id desc
|
||||
order by create_time desc
|
||||
</select>
|
||||
|
||||
<select id="selectProductAuthorizeByAuthorizeId" parameterType="Long" resultMap="ProductAuthorizeResult">
|
||||
@@ -61,6 +62,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="serialNumber != null">serial_number,</if>
|
||||
<if test="userId != null">user_id,</if>
|
||||
<if test="userName != null">user_name,</if>
|
||||
<if test="status != null">status,</if>
|
||||
<if test="createBy != null and createBy != ''">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
@@ -74,6 +76,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="serialNumber != null">#{serialNumber},</if>
|
||||
<if test="userId != null">#{userId},</if>
|
||||
<if test="userName != null">#{userName},</if>
|
||||
<if test="status != null">#{status},</if>
|
||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
@@ -81,12 +84,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="remark != null">#{remark},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<insert id="insertBatchAuthorize" parameterType="com.ruoyi.iot.domain.ProductAuthorize" useGeneratedKeys="true" keyProperty="authorizeId">
|
||||
insert into iot_product_authorize (authorize_code,product_id,create_by,create_time)
|
||||
insert into iot_product_authorize (authorize_code,product_id,create_by,create_time,status)
|
||||
values
|
||||
<foreach item="item" collection="list" separator=",">
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
#{item.authorizeCode},#{item.productId},#{item.createBy},#{item.createTime}
|
||||
#{item.authorizeCode},#{item.productId},#{item.createBy},#{item.createTime},#{item.status}
|
||||
</trim>
|
||||
</foreach>
|
||||
</insert>
|
||||
@@ -100,6 +104,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="productId != null">product_id = #{productId},</if>
|
||||
<if test="serialNumber != null">serial_number = #{serialNumber},</if>
|
||||
<if test="userName != null">user_name = #{userName},</if>
|
||||
<if test="status != null">status = #{status},</if>
|
||||
<if test="delFlag != null and delFlag != ''">del_flag = #{delFlag},</if>
|
||||
<if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
|
||||
@@ -185,6 +185,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</select>
|
||||
|
||||
<select id="thingsCountInProduct" parameterType="Long" resultType="int">
|
||||
select count(*) from iot_things_model where product_id = #{productId}
|
||||
select count(model_id) from iot_things_model where product_id = #{productId}
|
||||
</select>
|
||||
|
||||
<select id="thingsRepeatCountInProduct" parameterType="Long" resultType="int">
|
||||
SELECT count( identifier )
|
||||
FROM ( SELECT identifier
|
||||
FROM iot_things_model
|
||||
WHERE product_id = #{productId}
|
||||
GROUP BY identifier
|
||||
HAVING count( identifier )> 1 ) AS identifiers
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user