das接口文档修改,设备类型接口修改
This commit is contained in:
parent
04d2769d7c
commit
4ebb3d9d34
@ -13,6 +13,7 @@ import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
@ -100,4 +101,9 @@ public class SysOrg extends BaseEntity {
|
||||
@TableField("alias_name")
|
||||
private String aliasName;
|
||||
|
||||
/**
|
||||
* 子节点
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private List<SysOrg> children;
|
||||
}
|
||||
|
@ -5,6 +5,8 @@ import com.das.common.constant.EquipmentTypeIds;
|
||||
import com.das.common.constant.SysAuthorityIds;
|
||||
import com.das.common.exceptions.ServiceException;
|
||||
import com.das.common.result.R;
|
||||
import com.das.common.utils.PageDataInfo;
|
||||
import com.das.modules.auth.entity.SysOrg;
|
||||
import com.das.modules.equipment.domain.dto.SysEquipmentDto;
|
||||
import com.das.modules.equipment.domain.vo.EquipmentTypeVo;
|
||||
import com.das.modules.equipment.domain.vo.SysEquipmentVo;
|
||||
@ -91,7 +93,7 @@ public class EquipmentController {
|
||||
return R.fail("没有设备管理权限");
|
||||
}
|
||||
|
||||
if (sysEquipmentDto.getOrgId() == null) {
|
||||
if (sysEquipmentDto.getId() == null) {
|
||||
throw new ServiceException("参数缺失");
|
||||
}
|
||||
sysEquipmentService.deleteSysEquipment(sysEquipmentDto);
|
||||
@ -100,21 +102,23 @@ public class EquipmentController {
|
||||
|
||||
|
||||
/**
|
||||
* 查询设备类型列表(需要修改)
|
||||
* 查询设备类型列表
|
||||
* @return 所有的设备类型
|
||||
*/
|
||||
@PostMapping("/list")
|
||||
public R<Void> querySysEquipment(@RequestBody SysEquipmentDto sysEquipmentDto) {
|
||||
//判断是否有权限
|
||||
boolean hasPermission = StpUtil.hasPermission(SysAuthorityIds.SYS_AUTHORITY_ID_DEVICE_MGR.toString());
|
||||
if(!hasPermission){
|
||||
return R.fail("没有设备管理权限");
|
||||
}
|
||||
@PostMapping("/query")
|
||||
public PageDataInfo<SysEquipmentVo> querySysEquipmentList(@RequestBody SysEquipmentDto sysEquipmentDto) {
|
||||
return sysEquipmentService.querySysEquipmentList(sysEquipmentDto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询设备树
|
||||
* @return 所有的设备类型
|
||||
*/
|
||||
@PostMapping("/getDeviceTree")
|
||||
public R<List<SysOrg>> getRootOrg(@RequestBody SysEquipmentDto sysEquipmentDto) {
|
||||
if (sysEquipmentDto.getOrgId() == null) {
|
||||
throw new ServiceException("参数缺失");
|
||||
}
|
||||
sysEquipmentService.querySysEquipment(sysEquipmentDto);
|
||||
return R.success();
|
||||
return R.success(sysEquipmentService.getRootOrg(sysEquipmentDto));
|
||||
}
|
||||
}
|
||||
|
@ -85,4 +85,14 @@ public class SysEquipmentDto {
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long iotModelId;
|
||||
|
||||
/**
|
||||
* 分页大小
|
||||
*/
|
||||
private Integer pageSize;
|
||||
|
||||
/**
|
||||
* 当前页数
|
||||
*/
|
||||
private Integer pageNum;
|
||||
}
|
||||
|
@ -2,11 +2,17 @@ package com.das.modules.equipment.mapper;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.das.modules.equipment.domain.dto.SysEquipmentDto;
|
||||
import com.das.modules.equipment.domain.dto.SysIotModelFieldDto;
|
||||
import com.das.modules.equipment.domain.vo.SysEquipmentVo;
|
||||
import com.das.modules.equipment.domain.vo.SysIotModelFieldVo;
|
||||
import com.das.modules.equipment.entity.SysEquipment;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
@Mapper
|
||||
public interface SysEquipmentMapper extends BaseMapper<SysEquipment> {
|
||||
|
||||
|
||||
IPage<SysEquipmentVo> querySysEquipmentList(IPage<SysEquipmentVo> page, @Param("info") SysEquipmentDto sysEquipmentDto);
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package com.das.modules.equipment.service;
|
||||
|
||||
import com.das.common.utils.PageDataInfo;
|
||||
import com.das.modules.auth.entity.SysOrg;
|
||||
import com.das.modules.equipment.domain.dto.SysEquipmentDto;
|
||||
import com.das.modules.equipment.domain.dto.SysIotModelDto;
|
||||
import com.das.modules.equipment.domain.dto.SysIotModelFieldDto;
|
||||
@ -20,5 +22,8 @@ public interface SysEquipmentService {
|
||||
|
||||
void deleteSysEquipment(SysEquipmentDto sysEquipmentDto);
|
||||
|
||||
SysEquipmentDto querySysEquipment(SysEquipmentDto sysEquipmentDto);
|
||||
PageDataInfo<SysEquipmentVo> querySysEquipmentList(SysEquipmentDto sysEquipmentDto);
|
||||
|
||||
List<SysOrg> getRootOrg(SysEquipmentDto sysEquipmentDto);
|
||||
|
||||
}
|
||||
|
@ -2,12 +2,17 @@ package com.das.modules.equipment.service.impl;
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.das.common.config.SessionUtil;
|
||||
import com.das.common.exceptions.ServiceException;
|
||||
import com.das.common.utils.BeanCopyUtils;
|
||||
import com.das.common.utils.PageDataInfo;
|
||||
import com.das.common.utils.PageQuery;
|
||||
import com.das.modules.auth.domain.vo.SysUserVo;
|
||||
import com.das.modules.auth.entity.SysOrg;
|
||||
import com.das.modules.equipment.domain.dto.SysEquipmentDto;
|
||||
import com.das.modules.equipment.domain.vo.SysEquipmentVo;
|
||||
import com.das.modules.equipment.domain.vo.SysIotModelServiceVo;
|
||||
import com.das.modules.equipment.domain.vo.SysIotModelVo;
|
||||
import com.das.modules.equipment.entity.SysEquipment;
|
||||
import com.das.modules.equipment.entity.SysIotModel;
|
||||
@ -19,6 +24,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Service
|
||||
@ -31,12 +37,13 @@ public class SysEquipmentServiceImpl implements SysEquipmentService {
|
||||
SysEquipment sysEquipment = new SysEquipment();
|
||||
BeanCopyUtils.copy(sysEquipmentDto,sysEquipment);
|
||||
|
||||
SysUserVo sysUserVo = (SysUserVo) StpUtil.getTokenSession().get(SessionUtil.SESSION_USER_KEY);
|
||||
// SysUserVo sysUserVo = (SysUserVo) StpUtil.getTokenSession().get(SessionUtil.SESSION_USER_KEY);
|
||||
sysEquipment.setCreatedTime(new Date());
|
||||
sysEquipment.setUpdatedTime(new Date());
|
||||
sysEquipment.setCreatedBy(sysUserVo.getAccount());
|
||||
sysEquipment.setUpdatedBy(sysUserVo.getAccount());
|
||||
|
||||
// sysEquipment.setCreatedBy(sysUserVo.getAccount());
|
||||
// sysEquipment.setUpdatedBy(sysUserVo.getAccount());
|
||||
sysEquipment.setCreatedBy("测试");
|
||||
sysEquipment.setUpdatedBy("测试");
|
||||
sysEquipment.setRevision(1);
|
||||
sysEquipmentMapper.insert(sysEquipment);
|
||||
SysEquipmentVo sysEquipmentVo = new SysEquipmentVo();
|
||||
@ -48,9 +55,9 @@ public class SysEquipmentServiceImpl implements SysEquipmentService {
|
||||
public SysEquipmentVo updateSysEquipment(SysEquipmentDto sysEquipmentDto) {
|
||||
SysEquipment sysEquipment = new SysEquipment();
|
||||
BeanCopyUtils.copy(sysEquipmentDto,sysEquipment);
|
||||
SysUserVo sysUserVo = (SysUserVo) StpUtil.getTokenSession().get(SessionUtil.SESSION_USER_KEY);
|
||||
// SysUserVo sysUserVo = (SysUserVo) StpUtil.getTokenSession().get(SessionUtil.SESSION_USER_KEY);
|
||||
sysEquipment.setUpdatedTime(new Date());
|
||||
sysEquipment.setUpdatedBy(sysUserVo.getAccount());
|
||||
sysEquipment.setUpdatedBy("测试");
|
||||
// sysIotModel.setUpdatedBy("sysUserVo.getAccount()");
|
||||
sysEquipmentMapper.updateById(sysEquipment);
|
||||
SysEquipmentVo sysEquipmentVo = new SysEquipmentVo();
|
||||
@ -64,7 +71,16 @@ public class SysEquipmentServiceImpl implements SysEquipmentService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysEquipmentDto querySysEquipment(SysEquipmentDto sysEquipmentDto) {
|
||||
public PageDataInfo<SysEquipmentVo> querySysEquipmentList(SysEquipmentDto sysEquipmentDto) {
|
||||
PageQuery pageQuery = new PageQuery();
|
||||
pageQuery.setPageNum(sysEquipmentDto.getPageNum());
|
||||
pageQuery.setPageSize(sysEquipmentDto.getPageSize());
|
||||
IPage<SysEquipmentVo> iPage = sysEquipmentMapper.querySysEquipmentList(pageQuery.build(), sysEquipmentDto);
|
||||
return PageDataInfo.build(iPage.getRecords(), iPage.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysOrg> getRootOrg(SysEquipmentDto sysEquipmentDto) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
37
das/src/main/resources/mapper/SysEquipmentMapper.xml
Normal file
37
das/src/main/resources/mapper/SysEquipmentMapper.xml
Normal file
@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.das.modules.equipment.mapper.SysEquipmentMapper">
|
||||
|
||||
<resultMap type="com.das.modules.equipment.domain.vo.SysEquipmentVo" id="SysEquipmentMap">
|
||||
<result property="id" column="id" jdbcType="BIGINT"/>
|
||||
<result property="code" column="code" jdbcType="VARCHAR"/>
|
||||
<result property="location" column="location" jdbcType="VARCHAR"/>
|
||||
<result property="madeinFactory" column="madein_factory" jdbcType="VARCHAR"/>
|
||||
<result property="name" column="name" jdbcType="VARCHAR"/>
|
||||
<result property="model" column="model" jdbcType="VARCHAR"/>
|
||||
<result property="objectType" column="object_type" jdbcType="INTEGER"/>
|
||||
<result property="orgId" column="org_id" jdbcType="BIGINT"/>
|
||||
<result property="parentEquipmentId" column="parent_equipment_id" jdbcType="BIGINT"/>
|
||||
<result property="installDate" column="install_date" jdbcType="TIMESTAMP"/>
|
||||
<result property="remarks" column="remarks" jdbcType="VARCHAR"/>
|
||||
<result property="latitude" column="latitude" jdbcType="REAL"/>
|
||||
<result property="longitude" column="longitude" jdbcType="REAL"/>
|
||||
<result property="iotModelId" column="iot_model_id" jdbcType="BIGINT"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="querySysEquipmentList" resultMap="SysEquipmentMap">
|
||||
select t.* from sys_equipment t
|
||||
<where>
|
||||
<if test="info.iotModelId != null and info.iotModelId != ''">
|
||||
and t.iot_model_id = #{info.iotModelId}
|
||||
</if>
|
||||
<if test="info.orgId != null and info.orgId != ''">
|
||||
and t.org_id = #{info.orgId}
|
||||
</if>
|
||||
<if test="info.parentEquipmentId != null and info.parentEquipmentId != ''">
|
||||
and t.parent_equipment_id = #{info.parentEquipmentId}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
</mapper>
|
@ -655,27 +655,195 @@ POST请求接口
|
||||
|
||||
> /api/equipment/query
|
||||
|
||||
请求参数
|
||||
|
||||
```json
|
||||
{
|
||||
"orgId": 1,
|
||||
"parentEquipmentId": 1,
|
||||
"iotModelId": "",
|
||||
"pageSize": 1,
|
||||
"pageNum": 1
|
||||
}
|
||||
```
|
||||
|
||||
入参描述
|
||||
|
||||
| 参数名 | 参数类型 | 可选 | 描述 |
|
||||
| ----------- | -------- | ---- | -------------------------- |
|
||||
| orgId | 数值 | No | 所属机构ID |
|
||||
| parentEquipmentId | 数值 | No | 上级设备ID |
|
||||
| iotModelId | 字符串 | No | 所属物模型ID |
|
||||
| pageSize | 数值 | No | 每页显示条数 |
|
||||
| pageNum | 数值 | No | 页码 |
|
||||
|
||||
返回报文
|
||||
|
||||
```json
|
||||
{
|
||||
"total": 1,
|
||||
"rows": [
|
||||
{
|
||||
"id": "1809032537527582721",
|
||||
"objectType": 1,
|
||||
"code": "test",
|
||||
"name": "test",
|
||||
"madeinFactory": "test",
|
||||
"model": "test",
|
||||
"location": "test",
|
||||
"longitude": 48.69145,
|
||||
"latitude": 20.6946,
|
||||
"installDate": "2027-04-05 15:30:23",
|
||||
"remarks": "test",
|
||||
"orgId": "1",
|
||||
"parentEquipmentId": "1"
|
||||
}
|
||||
],
|
||||
"code": 200,
|
||||
"msg": "查询成功"
|
||||
}
|
||||
```
|
||||
|
||||
#### 2.3.3 设备新增
|
||||
|
||||
> /api/equipment/add
|
||||
|
||||
|
||||
请求参数
|
||||
|
||||
```json
|
||||
{
|
||||
"objectType": 1,
|
||||
"code": "test",
|
||||
"name": "test",
|
||||
"madeinFactory": "test",
|
||||
"model": "test",
|
||||
"location": "test",
|
||||
"longitude": 48.69145,
|
||||
"latitude": 20.6946,
|
||||
"installDate": "2027-04-05 15:30:23",
|
||||
"remarks": "test",
|
||||
"orgId": 1,
|
||||
"parentEquipmentId": 1,
|
||||
"iotModelId": ""
|
||||
}
|
||||
```
|
||||
|
||||
入参描述
|
||||
|
||||
| 参数名 | 参数类型 | 可选 | 描述 |
|
||||
| ----------- | -------- | ---- | -------------------------- |
|
||||
| objectType | 数值 | No | 设备类型 |
|
||||
| code | 字符串 | No | 设备编码 |
|
||||
| name | 字符串 | No | 设备名称 |
|
||||
| madeinFactory | 字符串 | No | 生产厂家 |
|
||||
| model | 字符串 | No | 规格型号 |
|
||||
| location | 字符串 | No | 位置 |
|
||||
| longitude | 数值 | No | 经度 |
|
||||
| latitude | 数值 | No | 纬度 |
|
||||
| installDate | 字符串 | No | 安装日期 |
|
||||
| remarks | 字符串 | Yes | 备注 |
|
||||
| orgId | 数值 | No | 所属机构ID |
|
||||
| parentEquipmentId | 数值 | No | 上级设备ID |
|
||||
| iotModelId | 字符串 | No | 所属物模型ID |
|
||||
|
||||
返回报文
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"success": true,
|
||||
"data": {
|
||||
"id": "1809029597391814657",
|
||||
"objectType": 1,
|
||||
"code": "test",
|
||||
"name": "test",
|
||||
"madeinFactory": "test",
|
||||
"model": "test",
|
||||
"location": "test",
|
||||
"longitude": 48.69145,
|
||||
"latitude": 20.6946,
|
||||
"installDate": "2027-04-05 15:30:23",
|
||||
"remarks": "test",
|
||||
"orgId": "1",
|
||||
"parentEquipmentId": "1"
|
||||
},
|
||||
"msg": "操作成功"
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
#### 2.3.4 设备修改
|
||||
|
||||
> /api/equipment/update
|
||||
> /api/equipment/update
|
||||
|
||||
|
||||
请求参数
|
||||
|
||||
```json
|
||||
{
|
||||
"id":1809029597391814657,
|
||||
"objectType": 1,
|
||||
"code": "test1",
|
||||
"name": "test1",
|
||||
"madeinFactory": "test1",
|
||||
"model": "test1",
|
||||
"location": "test1",
|
||||
"longitude": 48.69145,
|
||||
"latitude": 20.6946,
|
||||
"installDate": "2027-07-05 15:30:23",
|
||||
"remarks": "test1",
|
||||
"orgId": 1,
|
||||
"parentEquipmentId": 1,
|
||||
"iotModelId": ""
|
||||
}
|
||||
```
|
||||
|
||||
返回报文
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"success": true,
|
||||
"data": {
|
||||
"id": "1809029597391814657",
|
||||
"objectType": 1,
|
||||
"code": "test1",
|
||||
"name": "test1",
|
||||
"madeinFactory": "test1",
|
||||
"model": "test1",
|
||||
"location": "test1",
|
||||
"longitude": 48.69145,
|
||||
"latitude": 20.6946,
|
||||
"installDate": "2027-07-05 15:30:23",
|
||||
"remarks": "test1",
|
||||
"orgId": "1",
|
||||
"parentEquipmentId": "1"
|
||||
},
|
||||
"msg": "操作成功"
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
#### 2.3.5 设备删除
|
||||
|
||||
> /api/equipment/delete
|
||||
|
||||
请求参数
|
||||
```json
|
||||
{
|
||||
"id":1809029597391814657
|
||||
}
|
||||
```
|
||||
|
||||
返回报文
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"success": true,
|
||||
"msg": "操作成功"
|
||||
}
|
||||
```
|
||||
|
||||
#### 2.3.6 Excel导出设备清单
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user