Merge branch 'main' of https://git.jsspisoft.com/ry-das
This commit is contained in:
commit
df7f4c28b5
@ -0,0 +1,84 @@
|
||||
package com.das.common.interceptor;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletRequestWrapper;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.das.common.constant.HeaderConstant.TOKEN_ATTR_NAME;
|
||||
|
||||
// 解密上传请求
|
||||
public class DecryptUploadWrapper extends HttpServletRequestWrapper {
|
||||
|
||||
|
||||
private final String paramName;
|
||||
private final String decryptedValue;
|
||||
|
||||
private final String token;
|
||||
|
||||
public DecryptUploadWrapper(HttpServletRequest request, String paramName, String decryptedValue, String token) {
|
||||
super(request);
|
||||
this.paramName = paramName;
|
||||
this.decryptedValue = decryptedValue;
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getParameter(String name) {
|
||||
if (paramName.equals(name)) {
|
||||
return decryptedValue;
|
||||
}
|
||||
return super.getParameter(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getParameterValues(String name) {
|
||||
if (paramName.equals(name)) {
|
||||
return new String[]{decryptedValue};
|
||||
}
|
||||
return super.getParameterValues(name);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getHeader(String name) {
|
||||
if (TOKEN_ATTR_NAME.equals(name)) {
|
||||
return token;
|
||||
}
|
||||
return super.getHeader(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration<String> getHeaders(String name) {
|
||||
Set<String> set = new HashSet<>(8);
|
||||
if (TOKEN_ATTR_NAME.equals(name) && StrUtil.isNotBlank(token)) {
|
||||
set.add(token);
|
||||
}
|
||||
Enumeration<String> e = super.getHeaders(name);
|
||||
while (e.hasMoreElements()) {
|
||||
String n = e.nextElement();
|
||||
set.add(n);
|
||||
}
|
||||
return Collections.enumeration(set);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration<String> getHeaderNames() {
|
||||
Set<String> set = new HashSet<>(8);
|
||||
Enumeration<String> e = super.getHeaderNames();
|
||||
while (e.hasMoreElements()) {
|
||||
String n = e.nextElement();
|
||||
set.add(n);
|
||||
}
|
||||
if (StrUtil.isNotBlank(token)) {
|
||||
set.add(token);
|
||||
}
|
||||
return Collections.enumeration(set);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,98 @@
|
||||
package com.das.common.interceptor;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import jakarta.servlet.ReadListener;
|
||||
import jakarta.servlet.ServletInputStream;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletRequestWrapper;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.das.common.constant.HeaderConstant.TOKEN_ATTR_NAME;
|
||||
|
||||
// 解密post的requestbody请求
|
||||
public class DecryptingHttpServletRequestWrapper extends HttpServletRequestWrapper {
|
||||
private final String bodyData;
|
||||
private final String token;
|
||||
|
||||
public DecryptingHttpServletRequestWrapper(HttpServletRequest request, String bodyData, String token) {
|
||||
super(request);
|
||||
this.bodyData = bodyData;
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ServletInputStream getInputStream() {
|
||||
final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(bodyData.getBytes(StandardCharsets.UTF_8));
|
||||
return new ServletInputStream() {
|
||||
@Override
|
||||
public boolean isFinished() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReady() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReadListener(ReadListener listener) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read() {
|
||||
return byteArrayInputStream.read();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public BufferedReader getReader() {
|
||||
return new BufferedReader(new InputStreamReader(getInputStream()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHeader(String name) {
|
||||
if (TOKEN_ATTR_NAME.equals(name)) {
|
||||
return token;
|
||||
}
|
||||
return super.getHeader(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration<String> getHeaders(String name) {
|
||||
Set<String> set = new HashSet<>(8);
|
||||
if (TOKEN_ATTR_NAME.equals(name) && StrUtil.isNotBlank(token)) {
|
||||
set.add(token);
|
||||
}
|
||||
Enumeration<String> e = super.getHeaders(name);
|
||||
while (e.hasMoreElements()) {
|
||||
String n = e.nextElement();
|
||||
set.add(n);
|
||||
}
|
||||
return Collections.enumeration(set);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration<String> getHeaderNames() {
|
||||
Set<String> set = new HashSet<>(8);
|
||||
Enumeration<String> e = super.getHeaderNames();
|
||||
while (e.hasMoreElements()) {
|
||||
String n = e.nextElement();
|
||||
set.add(n);
|
||||
}
|
||||
if (StrUtil.isNotBlank(token)) {
|
||||
set.add(token);
|
||||
}
|
||||
return Collections.enumeration(set);
|
||||
}
|
||||
}
|
@ -5,24 +5,15 @@ import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.das.common.utils.AESUtil;
|
||||
import jakarta.servlet.FilterChain;
|
||||
import jakarta.servlet.ReadListener;
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.ServletInputStream;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletRequestWrapper;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.filter.OncePerRequestFilter;
|
||||
import org.springframework.web.multipart.support.StandardMultipartHttpServletRequest;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.das.common.constant.HeaderConstant.IV_ATTR_NAME;
|
||||
import static com.das.common.constant.HeaderConstant.TOKEN_ATTR_NAME;
|
||||
@ -31,6 +22,7 @@ import static org.springframework.http.HttpMethod.POST;
|
||||
public class DecryptingOncePerRequestFilter extends OncePerRequestFilter {
|
||||
|
||||
final private String aesKey;
|
||||
|
||||
public DecryptingOncePerRequestFilter(String aesKey) {
|
||||
this.aesKey = aesKey;
|
||||
}
|
||||
@ -44,11 +36,11 @@ public class DecryptingOncePerRequestFilter extends OncePerRequestFilter {
|
||||
String contentType = request.getContentType();
|
||||
|
||||
//当前只对Post的Application/json请求进行拦截处理
|
||||
if (POST.matches(method) && StrUtil.isNotBlank(contentType) && contentType.contains(MediaType.APPLICATION_JSON_VALUE)) {
|
||||
if (POST.matches(method) && StrUtil.isNotBlank(contentType) && contentType.contains(MediaType.APPLICATION_JSON_VALUE)) {
|
||||
String token = request.getHeader(TOKEN_ATTR_NAME);
|
||||
String iv = request.getHeader(IV_ATTR_NAME);
|
||||
//如果获取到token,则进行解密
|
||||
if (StrUtil.isNotBlank(token)){
|
||||
if (StrUtil.isNotBlank(token)) {
|
||||
token = AESUtil.decrypt(aesKey, token, iv);
|
||||
}
|
||||
//如果读取到requestBody,则进行解密
|
||||
@ -58,6 +50,22 @@ public class DecryptingOncePerRequestFilter extends OncePerRequestFilter {
|
||||
// 使用自定义的请求包装器替换原始请求
|
||||
filterChain.doFilter(new DecryptingHttpServletRequestWrapper(request, bodyData, token), response);
|
||||
}
|
||||
} else if (POST.matches(method) && StrUtil.isNotBlank(contentType) && contentType.contains(MediaType.MULTIPART_FORM_DATA_VALUE)) {
|
||||
// 上传文件过滤
|
||||
String token = request.getHeader(TOKEN_ATTR_NAME);
|
||||
String iv = request.getHeader(IV_ATTR_NAME);
|
||||
//如果获取到token,则进行解密
|
||||
if (StrUtil.isNotBlank(token)) {
|
||||
token = AESUtil.decrypt(aesKey, token, iv);
|
||||
}
|
||||
String id = request.getParameter("id");
|
||||
if (StrUtil.isNotBlank(id)) {
|
||||
StandardMultipartHttpServletRequest multiRequest = new StandardMultipartHttpServletRequest(request);
|
||||
id = AESUtil.decrypt(aesKey, id, iv);
|
||||
// 包装请求
|
||||
HttpServletRequest wrapper = new DecryptUploadWrapper(multiRequest, "id", id, token);
|
||||
filterChain.doFilter(wrapper, response);
|
||||
}
|
||||
} else {
|
||||
filterChain.doFilter(request, response);
|
||||
}
|
||||
@ -68,89 +76,6 @@ public class DecryptingOncePerRequestFilter extends OncePerRequestFilter {
|
||||
return IoUtil.read(request.getInputStream(), StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
|
||||
// 自定义的请求包装器
|
||||
static class DecryptingHttpServletRequestWrapper extends HttpServletRequestWrapper {
|
||||
private final String bodyData;
|
||||
private final String token;
|
||||
|
||||
public DecryptingHttpServletRequestWrapper(HttpServletRequest request, String bodyData, String token) {
|
||||
super(request);
|
||||
this.bodyData = bodyData;
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ServletInputStream getInputStream() {
|
||||
final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(bodyData.getBytes(StandardCharsets.UTF_8));
|
||||
return new ServletInputStream() {
|
||||
@Override
|
||||
public boolean isFinished() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReady() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReadListener(ReadListener listener) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read() {
|
||||
return byteArrayInputStream.read();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public BufferedReader getReader() {
|
||||
return new BufferedReader(new InputStreamReader(getInputStream()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHeader(String name) {
|
||||
if (TOKEN_ATTR_NAME.equals(name)){
|
||||
return token;
|
||||
}
|
||||
return super.getHeader(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration<String> getHeaders(String name) {
|
||||
Set<String> set = new HashSet<>(8);
|
||||
if (TOKEN_ATTR_NAME.equals(name) && StrUtil.isNotBlank(token)){
|
||||
set.add(token);
|
||||
}
|
||||
Enumeration<String> e = super.getHeaders(name);
|
||||
while (e.hasMoreElements()) {
|
||||
String n = e.nextElement();
|
||||
set.add(n);
|
||||
}
|
||||
return Collections.enumeration(set);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration<String> getHeaderNames() {
|
||||
Set<String> set = new HashSet<>(8);
|
||||
Enumeration<String> e = super.getHeaderNames();
|
||||
while (e.hasMoreElements()) {
|
||||
String n = e.nextElement();
|
||||
set.add(n);
|
||||
}
|
||||
if (StrUtil.isNotBlank(token)){
|
||||
set.add(token);
|
||||
}
|
||||
return Collections.enumeration(set);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.das.common.constant.BaseEntity;
|
||||
import com.das.modules.equipment.entity.SysEquipment;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.AllArgsConstructor;
|
||||
@ -13,6 +14,7 @@ import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
@ -100,4 +102,9 @@ public class SysOrg extends BaseEntity {
|
||||
@TableField("alias_name")
|
||||
private String aliasName;
|
||||
|
||||
/**
|
||||
* 子设备节点
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private List<SysEquipment> equipChildren;
|
||||
}
|
||||
|
@ -1,10 +1,23 @@
|
||||
package com.das.modules.equipment.controller;
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
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.dto.SysIotModelDto;
|
||||
import com.das.modules.equipment.domain.vo.EquipmentTypeVo;
|
||||
import com.das.modules.equipment.domain.vo.SysEquipmentVo;
|
||||
import com.das.modules.equipment.service.SysEquipmentService;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@ -19,6 +32,9 @@ import java.util.List;
|
||||
@RestController
|
||||
public class EquipmentController {
|
||||
|
||||
@Autowired
|
||||
private SysEquipmentService sysEquipmentService;
|
||||
|
||||
/**
|
||||
* 查询所有的设备类型
|
||||
* @return 所有的设备类型
|
||||
@ -31,4 +47,102 @@ public class EquipmentController {
|
||||
|
||||
return R.success(typeVoList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增设备类型
|
||||
* @return 所有的设备类型
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
public R<SysEquipmentVo> addSysEquipment(@RequestBody SysEquipmentDto sysEquipmentDto) {
|
||||
//判断是否有权限
|
||||
boolean hasPermission = StpUtil.hasPermission(SysAuthorityIds.SYS_AUTHORITY_ID_DEVICE_MGR.toString());
|
||||
if(!hasPermission){
|
||||
return R.fail("没有设备管理权限");
|
||||
}
|
||||
|
||||
if (sysEquipmentDto.getOrgId() == null) {
|
||||
throw new ServiceException("参数缺失");
|
||||
}
|
||||
return R.success(sysEquipmentService.creatSysEquipment(sysEquipmentDto));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改设备类型
|
||||
* @return 所有的设备类型
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
public R<SysEquipmentVo> updateSysEquipment(@RequestBody SysEquipmentDto sysEquipmentDto) {
|
||||
//判断是否有权限
|
||||
boolean hasPermission = StpUtil.hasPermission(SysAuthorityIds.SYS_AUTHORITY_ID_DEVICE_MGR.toString());
|
||||
if(!hasPermission){
|
||||
return R.fail("没有设备管理权限");
|
||||
}
|
||||
|
||||
if (sysEquipmentDto.getOrgId() == null) {
|
||||
throw new ServiceException("参数缺失");
|
||||
}
|
||||
return R.success(sysEquipmentService.updateSysEquipment(sysEquipmentDto));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除设备类型
|
||||
* @return 所有的设备类型
|
||||
*/
|
||||
@PostMapping("/delete")
|
||||
public R<Void> deleteSysEquipment(@RequestBody SysEquipmentDto sysEquipmentDto) {
|
||||
//判断是否有权限
|
||||
boolean hasPermission = StpUtil.hasPermission(SysAuthorityIds.SYS_AUTHORITY_ID_DEVICE_MGR.toString());
|
||||
if(!hasPermission){
|
||||
return R.fail("没有设备管理权限");
|
||||
}
|
||||
|
||||
if (sysEquipmentDto.getId() == null) {
|
||||
throw new ServiceException("参数缺失");
|
||||
}
|
||||
sysEquipmentService.deleteSysEquipment(sysEquipmentDto);
|
||||
return R.success();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询设备类型列表
|
||||
* @return 所有的设备类型
|
||||
*/
|
||||
@PostMapping("/query")
|
||||
public PageDataInfo<SysEquipmentVo> querySysEquipmentList(@RequestBody SysEquipmentDto sysEquipmentDto) {
|
||||
return sysEquipmentService.querySysEquipmentList(sysEquipmentDto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询设备类型列表
|
||||
* @return 所有的设备类型
|
||||
*/
|
||||
@PostMapping("/list")
|
||||
public R<List<SysEquipmentVo>> queryAllSysEquipmentList(@RequestBody SysEquipmentDto sysEquipmentDto) {
|
||||
return R.success(sysEquipmentService.queryAllSysEquipmentList(sysEquipmentDto));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询设备树
|
||||
* @return 所有的设备类型
|
||||
*/
|
||||
@PostMapping("/getEquipmentTree")
|
||||
public R<List<SysOrg>> getRootOrg(@RequestBody SysEquipmentDto sysEquipmentDto) {
|
||||
if (sysEquipmentDto.getOrgId() == null) {
|
||||
throw new ServiceException("参数缺失");
|
||||
}
|
||||
return R.success(sysEquipmentService.getRootOrg(sysEquipmentDto));
|
||||
}
|
||||
|
||||
|
||||
/** 设备导出 */
|
||||
@PostMapping("/export")
|
||||
public void exportSysEquipment(@RequestBody SysEquipmentDto sysEquipmentDto, HttpServletRequest request, HttpServletResponse response) {
|
||||
|
||||
if (sysEquipmentDto.getParentEquipmentId() == null) {
|
||||
throw new ServiceException("请选择需要下载的设备类型信息");
|
||||
}
|
||||
sysEquipmentService.exportSysEquipment(sysEquipmentDto,request, response);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,26 +1,34 @@
|
||||
package com.das.modules.equipment.controller;
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.alibaba.excel.ExcelReader;
|
||||
import com.alibaba.excel.read.builder.ExcelReaderSheetBuilder;
|
||||
import com.alibaba.excel.read.metadata.ReadSheet;
|
||||
import com.das.common.constant.SysAuthorityIds;
|
||||
import com.das.common.exceptions.ServiceException;
|
||||
import com.das.common.result.R;
|
||||
import com.das.common.utils.ExcelUtil;
|
||||
import com.das.common.utils.PageDataInfo;
|
||||
import com.das.common.utils.StringUtils;
|
||||
import com.das.modules.equipment.domain.dto.SysIotModelDto;
|
||||
import com.das.modules.equipment.domain.dto.SysIotModelFieldDto;
|
||||
import com.das.modules.equipment.domain.dto.SysIotModelServiceDto;
|
||||
import com.das.modules.equipment.domain.vo.SysIotModelFieldVo;
|
||||
import com.das.modules.equipment.domain.vo.SysIotModelServiceVo;
|
||||
import com.das.modules.equipment.domain.vo.SysIotModelVo;
|
||||
import com.das.modules.equipment.entity.SysIotModel;
|
||||
import com.das.modules.equipment.listener.ExcelListener;
|
||||
import com.das.modules.equipment.service.SysIotModelService;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -93,9 +101,9 @@ public class SysIotModelController {
|
||||
|
||||
/** 获取物模型属性列表 */
|
||||
@PostMapping("/attribute/list")
|
||||
public R<List<SysIotModelFieldVo>> querySysIotModelField(@RequestBody SysIotModelFieldDto sysIotModelFieldDto) {
|
||||
public PageDataInfo<SysIotModelFieldVo> querySysIotModelField(@RequestBody SysIotModelFieldDto sysIotModelFieldDto) {
|
||||
|
||||
return R.success(sysIotModelService.querySysIotModelField(sysIotModelFieldDto));
|
||||
return sysIotModelService.querySysIotModelField(sysIotModelFieldDto);
|
||||
}
|
||||
|
||||
|
||||
@ -154,9 +162,9 @@ public class SysIotModelController {
|
||||
|
||||
/** 获取物模型动作列表 */
|
||||
@PostMapping("/service/list")
|
||||
public R<List<SysIotModelServiceVo>> querySysIotModelField(@RequestBody SysIotModelServiceDto sysIotModelServiceDto) {
|
||||
public PageDataInfo<SysIotModelServiceVo> querySysIotModelField(@RequestBody SysIotModelServiceDto sysIotModelServiceDto) {
|
||||
|
||||
return R.success(sysIotModelService.querySysIotModelService(sysIotModelServiceDto));
|
||||
return sysIotModelService.querySysIotModelService(sysIotModelServiceDto);
|
||||
}
|
||||
|
||||
|
||||
@ -224,5 +232,19 @@ public class SysIotModelController {
|
||||
sysIotModelService.exportSysIotModel(sysIotModelDto,request, response);
|
||||
|
||||
}
|
||||
|
||||
/** 物模型导入 */
|
||||
@PostMapping("/import")
|
||||
public R<Void> importSysIotModel(String id, @RequestParam("file") MultipartFile file) throws IOException {
|
||||
|
||||
if (StringUtils.isEmpty(id)) {
|
||||
throw new ServiceException("请选择需要导入的物模型属性信息");
|
||||
}
|
||||
sysIotModelService.importSysIotModel(id, file);
|
||||
return R.success();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,98 @@
|
||||
package com.das.modules.equipment.domain.dto;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class SysEquipmentDto {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 模型ID
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 设备类型编码
|
||||
*/
|
||||
private Integer objectType;
|
||||
|
||||
/**
|
||||
* 设备编码
|
||||
*/
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 设备名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 制造商
|
||||
*/
|
||||
private String madeinFactory;
|
||||
|
||||
/**
|
||||
* 型号规格
|
||||
*/
|
||||
private String model;
|
||||
|
||||
/**
|
||||
* 安装位置
|
||||
*/
|
||||
private String location;
|
||||
|
||||
/**
|
||||
* 安装位置_经度
|
||||
*/
|
||||
private float longitude;
|
||||
|
||||
/**
|
||||
* 安装位置_纬度
|
||||
*/
|
||||
private float latitude;
|
||||
|
||||
/**
|
||||
* 安装日期
|
||||
*/
|
||||
private Date installDate;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remarks;
|
||||
|
||||
/**
|
||||
* 机构id
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long orgId;
|
||||
|
||||
/**
|
||||
* 上级设备id
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long parentEquipmentId;
|
||||
|
||||
/**
|
||||
* 对应物模型id
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long iotModelId;
|
||||
|
||||
/**
|
||||
* 分页大小
|
||||
*/
|
||||
private Integer pageSize;
|
||||
|
||||
/**
|
||||
* 当前页数
|
||||
*/
|
||||
private Integer pageNum;
|
||||
}
|
@ -33,4 +33,15 @@ public class SysIotModelFieldDto implements Serializable {
|
||||
private Integer porder;
|
||||
|
||||
private Integer revision;
|
||||
|
||||
/**
|
||||
* 分页大小
|
||||
*/
|
||||
private Integer pageSize;
|
||||
|
||||
/**
|
||||
* 当前页数
|
||||
*/
|
||||
private Integer pageNum;
|
||||
|
||||
}
|
||||
|
@ -36,4 +36,14 @@ public class SysIotModelServiceDto implements Serializable {
|
||||
private Integer porder;
|
||||
|
||||
private Integer revision;
|
||||
|
||||
/**
|
||||
* 分页大小
|
||||
*/
|
||||
private Integer pageSize;
|
||||
|
||||
/**
|
||||
* 当前页数
|
||||
*/
|
||||
private Integer pageNum;
|
||||
}
|
||||
|
@ -0,0 +1,91 @@
|
||||
package com.das.modules.equipment.domain.excel;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class SysEquipmentExcel {
|
||||
|
||||
/**
|
||||
* 设备类型编码
|
||||
*/
|
||||
@ExcelProperty(value = "设备类型编码",index = 0)
|
||||
private Integer objectType;
|
||||
|
||||
/**
|
||||
* 所属物模型ID
|
||||
*/
|
||||
@ExcelProperty(value = "所属物模型名称",index = 1)
|
||||
private String iotModelName;
|
||||
|
||||
/**
|
||||
* 设备编码
|
||||
*/
|
||||
@ExcelProperty(value = "设备编码",index = 2)
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 设备名称
|
||||
*/
|
||||
@ExcelProperty(value = "设备名称",index = 3)
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 制造商
|
||||
*/
|
||||
@ExcelProperty(value = "制造商",index = 4)
|
||||
private String madeinFactory;
|
||||
|
||||
/**
|
||||
* 型号规格
|
||||
*/
|
||||
@ExcelProperty(value = "型号规格",index = 5)
|
||||
private String model;
|
||||
|
||||
/**
|
||||
* 安装位置
|
||||
*/
|
||||
@ExcelProperty(value = "安装位置",index = 6)
|
||||
private String location;
|
||||
|
||||
/**
|
||||
* 安装位置_经度
|
||||
*/
|
||||
@ExcelProperty(value = "安装位置_经度",index = 7)
|
||||
private float longitude;
|
||||
|
||||
/**
|
||||
* 安装位置_纬度
|
||||
*/
|
||||
@ExcelProperty(value = "安装位置_纬度",index = 8)
|
||||
private float latitude;
|
||||
|
||||
/**
|
||||
* 安装日期
|
||||
*/
|
||||
@ExcelProperty(value = "安装日期",index = 9)
|
||||
private Date installDate;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@ExcelProperty(value = "备注",index = 10)
|
||||
private String remarks;
|
||||
|
||||
/**
|
||||
* 机构id
|
||||
*/
|
||||
@ExcelProperty(value = "机构名称",index = 11)
|
||||
private String orgName;
|
||||
|
||||
/**
|
||||
* 上级设备id
|
||||
*/
|
||||
@ExcelProperty(value = "上级设备名称",index = 12)
|
||||
private String parentEquipmentName;
|
||||
|
||||
}
|
@ -0,0 +1,96 @@
|
||||
package com.das.modules.equipment.domain.vo;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 设备类型前端回显
|
||||
* </p>
|
||||
*
|
||||
* @author chenhaojie
|
||||
*/
|
||||
@Data
|
||||
public class SysEquipmentVo{
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 模型ID
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 设备类型编码
|
||||
*/
|
||||
private Integer objectType;
|
||||
|
||||
/**
|
||||
* 设备编码
|
||||
*/
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 设备名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 制造商
|
||||
*/
|
||||
private String madeinFactory;
|
||||
|
||||
/**
|
||||
* 型号规格
|
||||
*/
|
||||
private String model;
|
||||
|
||||
/**
|
||||
* 安装位置
|
||||
*/
|
||||
private String location;
|
||||
|
||||
/**
|
||||
* 安装位置_经度
|
||||
*/
|
||||
private float longitude;
|
||||
|
||||
/**
|
||||
* 安装位置_纬度
|
||||
*/
|
||||
private float latitude;
|
||||
|
||||
/**
|
||||
* 安装日期
|
||||
*/
|
||||
private Date installDate;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remarks;
|
||||
|
||||
/**
|
||||
* 机构id
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long orgId;
|
||||
|
||||
/**
|
||||
* 上级设备id
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long parentEquipmentId;
|
||||
|
||||
/**
|
||||
* 对应物模型id
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long iotModelId;
|
||||
}
|
@ -0,0 +1,122 @@
|
||||
package com.das.modules.equipment.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.das.common.constant.BaseEntity;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 设备类型
|
||||
* </p>
|
||||
*
|
||||
* @author chenhaojie
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("sys_equipment")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SysEquipment extends BaseEntity {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 模型ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.ASSIGN_ID)
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 设备类型编码
|
||||
*/
|
||||
@TableField("object_type")
|
||||
private Integer objectType;
|
||||
|
||||
/**
|
||||
* 设备编码
|
||||
*/
|
||||
@TableField("code")
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 设备名称
|
||||
*/
|
||||
@TableField("name")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 制造商
|
||||
*/
|
||||
@TableField("madein_factory")
|
||||
private String madeinFactory;
|
||||
|
||||
/**
|
||||
* 型号规格
|
||||
*/
|
||||
@TableField("model")
|
||||
private String model;
|
||||
|
||||
/**
|
||||
* 安装位置
|
||||
*/
|
||||
@TableField("location")
|
||||
private String location;
|
||||
|
||||
/**
|
||||
* 安装位置_经度
|
||||
*/
|
||||
@TableField("longitude")
|
||||
private float longitude;
|
||||
|
||||
/**
|
||||
* 安装位置_纬度
|
||||
*/
|
||||
@TableField("latitude")
|
||||
private float latitude;
|
||||
|
||||
/**
|
||||
* 安装日期
|
||||
*/
|
||||
@TableField("install_date")
|
||||
private Date installDate;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@TableField("remarks")
|
||||
private String remarks;
|
||||
|
||||
/**
|
||||
* 机构id
|
||||
*/
|
||||
@TableField(value = "org_id")
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long orgId;
|
||||
|
||||
/**
|
||||
* 上级设备id
|
||||
*/
|
||||
@TableField(value = "parent_equipment_id")
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long parentEquipmentId;
|
||||
|
||||
/**
|
||||
* 对应物模型id
|
||||
*/
|
||||
@TableField(value = "iot_model_id")
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long iotModelId;
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package com.das.modules.equipment.listener;
|
||||
|
||||
import com.alibaba.excel.context.AnalysisContext;
|
||||
import com.alibaba.excel.event.AnalysisEventListener;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ExcelListener extends AnalysisEventListener{
|
||||
//可以通过实例获取该值
|
||||
private List<Object> datas = new ArrayList<Object>();
|
||||
|
||||
public void invoke(Object o, AnalysisContext analysisContext) {
|
||||
datas.add(o);
|
||||
doSomething(o);
|
||||
}
|
||||
|
||||
private void doSomething(Object object) {
|
||||
}
|
||||
|
||||
public List<Object> getDatas() {
|
||||
return datas;
|
||||
}
|
||||
|
||||
public void setDatas(List<Object> datas) {
|
||||
this.datas = datas;
|
||||
}
|
||||
|
||||
public void doAfterAllAnalysed(AnalysisContext analysisContext) {
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
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.SysIotModelDto;
|
||||
import com.das.modules.equipment.domain.dto.SysIotModelFieldDto;
|
||||
import com.das.modules.equipment.domain.excel.SysEquipmentExcel;
|
||||
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;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface SysEquipmentMapper extends BaseMapper<SysEquipment> {
|
||||
|
||||
IPage<SysEquipmentVo> querySysEquipmentList(IPage<SysEquipmentVo> page, @Param("info") SysEquipmentDto sysEquipmentDto);
|
||||
|
||||
List<SysEquipment> queryEquipmentTree(@Param("info")SysEquipmentDto sysEquipmentDto);
|
||||
|
||||
List<SysEquipmentExcel> queryInfoById (@Param("info") SysEquipmentDto sysEquipmentDto);
|
||||
}
|
@ -2,10 +2,16 @@ package com.das.modules.equipment.mapper;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.das.modules.auth.mapper.BaseMapperPlus;
|
||||
import com.das.modules.equipment.domain.dto.SysIotModelFieldDto;
|
||||
import com.das.modules.equipment.domain.vo.SysIotModelFieldVo;
|
||||
import com.das.modules.equipment.entity.SysIotModelField;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
@Mapper
|
||||
public interface SysIotModelFieldMapper extends BaseMapper<SysIotModelField> {
|
||||
public interface SysIotModelFieldMapper extends BaseMapperPlus<SysIotModelField, SysIotModelField> {
|
||||
|
||||
IPage<SysIotModelFieldVo> querySysIotModelFieldList(IPage<SysIotModelFieldVo> page, @Param("info") SysIotModelFieldDto sysIotModelFieldDto);
|
||||
}
|
||||
|
@ -2,10 +2,16 @@ package com.das.modules.equipment.mapper;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.das.modules.auth.mapper.BaseMapperPlus;
|
||||
import com.das.modules.equipment.domain.dto.SysIotModelServiceDto;
|
||||
import com.das.modules.equipment.domain.vo.SysIotModelServiceVo;
|
||||
import com.das.modules.equipment.entity.SysIotModelServices;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
@Mapper
|
||||
public interface SysIotModelServiceMapper extends BaseMapper<SysIotModelServices> {
|
||||
public interface SysIotModelServiceMapper extends BaseMapperPlus<SysIotModelServices, SysIotModelServices> {
|
||||
|
||||
IPage<SysIotModelServiceVo> querySysIotModelServiceList(IPage<SysIotModelServiceVo> page, @Param("info") SysIotModelServiceDto sysIotModelServiceDto);
|
||||
}
|
||||
|
@ -0,0 +1,33 @@
|
||||
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;
|
||||
import com.das.modules.equipment.domain.dto.SysIotModelServiceDto;
|
||||
import com.das.modules.equipment.domain.vo.SysEquipmentVo;
|
||||
import com.das.modules.equipment.domain.vo.SysIotModelFieldVo;
|
||||
import com.das.modules.equipment.domain.vo.SysIotModelServiceVo;
|
||||
import com.das.modules.equipment.domain.vo.SysIotModelVo;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface SysEquipmentService {
|
||||
SysEquipmentVo creatSysEquipment(SysEquipmentDto sysEquipmentDto);
|
||||
|
||||
SysEquipmentVo updateSysEquipment(SysEquipmentDto sysEquipmentDto);
|
||||
|
||||
void deleteSysEquipment(SysEquipmentDto sysEquipmentDto);
|
||||
|
||||
PageDataInfo<SysEquipmentVo> querySysEquipmentList(SysEquipmentDto sysEquipmentDto);
|
||||
|
||||
List<SysEquipmentVo> queryAllSysEquipmentList(SysEquipmentDto sysEquipmentDto);
|
||||
|
||||
List<SysOrg> getRootOrg(SysEquipmentDto sysEquipmentDto);
|
||||
|
||||
void exportSysEquipment(SysEquipmentDto sysEquipmentDto, HttpServletRequest request, HttpServletResponse response);
|
||||
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package com.das.modules.equipment.service;
|
||||
|
||||
import com.das.common.utils.PageDataInfo;
|
||||
import com.das.modules.equipment.domain.dto.SysIotModelDto;
|
||||
import com.das.modules.equipment.domain.dto.SysIotModelFieldDto;
|
||||
import com.das.modules.equipment.domain.dto.SysIotModelServiceDto;
|
||||
@ -8,7 +9,9 @@ import com.das.modules.equipment.domain.vo.SysIotModelServiceVo;
|
||||
import com.das.modules.equipment.domain.vo.SysIotModelVo;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
public interface SysIotModelService {
|
||||
@ -20,7 +23,7 @@ public interface SysIotModelService {
|
||||
|
||||
List<SysIotModelVo> querySysIotModel(SysIotModelDto sysIotModelDto);
|
||||
|
||||
List<SysIotModelFieldVo> querySysIotModelField(SysIotModelFieldDto sysIotModelFieldDto);
|
||||
PageDataInfo<SysIotModelFieldVo> querySysIotModelField(SysIotModelFieldDto sysIotModelFieldDto);
|
||||
|
||||
SysIotModelFieldVo creatSysIotModelField(SysIotModelFieldDto sysIotModelFieldDto);
|
||||
|
||||
@ -28,7 +31,7 @@ public interface SysIotModelService {
|
||||
|
||||
void deleteSysIotModelField(SysIotModelFieldDto sysIotModelFieldDto);
|
||||
|
||||
List<SysIotModelServiceVo> querySysIotModelService(SysIotModelServiceDto sysIotModelServiceDto);
|
||||
PageDataInfo<SysIotModelServiceVo> querySysIotModelService(SysIotModelServiceDto sysIotModelServiceDto);
|
||||
|
||||
SysIotModelServiceVo creatSysIotModelService(SysIotModelServiceDto sysIotModelServiceDto);
|
||||
|
||||
@ -38,4 +41,6 @@ public interface SysIotModelService {
|
||||
|
||||
void exportSysIotModel(SysIotModelDto sysIotModelDto, HttpServletRequest request, HttpServletResponse response);
|
||||
|
||||
void importSysIotModel(String iotModelId, MultipartFile file) throws IOException;
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,134 @@
|
||||
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.ExcelUtil;
|
||||
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.auth.mapper.SysOrgMapper;
|
||||
import com.das.modules.equipment.domain.dto.SysEquipmentDto;
|
||||
import com.das.modules.equipment.domain.dto.SysIotModelDto;
|
||||
import com.das.modules.equipment.domain.excel.SheetInfoBean;
|
||||
import com.das.modules.equipment.domain.excel.SysEquipmentExcel;
|
||||
import com.das.modules.equipment.domain.excel.SysIotModelFieldExcel;
|
||||
import com.das.modules.equipment.domain.excel.SysIotModelServiceExcel;
|
||||
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;
|
||||
import com.das.modules.equipment.mapper.SysEquipmentMapper;
|
||||
import com.das.modules.equipment.mapper.SysIotModelMapper;
|
||||
import com.das.modules.equipment.service.SysEquipmentService;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Service
|
||||
public class SysEquipmentServiceImpl implements SysEquipmentService {
|
||||
|
||||
@Autowired
|
||||
private SysEquipmentMapper sysEquipmentMapper;
|
||||
|
||||
@Autowired
|
||||
private SysOrgMapper sysOrgMapper;
|
||||
@Override
|
||||
public SysEquipmentVo creatSysEquipment(SysEquipmentDto sysEquipmentDto) {
|
||||
SysEquipment sysEquipment = new SysEquipment();
|
||||
BeanCopyUtils.copy(sysEquipmentDto,sysEquipment);
|
||||
|
||||
// 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("测试");
|
||||
sysEquipment.setUpdatedBy("测试");
|
||||
sysEquipment.setRevision(1);
|
||||
sysEquipmentMapper.insert(sysEquipment);
|
||||
SysEquipmentVo sysEquipmentVo = new SysEquipmentVo();
|
||||
BeanCopyUtils.copy(sysEquipment,sysEquipmentVo);
|
||||
return sysEquipmentVo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysEquipmentVo updateSysEquipment(SysEquipmentDto sysEquipmentDto) {
|
||||
SysEquipment sysEquipment = new SysEquipment();
|
||||
BeanCopyUtils.copy(sysEquipmentDto,sysEquipment);
|
||||
// SysUserVo sysUserVo = (SysUserVo) StpUtil.getTokenSession().get(SessionUtil.SESSION_USER_KEY);
|
||||
sysEquipment.setUpdatedTime(new Date());
|
||||
sysEquipment.setUpdatedBy("测试");
|
||||
// sysIotModel.setUpdatedBy("sysUserVo.getAccount()");
|
||||
sysEquipmentMapper.updateById(sysEquipment);
|
||||
SysEquipmentVo sysEquipmentVo = new SysEquipmentVo();
|
||||
BeanCopyUtils.copy(sysEquipment,sysEquipmentVo);
|
||||
return sysEquipmentVo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteSysEquipment(SysEquipmentDto sysEquipmentDto) {
|
||||
sysEquipmentMapper.deleteById(sysEquipmentDto.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
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<SysEquipmentVo> queryAllSysEquipmentList(SysEquipmentDto sysEquipmentDto) {
|
||||
// 查询当前账号机构下的子机构和子设备
|
||||
QueryWrapper<SysEquipment> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("org_id", sysEquipmentDto.getOrgId());
|
||||
queryWrapper.eq("parent_equipment_id", sysEquipmentDto.getParentEquipmentId());
|
||||
queryWrapper.eq("object_type", sysEquipmentDto.getObjectType());
|
||||
List<SysEquipment> sysEquipmentList = sysEquipmentMapper.selectList(queryWrapper);
|
||||
List<SysEquipmentVo> list = new ArrayList<>();
|
||||
list.addAll(BeanCopyUtils.copyList(sysEquipmentList, SysEquipmentVo.class));
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysOrg> getRootOrg(SysEquipmentDto sysEquipmentDto) {
|
||||
// 查询当前账号机构下的子机构和子设备
|
||||
QueryWrapper<SysOrg> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("id", sysEquipmentDto.getOrgId());
|
||||
List<SysOrg> sysOrgList = sysOrgMapper.selectList(queryWrapper);
|
||||
if (sysOrgList.size() == 0) {
|
||||
throw new ServiceException("机构不存在");
|
||||
}
|
||||
for (SysOrg sysOrg : sysOrgList) {
|
||||
sysOrg.setEquipChildren(sysEquipmentMapper.queryEquipmentTree(sysEquipmentDto));
|
||||
}
|
||||
|
||||
return sysOrgList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exportSysEquipment(SysEquipmentDto sysEquipmentDto, HttpServletRequest request, HttpServletResponse response) {
|
||||
// 查询物模型属性和动作
|
||||
List<SysEquipmentExcel> sysEquipmentList = sysEquipmentMapper.queryInfoById(sysEquipmentDto);
|
||||
String fileName = "设备类型信息表";
|
||||
List<SheetInfoBean> sheetInfoBeanList = new ArrayList<>();
|
||||
SheetInfoBean sheetInfoBean = new SheetInfoBean("设备类型信息", SysEquipmentExcel.class, sysEquipmentList);
|
||||
sheetInfoBeanList.add(sheetInfoBean);
|
||||
ExcelUtil.exportMoreSheet(fileName,request,response,sheetInfoBeanList);
|
||||
}
|
||||
}
|
@ -1,12 +1,17 @@
|
||||
package com.das.modules.equipment.service.impl;
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.alibaba.excel.ExcelReader;
|
||||
import com.alibaba.excel.read.metadata.ReadSheet;
|
||||
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.ExcelUtil;
|
||||
import com.das.common.utils.*;
|
||||
import com.das.modules.auth.domain.vo.SysUserVo;
|
||||
import com.das.modules.auth.entity.SysOrg;
|
||||
import com.das.modules.equipment.domain.excel.SheetInfoBean;
|
||||
import com.das.modules.equipment.domain.dto.SysIotModelDto;
|
||||
import com.das.modules.equipment.domain.dto.SysIotModelFieldDto;
|
||||
@ -19,6 +24,7 @@ import com.das.modules.equipment.domain.vo.SysIotModelVo;
|
||||
import com.das.modules.equipment.entity.SysIotModel;
|
||||
import com.das.modules.equipment.entity.SysIotModelField;
|
||||
import com.das.modules.equipment.entity.SysIotModelServices;
|
||||
import com.das.modules.equipment.listener.ExcelListener;
|
||||
import com.das.modules.equipment.mapper.SysIotModelFieldMapper;
|
||||
import com.das.modules.equipment.mapper.SysIotModelMapper;
|
||||
import com.das.modules.equipment.mapper.SysIotModelServiceMapper;
|
||||
@ -28,7 +34,10 @@ import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@ -111,17 +120,12 @@ public class SysIotModelServiceImpl implements SysIotModelService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysIotModelFieldVo> querySysIotModelField(SysIotModelFieldDto sysIotModelFieldDto) {
|
||||
List<SysIotModelFieldVo> sysIotModelFieldVoList = new ArrayList<>();
|
||||
QueryWrapper<SysIotModelField> sysIotModelFieldQueryWrapper = new QueryWrapper<>();
|
||||
sysIotModelFieldQueryWrapper.eq("iot_model_id",sysIotModelFieldDto.getIotModelId());
|
||||
List<SysIotModelField> sysIotModelFields = sysIotModelFieldMapper.selectList(sysIotModelFieldQueryWrapper);
|
||||
for (SysIotModelField item : sysIotModelFields){
|
||||
SysIotModelFieldVo sysIotModelVo = new SysIotModelFieldVo();
|
||||
BeanCopyUtils.copy(item,sysIotModelVo);
|
||||
sysIotModelFieldVoList.add(sysIotModelVo);
|
||||
}
|
||||
return sysIotModelFieldVoList;
|
||||
public PageDataInfo<SysIotModelFieldVo> querySysIotModelField(SysIotModelFieldDto sysIotModelFieldDto) {
|
||||
PageQuery pageQuery = new PageQuery();
|
||||
pageQuery.setPageNum(sysIotModelFieldDto.getPageNum());
|
||||
pageQuery.setPageSize(sysIotModelFieldDto.getPageSize());
|
||||
IPage<SysIotModelFieldVo> iPage = sysIotModelFieldMapper.querySysIotModelFieldList(pageQuery.build(), sysIotModelFieldDto);
|
||||
return PageDataInfo.build(iPage.getRecords(), iPage.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -168,17 +172,12 @@ public class SysIotModelServiceImpl implements SysIotModelService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysIotModelServiceVo> querySysIotModelService(SysIotModelServiceDto sysIotModelServiceDto) {
|
||||
List<SysIotModelServiceVo> sysIotModelServiceVoList = new ArrayList<>();
|
||||
QueryWrapper<SysIotModelServices> sysIotModelServicesQueryWrapper = new QueryWrapper<>();
|
||||
sysIotModelServicesQueryWrapper.eq("iot_model_id",sysIotModelServiceDto.getIotModelId());
|
||||
List<SysIotModelServices> sysIotModelServices = sysIotModelServiceMapper.selectList(sysIotModelServicesQueryWrapper);
|
||||
for (SysIotModelServices item : sysIotModelServices){
|
||||
SysIotModelServiceVo sysIotServiceVo = new SysIotModelServiceVo();
|
||||
BeanCopyUtils.copy(item,sysIotServiceVo);
|
||||
sysIotModelServiceVoList.add(sysIotServiceVo);
|
||||
}
|
||||
return sysIotModelServiceVoList;
|
||||
public PageDataInfo<SysIotModelServiceVo> querySysIotModelService(SysIotModelServiceDto sysIotModelServiceDto) {
|
||||
PageQuery pageQuery = new PageQuery();
|
||||
pageQuery.setPageNum(sysIotModelServiceDto.getPageNum());
|
||||
pageQuery.setPageSize(sysIotModelServiceDto.getPageSize());
|
||||
IPage<SysIotModelServiceVo> iPage = sysIotModelServiceMapper.querySysIotModelServiceList(pageQuery.build(), sysIotModelServiceDto);
|
||||
return PageDataInfo.build(iPage.getRecords(), iPage.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -240,4 +239,69 @@ public class SysIotModelServiceImpl implements SysIotModelService {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void importSysIotModel(String iotModelId, MultipartFile file) throws IOException {
|
||||
//输入流
|
||||
InputStream inputStream = file.getInputStream();
|
||||
//监视器
|
||||
ExcelListener listener = new ExcelListener();
|
||||
ExcelReader excelReader = EasyExcel.read(inputStream, listener).build();
|
||||
// 第一个sheet读取物模型属性
|
||||
ReadSheet readSheet1 = EasyExcel.readSheet(0).head(SysIotModelFieldExcel.class).build();
|
||||
// 第二个sheet读取物模型动作
|
||||
ReadSheet readSheet2 = EasyExcel.readSheet(1).head(SysIotModelServiceExcel.class).build();
|
||||
// 开始读取第一个sheet
|
||||
excelReader.read(readSheet1);
|
||||
//excel sheet0 信息
|
||||
List<Object> fieldList = listener.getDatas();
|
||||
//List<object> 转 List<实体类>
|
||||
List<SysIotModelField> sysIotModelFieldList = new ArrayList<>();
|
||||
//List object for 转换 实体类
|
||||
for (Object objects : fieldList) {
|
||||
SysIotModelFieldExcel dto = (SysIotModelFieldExcel) objects;
|
||||
SysIotModelField field = new SysIotModelField();
|
||||
BeanUtil.copyProperties(dto,field);
|
||||
field.setIotModelId(Long.valueOf(iotModelId));
|
||||
field.setId(SequenceUtils.generateId());
|
||||
field.setCreatedTime(new Date());
|
||||
field.setUpdatedTime(new Date());
|
||||
field.setRevision(1);
|
||||
// field.setCreatedBy(StpUtil.getLoginIdAsString());
|
||||
// field.setUpdatedBy(StpUtil.getLoginIdAsString());
|
||||
field.setCreatedBy("测试人员");
|
||||
field.setUpdatedBy("测试人员");
|
||||
sysIotModelFieldList.add(field);
|
||||
}
|
||||
//保存第一个sheet页中的数据
|
||||
sysIotModelFieldMapper.insertBatch(sysIotModelFieldList);
|
||||
// 清空之前的数据
|
||||
listener.getDatas().clear();
|
||||
// 开始读取第二个sheet
|
||||
excelReader.read(readSheet2);
|
||||
//excel sheet1 信息
|
||||
List<Object> serviceList = listener.getDatas();
|
||||
|
||||
//List<object> 转 List<实体类>
|
||||
List<SysIotModelServices> sysIotModelServiceList = new ArrayList<>();
|
||||
//List object for 转换 实体类
|
||||
for (Object objects : serviceList) {
|
||||
SysIotModelServiceExcel dto = (SysIotModelServiceExcel) objects;
|
||||
SysIotModelServices services = new SysIotModelServices();
|
||||
BeanUtil.copyProperties(dto,services);
|
||||
services.setIotModelId(Long.valueOf(iotModelId));
|
||||
services.setId(SequenceUtils.generateId());
|
||||
services.setCreatedTime(new Date());
|
||||
services.setUpdatedTime(new Date());
|
||||
services.setRevision(1);
|
||||
// services.setCreatedBy(StpUtil.getLoginIdAsString());
|
||||
// services.setUpdatedBy(StpUtil.getLoginIdAsString());
|
||||
services.setCreatedBy("测试人员");
|
||||
services.setUpdatedBy("测试人员");
|
||||
sysIotModelServiceList.add(services);
|
||||
}
|
||||
//保存第一个sheet页中的数据
|
||||
sysIotModelServiceMapper.insertBatch(sysIotModelServiceList);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
84
das/src/main/resources/mapper/SysEquipmentMapper.xml
Normal file
84
das/src/main/resources/mapper/SysEquipmentMapper.xml
Normal file
@ -0,0 +1,84 @@
|
||||
<?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>
|
||||
|
||||
<resultMap type="com.das.modules.equipment.domain.excel.SysEquipmentExcel" id="SysEquipmentExcelMap">
|
||||
|
||||
<result property="orgName" column="org_name" jdbcType="VARCHAR"/>
|
||||
<result property="parentEquipmentName" column="parent_equipment_name" jdbcType="VARCHAR"/>
|
||||
<result property="objectType" column="object_type" jdbcType="INTEGER"/>
|
||||
<result property="iotModelName" column="iot_model_name" jdbcType="VARCHAR"/>
|
||||
<result property="code" column="code" jdbcType="VARCHAR"/>
|
||||
<result property="name" column="name" jdbcType="VARCHAR"/>
|
||||
<result property="model" column="model" jdbcType="VARCHAR"/>
|
||||
<result property="location" column="location" jdbcType="VARCHAR"/>
|
||||
<result property="madeinFactory" column="madein_factory" jdbcType="VARCHAR"/>
|
||||
<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"/>
|
||||
</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>
|
||||
<if test="info.name != null and info.name != ''">
|
||||
and t.name like concat('%',#{info.name},'%')
|
||||
</if>
|
||||
<if test="info.code != null and info.code != ''">
|
||||
and t.code like concat('%',#{info.code},'%')
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
||||
<select id="queryEquipmentTree" resultMap="SysEquipmentMap">
|
||||
select t.* from sys_equipment t WHERE t.org_id = #{info.id} and t.object_type in (10001,10002)
|
||||
<if test="info.parentEquipmentId != null and info.parentEquipmentId != ''">
|
||||
and t.parent_equipment_id = #{info.parentEquipmentId}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="queryInfoById" resultMap="SysEquipmentExcelMap">
|
||||
select t.*,se."name" as parentEquipmentName,sim.iot_model_name as iotModelName, so."name" as orgName from sys_equipment t
|
||||
left join sys_equipment se on t.parent_equipment_id = se.id
|
||||
left join sys_iot_model sim on t.iot_model_id = sim.id
|
||||
left join sys_org so on t.org_id = so.id
|
||||
<where>
|
||||
<if test="info.id != null and info.id != ''">
|
||||
and t.parent_equipment_id = #{info.id}
|
||||
</if>
|
||||
<if test="info.orgId != null and info.orgId != ''">
|
||||
and t.org_id = #{info.orgId}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
30
das/src/main/resources/mapper/SysIotModelFieldMapper.xml
Normal file
30
das/src/main/resources/mapper/SysIotModelFieldMapper.xml
Normal file
@ -0,0 +1,30 @@
|
||||
<?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.SysIotModelFieldMapper">
|
||||
|
||||
<resultMap type="com.das.modules.equipment.domain.vo.SysIotModelFieldVo" id="SysIotModelFieldMap">
|
||||
<result property="attributeCode" column="attribute_code" jdbcType="VARCHAR"/>
|
||||
<result property="attributeName" column="attribute_name" jdbcType="VARCHAR"/>
|
||||
<result property="attributeType" column="attribute_type" jdbcType="INTEGER"/>
|
||||
<result property="porder" column="porder" jdbcType="INTEGER"/>
|
||||
<result property="revision" column="revision" jdbcType="INTEGER"/>
|
||||
<result property="id" column="id" jdbcType="BIGINT"/>
|
||||
<result property="iotModelId" column="iot_model_id" jdbcType="BIGINT"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="querySysIotModelFieldList" resultMap="SysIotModelFieldMap">
|
||||
select t.* from sys_iot_model_field t
|
||||
<where>
|
||||
<if test="info.iotModelId != null and info.iotModelId != ''">
|
||||
and t.iot_model_id = #{info.iotModelId}
|
||||
</if>
|
||||
<if test="info.attributeName != null and info.attributeName != ''">
|
||||
and t.attribute_name like concat('%',#{info.attributeName},'%')
|
||||
</if>
|
||||
<if test="info.attributeCode != null and info.attributeCode != ''">
|
||||
and t.attribute_code like concat('%',#{info.attributeCode},'%')
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
</mapper>
|
30
das/src/main/resources/mapper/SysIotModelServiceMapper.xml
Normal file
30
das/src/main/resources/mapper/SysIotModelServiceMapper.xml
Normal file
@ -0,0 +1,30 @@
|
||||
<?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.SysIotModelServiceMapper">
|
||||
|
||||
<resultMap type="com.das.modules.equipment.domain.vo.SysIotModelServiceVo" id="SysIotModelServiceMap">
|
||||
<result property="serviceCode" column="service_code" jdbcType="VARCHAR"/>
|
||||
<result property="serviceName" column="service_name" jdbcType="VARCHAR"/>
|
||||
<result property="serviceType" column="service_type" jdbcType="INTEGER"/>
|
||||
<result property="porder" column="porder" jdbcType="INTEGER"/>
|
||||
<result property="revision" column="revision" jdbcType="INTEGER"/>
|
||||
<result property="id" column="id" jdbcType="BIGINT"/>
|
||||
<result property="iotModelId" column="iot_model_id" jdbcType="BIGINT"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="querySysIotModelServiceList" resultMap="SysIotModelServiceMap">
|
||||
select t.* from sys_iot_model_service t
|
||||
<where>
|
||||
<if test="info.iotModelId != null and info.iotModelId != ''">
|
||||
and t.iot_model_id = #{info.iotModelId}
|
||||
</if>
|
||||
<if test="info.serviceName != null and info.serviceName != ''">
|
||||
and t.service_name like concat('%',#{info.serviceName},'%')
|
||||
</if>
|
||||
<if test="info.serviceCode != null and info.serviceCode != ''">
|
||||
and t.service_code like concat('%',#{info.serviceCode},'%')
|
||||
</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导出设备清单
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
import createAxios from '/@/utils/axios'
|
||||
import { getUserData, passWordInfoType, getUserReturnDataType, userFormDataType, updateUserInfoReturnDataType } from './type'
|
||||
import { getUserData, passWordInfoType, getUserReturnDataType, userFormDataType, updateUserInfoReturnDataType } from '/@/views/backend/auth/userInfo/type'
|
||||
export const updateUserInfo = (data: userFormDataType) => {
|
||||
return createAxios<never, Promise<updateUserInfoReturnDataType>>({
|
||||
url: 'api/user/updateById',
|
||||
method: 'post',
|
||||
data: {
|
||||
id: data.id,
|
||||
id: data.id,
|
||||
account: data.account,
|
||||
userName: data.userName,
|
||||
email: data.email,
|
141
ui/dasadmin/src/api/backend/deviceModel/request.ts
Normal file
141
ui/dasadmin/src/api/backend/deviceModel/request.ts
Normal file
@ -0,0 +1,141 @@
|
||||
import createAxios from '/@/utils/axios'
|
||||
import {
|
||||
RequestReturnType,
|
||||
GetModelType,
|
||||
AddModelType,
|
||||
UpdateModelType,
|
||||
DelModelType,
|
||||
GetModelAttributeType,
|
||||
AddModelAttributeType,
|
||||
UpdateModelAttributeType,
|
||||
DelModelAttributeType,
|
||||
GetModelServiceType,
|
||||
AddModelServiceType,
|
||||
UpdateModelServiceType,
|
||||
RequestReturnRowType,
|
||||
} from '/@/views/backend/auth/model/type'
|
||||
import { useAdminInfo } from '/@/stores/adminInfo'
|
||||
import { encrypt_aes } from '/@/utils/crypto'
|
||||
|
||||
const adminInfo = useAdminInfo()
|
||||
export const getModelListReq = (data: GetModelType) => {
|
||||
return createAxios<never, RequestReturnType<AddModelType[] & UpdateModelType[]>>({
|
||||
url: '/api/equipment/model/list',
|
||||
method: 'post',
|
||||
data: data,
|
||||
})
|
||||
}
|
||||
|
||||
export const addModelReq = (data: AddModelType) => {
|
||||
return createAxios<never, RequestReturnType<AddModelType[] & UpdateModelType[]>>({
|
||||
url: '/api/equipment/model/add',
|
||||
method: 'post',
|
||||
data: data,
|
||||
})
|
||||
}
|
||||
|
||||
export const updateModelReq = (data: UpdateModelType) => {
|
||||
return createAxios<never, RequestReturnType>({
|
||||
url: '/api/equipment/model/update',
|
||||
method: 'post',
|
||||
data: data,
|
||||
})
|
||||
}
|
||||
|
||||
export const delModelReq = (data: DelModelType) => {
|
||||
return createAxios<never, RequestReturnType>({
|
||||
url: '/api/equipment/model/delete',
|
||||
method: 'post',
|
||||
data: data,
|
||||
})
|
||||
}
|
||||
|
||||
export const getModelAttributeListReq = (data: GetModelAttributeType) => {
|
||||
return createAxios<never, RequestReturnRowType<(AddModelAttributeType & UpdateModelAttributeType)[]>>({
|
||||
url: '/api/equipment/model/attribute/list',
|
||||
method: 'post',
|
||||
data: data,
|
||||
})
|
||||
}
|
||||
|
||||
export const addModelAttributeReq = (data: AddModelAttributeType) => {
|
||||
return createAxios<never, RequestReturnType<(AddModelAttributeType & UpdateModelAttributeType)[]>>({
|
||||
url: '/api/equipment/model/attribute/add',
|
||||
method: 'post',
|
||||
data: data,
|
||||
})
|
||||
}
|
||||
|
||||
export const updateModelAttributeReq = (data: UpdateModelAttributeType) => {
|
||||
return createAxios<never, RequestReturnType>({
|
||||
url: '/api/equipment/model/attribute/update',
|
||||
method: 'post',
|
||||
data: data,
|
||||
})
|
||||
}
|
||||
|
||||
export const delModelAttributeReq = (data: DelModelAttributeType) => {
|
||||
return createAxios<never, RequestReturnType>({
|
||||
url: '/api/equipment/model/attribute/delete',
|
||||
method: 'post',
|
||||
data: data,
|
||||
})
|
||||
}
|
||||
|
||||
export const getModelServiceListReq = (data: GetModelServiceType) => {
|
||||
return createAxios<never, RequestReturnRowType<(AddModelServiceType & UpdateModelServiceType)[]>>({
|
||||
url: '/api/equipment/model/service/list',
|
||||
method: 'post',
|
||||
data: data,
|
||||
})
|
||||
}
|
||||
|
||||
export const addModelServiceReq = (data: AddModelServiceType) => {
|
||||
return createAxios<never, RequestReturnType<(AddModelServiceType & UpdateModelServiceType)[]>>({
|
||||
url: '/api/equipment/model/service/add',
|
||||
method: 'post',
|
||||
data: data,
|
||||
})
|
||||
}
|
||||
|
||||
export const updateModelServiceReq = (data: UpdateModelServiceType) => {
|
||||
return createAxios<never, RequestReturnType>({
|
||||
url: '/api/equipment/model/service/update',
|
||||
method: 'post',
|
||||
data: data,
|
||||
})
|
||||
}
|
||||
|
||||
export const delModelServiceReq = (data: DelModelAttributeType) => {
|
||||
return createAxios<never, RequestReturnType>({
|
||||
url: '/api/equipment/model/service/delete',
|
||||
method: 'post',
|
||||
data: data,
|
||||
})
|
||||
}
|
||||
|
||||
export const uploadModelReq = (data: FormData, v: string) => {
|
||||
const token = encrypt_aes(adminInfo.token, v)
|
||||
return createAxios<never, RequestReturnType>(
|
||||
{
|
||||
url: '/api/equipment/model/import',
|
||||
method: 'post',
|
||||
data: data,
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data',
|
||||
v,
|
||||
token,
|
||||
},
|
||||
},
|
||||
{ customEncrypt: true }
|
||||
)
|
||||
}
|
||||
|
||||
export const downloadModelReq = (data: { id: string }) => {
|
||||
return createAxios<never, RequestReturnType>({
|
||||
url: '/api/equipment/model/export',
|
||||
method: 'post',
|
||||
data: data,
|
||||
responseType: 'blob',
|
||||
})
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
import createAxios from '/@/utils/axios'
|
||||
import { getDataType, addDataType, changeDataType, delDataType, getDataReturnType, operateDataReturnType, getTreeDataType,getTreeDataReturnType } from './type'
|
||||
import { getDataType, addDataType, changeDataType, delDataType, getDataReturnType, operateDataReturnType, getTreeDataType,getTreeDataReturnType } from '/@/views/backend/auth/org/type'
|
||||
|
||||
export const getInstitutionalListReq = (data: getDataType) => {
|
||||
return createAxios<addDataType, getDataReturnType<getTreeDataReturnType>>({
|
@ -10,7 +10,7 @@ import {
|
||||
addDataReturnType,
|
||||
delDataType,
|
||||
authorityDataListType
|
||||
} from './type'
|
||||
} from '/@/views/backend/auth/role/type'
|
||||
export const getRoleListReq = (params: getDataType) => {
|
||||
return createAxios<never, roleListReturnType<getDataReturnType>>({
|
||||
url: '/api/role/query',
|
@ -132,7 +132,7 @@ import { postClearCache } from '/@/api/common'
|
||||
import TerminalVue from '/@/components/terminal/index.vue'
|
||||
import { fullUrl } from '/@/utils/common'
|
||||
import { useSiteConfig } from '/@/stores/siteConfig'
|
||||
import UserInfoPage from '/@/views/backend/userInfo/userInfo.vue'
|
||||
import UserInfoPage from '/@/views/backend/auth/userInfo/userInfo.vue'
|
||||
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
|
||||
|
||||
const { t } = useI18n()
|
||||
|
@ -70,6 +70,7 @@ function createAxios<Data = any, T = ApiPromise<Data>>(axiosConfig: AxiosRequest
|
||||
showCodeMessage: true, // 是否开启code不为1时的信息提示, 默认为true
|
||||
showSuccessMessage: false, // 是否开启code为1时的信息提示, 默认为false
|
||||
anotherToken: '', // 当前请求使用另外的用户token
|
||||
customEncrypt: false, // 是否开启自定义加密
|
||||
},
|
||||
options
|
||||
)
|
||||
@ -87,24 +88,24 @@ function createAxios<Data = any, T = ApiPromise<Data>>(axiosConfig: AxiosRequest
|
||||
loadingInstance.target = ElLoading.service(loading)
|
||||
}
|
||||
}
|
||||
if (!options.customEncrypt) {
|
||||
if (config.method === 'post' && config.data) {
|
||||
// 对data进行加密
|
||||
console.log(config.data)
|
||||
config.data = encrypt_aes(config.data, v)
|
||||
} else if (config.method === 'get' && config.params) {
|
||||
// 对params进行加密
|
||||
console.log(config.params)
|
||||
config.params = encrypt_aes(config.params, v)
|
||||
}
|
||||
|
||||
if (config.method === 'post' && config.data) {
|
||||
// 对data进行加密
|
||||
console.log(config.data)
|
||||
config.data = encrypt_aes(config.data, v)
|
||||
} else if (config.method === 'get' && config.params) {
|
||||
// 对params进行加密
|
||||
console.log(config.params)
|
||||
config.params = encrypt_aes(config.params, v)
|
||||
// 自动携带token
|
||||
if (config.headers) {
|
||||
config.headers.v = v
|
||||
const token = adminInfo.getToken()
|
||||
if (token) (config.headers as anyObj).token = encrypt_aes(token, v)
|
||||
}
|
||||
}
|
||||
|
||||
// 自动携带token
|
||||
if (config.headers) {
|
||||
config.headers.v = v
|
||||
const token = adminInfo.getToken()
|
||||
if (token) (config.headers as anyObj).token = encrypt_aes(token, v)
|
||||
}
|
||||
|
||||
return config
|
||||
},
|
||||
(error) => {
|
||||
@ -347,6 +348,8 @@ interface Options {
|
||||
showSuccessMessage?: boolean
|
||||
// 当前请求使用另外的用户token
|
||||
anotherToken?: string
|
||||
// 是否开启自定义加密
|
||||
customEncrypt?: boolean
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -340,7 +340,7 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { Search, CirclePlusFilled, Upload, Download } from '@element-plus/icons-vue'
|
||||
import { userList } from '/@/api/backend'
|
||||
import { userList } from '../../../../api/backend/index'
|
||||
import { ElTable, ElMessage, ElMessageBox } from 'element-plus'
|
||||
import type { UploadProps, UploadUserFile } from 'element-plus'
|
||||
import type Node from 'element-plus/es/components/tree/src/model/node'
|
||||
|
102
ui/dasadmin/src/views/backend/auth/model/contextMenu.vue
Normal file
102
ui/dasadmin/src/views/backend/auth/model/contextMenu.vue
Normal file
@ -0,0 +1,102 @@
|
||||
<template>
|
||||
<div
|
||||
v-show="props.visible"
|
||||
class="moveContextMenu"
|
||||
:style="{
|
||||
left: props.pos.x - 60 + 'px',
|
||||
top: props.pos.y + 11 + 'px',
|
||||
}"
|
||||
>
|
||||
<div class="contextMenu">
|
||||
<div class="arrowBorder"></div>
|
||||
<div class="arrow"></div>
|
||||
<div class="modelOperate">
|
||||
<slot name="default"></slot>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { watch } from 'vue'
|
||||
const props = defineProps({
|
||||
pos: {
|
||||
type: Object,
|
||||
default: {
|
||||
x: 0,
|
||||
y: 0,
|
||||
},
|
||||
},
|
||||
visible: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
})
|
||||
|
||||
const emits = defineEmits(['update:visible', 'openModel'])
|
||||
|
||||
const closeMenu = () => {
|
||||
emits('update:visible', false)
|
||||
}
|
||||
watch(
|
||||
() => props.visible,
|
||||
() => {
|
||||
if (props.visible) {
|
||||
document.body.addEventListener('click', closeMenu)
|
||||
} else {
|
||||
document.body.removeEventListener('click', closeMenu)
|
||||
}
|
||||
}
|
||||
)
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
$defaultWidth: 80px;
|
||||
$defaultHeight: 150px;
|
||||
$defaultPadding: 20px;
|
||||
.moveContextMenu {
|
||||
position: fixed;
|
||||
.contextMenu {
|
||||
position: relative;
|
||||
padding: $defaultPadding;
|
||||
width: $defaultWidth + $defaultPadding * 2;
|
||||
height: $defaultHeight + $defaultPadding * 2;
|
||||
background-color: #fff;
|
||||
border-radius: 10px;
|
||||
border: 1px solid #e4e7ed;
|
||||
.modelOperate {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
width: $defaultWidth;
|
||||
height: $defaultHeight;
|
||||
.el-button {
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
.arrow {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -100%);
|
||||
width: 0;
|
||||
height: 0;
|
||||
border-bottom: 10px solid #fff;
|
||||
border-left: 9px solid transparent;
|
||||
border-right: 9px solid transparent;
|
||||
}
|
||||
.arrowBorder {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -100%);
|
||||
width: 0;
|
||||
height: 0;
|
||||
border-bottom: 11px solid #e4e7ed;
|
||||
border-left: 10px solid transparent;
|
||||
border-right: 10px solid transparent;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
852
ui/dasadmin/src/views/backend/auth/model/index.vue
Normal file
852
ui/dasadmin/src/views/backend/auth/model/index.vue
Normal file
@ -0,0 +1,852 @@
|
||||
<template>
|
||||
<div class="DeviceModel">
|
||||
<el-dialog v-model="modelDialogVisible" :title="modelDialogTitle" :width="400" @close="cancelModelForm">
|
||||
<el-form ref="modelFormRef" :model="modelForm" :rules="modelFormRules" label-width="110">
|
||||
<el-form-item prop="iotModelName" :label="ModelFieldsEnums['iotModelName']">
|
||||
<el-input :disabled="modelDialogState === ModelDialogTitleStateType['detail']" v-model="modelForm.iotModelName"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item prop="iotModelCode" :label="ModelFieldsEnums['iotModelCode']">
|
||||
<el-input :disabled="modelDialogState === ModelDialogTitleStateType['detail']" v-model="modelForm.iotModelCode"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item prop="objectType" :label="ModelFieldsEnums['objectType']">
|
||||
<el-input :disabled="modelDialogState === ModelDialogTitleStateType['detail']" v-model="modelForm.objectType"></el-input>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer v-if="modelDialogState !== ModelDialogTitleStateType['detail']">
|
||||
<el-button type="primary" @click="submitModelForm">提交</el-button>
|
||||
<el-button @click="cancelModelForm">取消</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
<el-container class="containerPart">
|
||||
<el-aside class="asidePart">
|
||||
<el-header class="asideHeader">
|
||||
<el-input
|
||||
v-model="searchModelValue"
|
||||
:suffix-icon="Search"
|
||||
clearable
|
||||
@input="debounceSearchModel"
|
||||
class="searchModelInput"
|
||||
></el-input>
|
||||
</el-header>
|
||||
<el-main class="asideMain">
|
||||
<el-tree-v2
|
||||
ref="modelTreeRef"
|
||||
:data="treeData"
|
||||
:props="DeviceModelPropReplace"
|
||||
class="modelTree"
|
||||
@node-contextmenu="modelContextMenu"
|
||||
@node-click="modelNodeClick"
|
||||
highlight-current
|
||||
>
|
||||
</el-tree-v2>
|
||||
</el-main>
|
||||
</el-aside>
|
||||
<el-container class="mainContainer">
|
||||
<el-header class="mainHeader">
|
||||
<div class="mainHeaderCenter">
|
||||
<el-input clearable class="modelAttributeSearchInput" v-model="modelAttributeAndServiceInputValue"></el-input>
|
||||
<el-radio-group v-model="modelAttributeSearchRadio">
|
||||
<el-radio value="Name">名称</el-radio>
|
||||
<el-radio value="Code">编码</el-radio>
|
||||
</el-radio-group>
|
||||
<el-button :icon="Search" type="primary" @click="searchModelAttribute">查询</el-button>
|
||||
</div>
|
||||
<div class="mainHeaderRight">
|
||||
<el-button :icon="Plus" type="primary" @click="addModelAttributeAndService">新增</el-button>
|
||||
<el-upload :show-file-list="false" :limit="1" :http-request="upLoadModel">
|
||||
<template #trigger>
|
||||
<el-button :icon="Upload">导入</el-button>
|
||||
</template>
|
||||
</el-upload>
|
||||
<el-button :icon="Download" @click="downLoadModel">导出</el-button>
|
||||
</div>
|
||||
</el-header>
|
||||
<el-main class="mainMain">
|
||||
<el-tabs v-model="ModelTabs" @tab-change="changeTabs" class="tabsPart">
|
||||
<el-tab-pane :label="modelTabsType['attribute']" name="attribute">
|
||||
<el-table :data="attributeTableData" class="tablePart">
|
||||
<el-table-column
|
||||
prop="attributeName"
|
||||
:label="ModelAttributeFieldsEnums['attributeName']"
|
||||
align="center"
|
||||
></el-table-column>
|
||||
<el-table-column
|
||||
prop="attributeCode"
|
||||
:label="ModelAttributeFieldsEnums['attributeCode']"
|
||||
align="center"
|
||||
></el-table-column>
|
||||
<el-table-column
|
||||
prop="attributeTypeName"
|
||||
:label="ModelAttributeFieldsEnums['attributeTypeName']"
|
||||
align="center"
|
||||
></el-table-column>
|
||||
<el-table-column prop="porder" :label="ModelAttributeFieldsEnums['porder']" align="center"></el-table-column>
|
||||
<el-table-column fixed="right" label="操作" min-width="80" align="center">
|
||||
<template #default="scope">
|
||||
<div class="tableOperate">
|
||||
<a @click="editAttributeForm(scope.row)">编辑</a>
|
||||
<a>|</a>
|
||||
<el-popconfirm title="确定删除么?" @confirm="delAttributeForm(scope.row)">
|
||||
<template #reference>
|
||||
<a>删除</a>
|
||||
</template>
|
||||
</el-popconfirm>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane :label="modelTabsType['service']" name="service">
|
||||
<el-table :data="serviceTableData" class="tablePart">
|
||||
<el-table-column prop="serviceName" :label="ModelServiceFieldsEnums['serviceName']" align="center"></el-table-column>
|
||||
<el-table-column prop="serviceCode" :label="ModelServiceFieldsEnums['serviceCode']" align="center"></el-table-column>
|
||||
<el-table-column
|
||||
prop="serviceTypeName"
|
||||
:label="ModelServiceFieldsEnums['serviceTypeName']"
|
||||
align="center"
|
||||
></el-table-column>
|
||||
<el-table-column prop="porder" :label="ModelServiceFieldsEnums['porder']" align="center"></el-table-column>
|
||||
<el-table-column fixed="right" label="操作" min-width="80" align="center">
|
||||
<template #default="scope">
|
||||
<div class="tableOperate">
|
||||
<a @click="editServiceForm(scope.row)">编辑</a>
|
||||
<a>|</a>
|
||||
<el-popconfirm title="确定删除么?" @confirm="delServiceForm(scope.row)">
|
||||
<template #reference>
|
||||
<a>删除</a>
|
||||
</template>
|
||||
</el-popconfirm>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
<div class="mainFooter">
|
||||
<el-pagination
|
||||
v-model:current-page="currentPage"
|
||||
v-model:page-size="currentPageSize"
|
||||
:total="pageTotal"
|
||||
:page-sizes="pagePagination"
|
||||
background
|
||||
:pager-count="7"
|
||||
layout="prev, pager, next, jumper,sizes,total"
|
||||
@change="getcurrentPage"
|
||||
></el-pagination>
|
||||
</div>
|
||||
</el-main>
|
||||
</el-container>
|
||||
</el-container>
|
||||
<ContextMenu :pos="contextMenuPos" v-model:visible="modelOperateVisible">
|
||||
<template #default>
|
||||
<div class="modelOperate">
|
||||
<el-button @click="openModel('detail', curContextMenuTreeData)" :icon="Reading">查看</el-button>
|
||||
<el-button @click="openModel('add')" :icon="DocumentAdd">新增</el-button>
|
||||
<el-button @click="openModel('edit', curContextMenuTreeData)" :icon="DocumentChecked">修改</el-button>
|
||||
<el-popconfirm title="确认删除?" @confirm="delModel">
|
||||
<template #reference>
|
||||
<el-button :icon="DocumentDelete" @click.stop>删除</el-button>
|
||||
</template>
|
||||
</el-popconfirm>
|
||||
</div>
|
||||
</template>
|
||||
</ContextMenu>
|
||||
<el-dialog v-model="attributeVisible" :title="attributeFormTitle" @close="closeAttributeForm" :width="600">
|
||||
<el-form ref="attributeFormRef" :model="attributeForm" label-width="100">
|
||||
<el-form-item :label="ModelAttributeFieldsEnums['attributeName']" prop="attributeName">
|
||||
<el-input v-model="attributeForm.attributeName"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item :label="ModelAttributeFieldsEnums['attributeCode']" prop="attributeCode">
|
||||
<el-input v-model="attributeForm.attributeCode"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item :label="ModelAttributeFieldsEnums['attributeTypeName']" prop="attributeType">
|
||||
<el-select v-model="attributeForm.attributeType">
|
||||
<el-option label="模拟量" :value="138"></el-option>
|
||||
<el-option label="累积量" :value="139"></el-option>
|
||||
<el-option label="离散量" :value="140"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item :label="ModelAttributeFieldsEnums['porder']" prop="porder">
|
||||
<el-input v-model="attributeForm.porder"></el-input>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button type="primary" @click="submitAttributeForm">提交</el-button>
|
||||
<el-button @click="closeAttributeForm">取消</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
<el-dialog v-model="serviceVisible" :title="serviceFormTitle" @close="closeServiceForm" :width="600">
|
||||
<el-form ref="serviceFormRef" :model="serviceForm" label-width="100">
|
||||
<el-form-item :label="ModelServiceFieldsEnums['serviceName']" prop="serviceName">
|
||||
<el-input v-model="serviceForm.serviceName"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item :label="ModelServiceFieldsEnums['serviceCode']" prop="serviceCode">
|
||||
<el-input v-model="serviceForm.serviceCode"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item :label="ModelServiceFieldsEnums['serviceTypeName']" prop="attributeType">
|
||||
<el-select v-model="serviceForm.serviceType">
|
||||
<el-option label="遥调" :value="146"></el-option>
|
||||
<el-option label="遥控" :value="147"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item :label="ModelServiceFieldsEnums['porder']" prop="porder">
|
||||
<el-input v-model="serviceForm.porder"></el-input>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button type="primary" @click="submitServiceForm">提交</el-button>
|
||||
<el-button @click="closeServiceForm">取消</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { reactive, ref, computed } from 'vue'
|
||||
import {
|
||||
ElContainer,
|
||||
ElAside,
|
||||
ElHeader,
|
||||
ElMain,
|
||||
ElTreeV2,
|
||||
ElInput,
|
||||
ElMessage,
|
||||
ElRadioGroup,
|
||||
ElRadio,
|
||||
ElButton,
|
||||
ElTabs,
|
||||
ElTabPane,
|
||||
ElTable,
|
||||
ElUpload,
|
||||
FormInstance,
|
||||
UploadRequestOptions,
|
||||
TreeNode,
|
||||
TreeInstance
|
||||
} from 'element-plus'
|
||||
import { Reading, DocumentAdd, DocumentChecked, DocumentDelete, Search, Plus, Download, Upload } from '@element-plus/icons-vue'
|
||||
import {
|
||||
ModelFieldsEnums,
|
||||
AddModelType,
|
||||
UpdateModelType,
|
||||
ModelDialogTitleStateType,
|
||||
ModelDialogTitleStateValueType,
|
||||
ModelDialogTitleStateKeyType,
|
||||
radioGroupType,
|
||||
modelTabsTypeKeyType,
|
||||
modelTabsType,
|
||||
AddModelAttributeType,
|
||||
UpdateModelAttributeType,
|
||||
UpdateModelServiceType,
|
||||
AddModelServiceType,
|
||||
ModelAttributeFieldsEnums,
|
||||
ModelAttributeTableType,
|
||||
ModelServiceTableType,
|
||||
ModelServiceFieldsEnums,
|
||||
AttributeDialogTitleStateType,
|
||||
serviceDialogTitleStateType,
|
||||
GetModelServiceType,
|
||||
GetModelAttributeType,
|
||||
} from './type'
|
||||
import {
|
||||
getModelListReq,
|
||||
addModelReq,
|
||||
updateModelReq,
|
||||
delModelReq,
|
||||
getModelAttributeListReq,
|
||||
addModelAttributeReq,
|
||||
updateModelAttributeReq,
|
||||
delModelAttributeReq,
|
||||
getModelServiceListReq,
|
||||
addModelServiceReq,
|
||||
updateModelServiceReq,
|
||||
delModelServiceReq,
|
||||
downloadModelReq,
|
||||
uploadModelReq,
|
||||
} from '/@/api/backend/deviceModel/request'
|
||||
import ContextMenu from './contextMenu.vue'
|
||||
import { encrypt_aes, generateRandomNumber } from '/@/utils/crypto'
|
||||
import { debounce } from 'lodash'
|
||||
|
||||
const DeviceModelPropReplace = {
|
||||
label: 'iotModelName',
|
||||
}
|
||||
const modelTreeRef = ref<TreeInstance>()
|
||||
const treeData = ref<(AddModelType & UpdateModelType)[]>([])
|
||||
const originTreeData = ref<(AddModelType & UpdateModelType)[]>([])
|
||||
|
||||
const searchModelValue = ref('')
|
||||
const searchModel = () => {
|
||||
if (searchModelValue.value === '') {
|
||||
treeData.value = originTreeData.value
|
||||
return
|
||||
}
|
||||
const reg = new RegExp(searchModelValue.value)
|
||||
const result = []
|
||||
for (let item of originTreeData.value) {
|
||||
if (reg.test(item.iotModelName)) {
|
||||
result.push(item)
|
||||
}
|
||||
}
|
||||
treeData.value = result
|
||||
}
|
||||
const debounceSearchModel = debounce(searchModel, 100)
|
||||
const modelFormRef = ref<FormInstance>()
|
||||
const modelDialogVisible = ref(false)
|
||||
const modelDialogState = ref<ModelDialogTitleStateValueType>(ModelDialogTitleStateType['detail'])
|
||||
const modelDialogTitle = computed(() => {
|
||||
return modelDialogState.value === ModelDialogTitleStateType['detail']
|
||||
? '查看物模型'
|
||||
: modelDialogState.value === ModelDialogTitleStateType['edit']
|
||||
? '新增物模型'
|
||||
: '编辑物模型'
|
||||
})
|
||||
const originModelForm: AddModelType & UpdateModelType = {
|
||||
iotModelName: '',
|
||||
objectType: null,
|
||||
iotModelCode: '',
|
||||
revision: 1,
|
||||
createdBy: undefined,
|
||||
createdTime: undefined,
|
||||
updatedBy: undefined,
|
||||
updatedTime: undefined,
|
||||
id: null,
|
||||
}
|
||||
const modelForm = ref<AddModelType & UpdateModelType>(JSON.parse(JSON.stringify(originModelForm)))
|
||||
const modelFormRules = {
|
||||
iotModelName: [{ required: true, message: '请输入物模型名称', trigger: 'blur' }],
|
||||
iotModelCode: [{ required: true, message: '请输入物模型编码', trigger: 'blur' }],
|
||||
objectType: [{ required: true, message: '请选择物模型类型', trigger: 'blur' }],
|
||||
}
|
||||
const submitModelForm = () => {
|
||||
if (modelDialogState.value === ModelDialogTitleStateType['add']) {
|
||||
addModelReq(modelForm.value)
|
||||
.then((res) => {
|
||||
if (res.success) {
|
||||
ElMessage.success('新增物模型成功')
|
||||
modelDialogVisible.value = false
|
||||
getModelList()
|
||||
} else {
|
||||
ElMessage.error(res.msg)
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
ElMessage.error(err?.response?.data?.msg ?? '新增失败')
|
||||
})
|
||||
} else if (modelDialogState.value === ModelDialogTitleStateType['edit']) {
|
||||
updateModelReq(modelForm.value)
|
||||
.then((res) => {
|
||||
if (res.success) {
|
||||
ElMessage.success('修改物模型成功')
|
||||
modelDialogVisible.value = false
|
||||
getModelList()
|
||||
} else {
|
||||
ElMessage.error(res.msg)
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
ElMessage.error(err?.response?.data?.msg ?? '修改失败')
|
||||
})
|
||||
}
|
||||
}
|
||||
const getModelList = (name?: string) => {
|
||||
return new Promise((resolve) => {
|
||||
getModelListReq({ iotModelName: name })
|
||||
.then((res) => {
|
||||
if (res.success) {
|
||||
originTreeData.value = res.data!
|
||||
treeData.value = res.data!
|
||||
resolve(res.data![0])
|
||||
} else {
|
||||
ElMessage.error(res.msg)
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
ElMessage.error(err?.response?.data?.msg ?? '查询失败')
|
||||
})
|
||||
})
|
||||
}
|
||||
const cancelModelForm = () => {
|
||||
modelForm.value = JSON.parse(JSON.stringify(originModelForm))
|
||||
modelFormRef.value?.resetFields()
|
||||
modelDialogVisible.value = false
|
||||
}
|
||||
|
||||
const modelOperateVisible = ref(false)
|
||||
const contextMenuPos = ref({
|
||||
x: 0,
|
||||
y: 0,
|
||||
})
|
||||
const curContextMenuTreeData = ref<AddModelType & UpdateModelType>()
|
||||
const modelContextMenu = (event: any, data: TreeNode) => {
|
||||
contextMenuPos.value.x = event.pageX
|
||||
contextMenuPos.value.y = event.pageY
|
||||
curContextMenuTreeData.value = JSON.parse(JSON.stringify(data))
|
||||
modelOperateVisible.value = true
|
||||
}
|
||||
const modelNodeClick = (target: TreeNode) => {
|
||||
curContextMenuTreeData.value = JSON.parse(JSON.stringify(target))
|
||||
if (ModelTabs.value === 'attribute') {
|
||||
getAttributeList()
|
||||
} else {
|
||||
getServiceList()
|
||||
}
|
||||
}
|
||||
const openModel = (type: ModelDialogTitleStateKeyType, data?: AddModelType & UpdateModelType) => {
|
||||
modelDialogState.value = ModelDialogTitleStateType[type]
|
||||
if (type !== 'add') {
|
||||
modelForm.value = data!
|
||||
}
|
||||
// modelOperateVisible.value = false
|
||||
modelDialogVisible.value = true
|
||||
}
|
||||
const delModel = () => {
|
||||
delModelReq({ id: curContextMenuTreeData.value!.id! })
|
||||
.then((res) => {
|
||||
if (res.success) {
|
||||
ElMessage.success('删除物模型成功')
|
||||
getModelList()
|
||||
modelOperateVisible.value = false
|
||||
} else {
|
||||
ElMessage.error(res.msg)
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
ElMessage.error(err?.response?.data?.msg ?? '删除失败')
|
||||
})
|
||||
}
|
||||
const modelAttributeAndServiceInputValue = ref('')
|
||||
const searchModelAttribute = () => {
|
||||
if (modelAttributeSearchRadio.value === 'Name') {
|
||||
if (ModelTabs.value === 'attribute') {
|
||||
console.log('test')
|
||||
|
||||
getAttributeList(modelAttributeSearchRadio.value, modelAttributeAndServiceInputValue.value)
|
||||
} else if (ModelTabs.value === 'service') {
|
||||
getServiceList(modelAttributeSearchRadio.value, modelAttributeAndServiceInputValue.value)
|
||||
}
|
||||
} else if (modelAttributeSearchRadio.value === 'Code') {
|
||||
if (ModelTabs.value === 'attribute') {
|
||||
getAttributeList(modelAttributeSearchRadio.value, modelAttributeAndServiceInputValue.value)
|
||||
} else if (ModelTabs.value === 'service') {
|
||||
getServiceList(modelAttributeSearchRadio.value, modelAttributeAndServiceInputValue.value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const modelAttributeSearchRadio = ref<radioGroupType>('Name')
|
||||
|
||||
const ModelTabs = ref<modelTabsTypeKeyType>('attribute')
|
||||
const changeTabs = (name: any) => {
|
||||
if (name === 'attribute') {
|
||||
getAttributeList()
|
||||
} else {
|
||||
getServiceList()
|
||||
}
|
||||
}
|
||||
|
||||
const attributeTableData = ref<ModelAttributeTableType[]>([])
|
||||
const editAttributeForm = (data: AddModelAttributeType & UpdateModelAttributeType) => {
|
||||
attributeFormTitle.value = AttributeDialogTitleStateType['edit']
|
||||
attributeForm.value = JSON.parse(JSON.stringify(data))
|
||||
attributeVisible.value = true
|
||||
}
|
||||
const delAttributeForm = (data: AddModelAttributeType & UpdateModelAttributeType) => {
|
||||
delModelAttributeReq({ id: data.id! })
|
||||
.then((res) => {
|
||||
if (res.success) {
|
||||
ElMessage.success('删除物模型属性成功')
|
||||
getAttributeList()
|
||||
} else {
|
||||
ElMessage.error(res.msg)
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
ElMessage.error(err?.response?.data?.msg ?? '删除失败')
|
||||
})
|
||||
}
|
||||
|
||||
const getAttributeList = (type?: radioGroupType, value?: string) => {
|
||||
const requestData: GetModelAttributeType = {
|
||||
iotModelId: curContextMenuTreeData.value!.id!,
|
||||
pageNum: currentPage.value,
|
||||
pageSize: currentPageSize.value,
|
||||
}
|
||||
if (type === 'Name') {
|
||||
requestData.attributeName = value
|
||||
} else if (type === 'Code') {
|
||||
requestData.attributeCode = value
|
||||
}
|
||||
|
||||
getModelAttributeListReq(requestData)
|
||||
.then((res) => {
|
||||
if (res.rows && res.rows.length > 0) {
|
||||
attributeTableData.value = res.rows!.map((item) => {
|
||||
return {
|
||||
...item,
|
||||
attributeTypeName:
|
||||
item.attributeType === 138
|
||||
? '模拟量'
|
||||
: item.attributeType === 139
|
||||
? '累积量'
|
||||
: item.attributeType === 140
|
||||
? '离散量'
|
||||
: item.attributeType!,
|
||||
}
|
||||
})
|
||||
pageTotal.value = res.total
|
||||
} else {
|
||||
ElMessage.error(res.msg)
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
ElMessage.error(err?.response?.data?.msg ?? '查询失败')
|
||||
})
|
||||
}
|
||||
|
||||
const getServiceList = (type?: radioGroupType, value?: string) => {
|
||||
const requestData: GetModelServiceType = {
|
||||
iotModelId: curContextMenuTreeData.value!.id!,
|
||||
pageNum: currentPage.value,
|
||||
pageSize: currentPageSize.value,
|
||||
}
|
||||
if (type === 'Name') {
|
||||
requestData.serviceName = value
|
||||
} else if (type === 'Code') {
|
||||
requestData.serviceCode = value
|
||||
}
|
||||
getModelServiceListReq(requestData)
|
||||
.then((res) => {
|
||||
if (res.rows && res.rows.length > 0) {
|
||||
serviceTableData.value = res.rows!.map((item) => {
|
||||
return {
|
||||
...item,
|
||||
serviceTypeName: item.serviceType === 146 ? '遥调' : item.serviceType === 147 ? '遥控' : item.serviceType!,
|
||||
}
|
||||
})
|
||||
pageTotal.value = res.total
|
||||
} else {
|
||||
ElMessage.error(res.msg)
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
ElMessage.error(err?.response?.data?.msg ?? '查询失败')
|
||||
})
|
||||
}
|
||||
|
||||
const serviceTableData = ref<ModelServiceTableType[]>([])
|
||||
|
||||
const editServiceForm = (data: AddModelServiceType & UpdateModelServiceType) => {
|
||||
serviceFormTitle.value = serviceDialogTitleStateType['edit']
|
||||
serviceForm.value = JSON.parse(JSON.stringify(data))
|
||||
serviceVisible.value = true
|
||||
}
|
||||
const delServiceForm = (data: AddModelServiceType & UpdateModelServiceType) => {
|
||||
delModelServiceReq({ id: data.id! })
|
||||
.then((res) => {
|
||||
if (res.success) {
|
||||
ElMessage.success('删除物模型方法成功')
|
||||
getServiceList()
|
||||
} else {
|
||||
ElMessage.error(res.msg)
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
ElMessage.error(err?.response?.data?.msg ?? '删除失败')
|
||||
})
|
||||
}
|
||||
|
||||
const attributeVisible = ref(false)
|
||||
const attributeFormTitle = ref(AttributeDialogTitleStateType['add'])
|
||||
const originAttributeForm: AddModelAttributeType & UpdateModelAttributeType = {
|
||||
id: null,
|
||||
iotModelId: '',
|
||||
attributeCode: '',
|
||||
attributeName: '',
|
||||
attributeType: null,
|
||||
porder: null,
|
||||
revision: 1,
|
||||
createdBy: undefined,
|
||||
createdTime: undefined,
|
||||
updatedBy: undefined,
|
||||
updatedTime: undefined,
|
||||
}
|
||||
const attributeFormRef = ref<FormInstance>()
|
||||
const attributeForm = ref<AddModelAttributeType & UpdateModelAttributeType>(JSON.parse(JSON.stringify(originAttributeForm)))
|
||||
|
||||
const closeAttributeForm = () => {
|
||||
attributeVisible.value = false
|
||||
attributeForm.value = JSON.parse(JSON.stringify(originAttributeForm))
|
||||
attributeFormRef.value?.resetFields()
|
||||
}
|
||||
const submitAttributeForm = () => {
|
||||
attributeFormRef.value?.validate((valid) => {
|
||||
if (valid) {
|
||||
if (attributeFormTitle.value === AttributeDialogTitleStateType['add']) {
|
||||
attributeForm.value.iotModelId = curContextMenuTreeData.value!.id!
|
||||
addModelAttributeReq(attributeForm.value)
|
||||
.then((res) => {
|
||||
if (res.success) {
|
||||
ElMessage.success('新增物模型属性成功')
|
||||
closeAttributeForm()
|
||||
getAttributeList()
|
||||
} else {
|
||||
ElMessage.error(res.msg)
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
ElMessage.error(err?.response?.data?.msg ?? '新增失败')
|
||||
})
|
||||
} else if (attributeFormTitle.value === AttributeDialogTitleStateType['edit']) {
|
||||
updateModelAttributeReq(attributeForm.value)
|
||||
.then((res) => {
|
||||
if (res.success) {
|
||||
ElMessage.success('修改物模型属性成功')
|
||||
closeAttributeForm()
|
||||
getAttributeList()
|
||||
} else {
|
||||
ElMessage.error(res.msg)
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
ElMessage.error(err?.response?.data?.msg ?? '修改失败')
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const serviceVisible = ref(false)
|
||||
const serviceFormTitle = ref(serviceDialogTitleStateType['add'])
|
||||
const originServiceForm: AddModelServiceType & UpdateModelServiceType = {
|
||||
id: null,
|
||||
iotModelId: '',
|
||||
serviceCode: '',
|
||||
serviceName: '',
|
||||
serviceType: null,
|
||||
porder: null,
|
||||
revision: 1,
|
||||
createdBy: undefined,
|
||||
createdTime: undefined,
|
||||
updatedBy: undefined,
|
||||
updatedTime: undefined,
|
||||
}
|
||||
const serviceFormRef = ref<FormInstance>()
|
||||
const serviceForm = ref<AddModelServiceType & UpdateModelServiceType>(JSON.parse(JSON.stringify(originServiceForm)))
|
||||
const closeServiceForm = () => {
|
||||
serviceVisible.value = false
|
||||
serviceForm.value = JSON.parse(JSON.stringify(originServiceForm))
|
||||
serviceFormRef.value?.resetFields()
|
||||
}
|
||||
const submitServiceForm = () => {
|
||||
serviceFormRef.value?.validate((valid) => {
|
||||
if (valid) {
|
||||
if (serviceFormTitle.value === serviceDialogTitleStateType['add']) {
|
||||
serviceForm.value.iotModelId = curContextMenuTreeData.value!.id!
|
||||
addModelServiceReq(serviceForm.value)
|
||||
.then((res) => {
|
||||
if (res.success) {
|
||||
ElMessage.success('新增物模型方法成功')
|
||||
closeServiceForm()
|
||||
getServiceList()
|
||||
} else {
|
||||
ElMessage.error(res.msg)
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
ElMessage.error(err?.response?.data?.msg ?? '新增失败')
|
||||
})
|
||||
} else if (serviceFormTitle.value === serviceDialogTitleStateType['edit']) {
|
||||
updateModelServiceReq(serviceForm.value)
|
||||
.then((res) => {
|
||||
if (res.success) {
|
||||
ElMessage.success('修改物模型方法成功')
|
||||
closeServiceForm()
|
||||
getServiceList()
|
||||
} else {
|
||||
ElMessage.error(res.msg)
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
ElMessage.error(err?.response?.data?.msg ?? '修改失败')
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const addModelAttributeAndService = () => {
|
||||
if (ModelTabs.value === 'attribute') {
|
||||
attributeVisible.value = true
|
||||
} else {
|
||||
serviceVisible.value = true
|
||||
}
|
||||
}
|
||||
|
||||
const upLoadModel = (file: UploadRequestOptions) => {
|
||||
const formData = new FormData()
|
||||
formData.append('file', file.file)
|
||||
const v = generateRandomNumber(16)
|
||||
const id = encrypt_aes(curContextMenuTreeData.value!.id!, v)
|
||||
formData.append('id', id)
|
||||
return uploadModelReq(formData, v)
|
||||
.then((res) => {
|
||||
if (res.success) {
|
||||
ElMessage.success('上传物模型成功')
|
||||
getModelList()
|
||||
} else {
|
||||
ElMessage.error(res.msg)
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
ElMessage.error(err?.response?.data?.msg ?? '上传失败')
|
||||
})
|
||||
}
|
||||
|
||||
const downLoadModel = () => {
|
||||
downloadModelReq({ id: curContextMenuTreeData.value!.id! }).then((res: any) => {
|
||||
const downloadUrl = window.URL.createObjectURL(res)
|
||||
const a = document.createElement('a')
|
||||
a.href = downloadUrl
|
||||
a.download = '物模型' + new Date().getTime()
|
||||
document.body.appendChild(a)
|
||||
a.click()
|
||||
window.URL.revokeObjectURL(downloadUrl)
|
||||
document.body.removeChild(a)
|
||||
})
|
||||
}
|
||||
|
||||
const currentPage = ref(1)
|
||||
const currentPageSize = ref(10)
|
||||
const pageTotal = ref(0)
|
||||
const pagePagination = ref([10, 20, 30])
|
||||
const getcurrentPage = () => {
|
||||
if (ModelTabs.value === 'attribute') {
|
||||
getAttributeList()
|
||||
} else if (ModelTabs.value === 'service') {
|
||||
getServiceList()
|
||||
}
|
||||
}
|
||||
|
||||
getModelList().then((res) => {
|
||||
curContextMenuTreeData.value = JSON.parse(JSON.stringify(res))
|
||||
modelTreeRef.value?.setCurrentKey(curContextMenuTreeData.value!.id!)
|
||||
if (ModelTabs.value === 'attribute') {
|
||||
getAttributeList()
|
||||
} else {
|
||||
getServiceList()
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
$headerHeight: 60px;
|
||||
$defaultBackgroundColor: #fff;
|
||||
$defaultAsideWidth: 260px;
|
||||
$paginationHeight: 32px;
|
||||
.DeviceModel {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
.containerPart {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
.asidePart {
|
||||
width: $defaultAsideWidth;
|
||||
height: 100%;
|
||||
border-right: 1px solid #eaebed;
|
||||
.asideHeader {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
.searchModelInput {
|
||||
height: 40px;
|
||||
}
|
||||
}
|
||||
.asideMain {
|
||||
height: calc(100% - $headerHeight);
|
||||
overflow-y: auto;
|
||||
.modelTree {
|
||||
height: 100%;
|
||||
background-color: $defaultBackgroundColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
.mainContainer {
|
||||
width: calc(100% - $defaultAsideWidth);
|
||||
height: 100%;
|
||||
.mainHeader {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
height: $headerHeight;
|
||||
padding: 0 20px;
|
||||
border-bottom: 1px solid #eaebed;
|
||||
.modelAttributeSearchInput {
|
||||
height: 40px;
|
||||
width: 220px;
|
||||
}
|
||||
.mainHeaderCenter {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
width: 480px;
|
||||
}
|
||||
.mainHeaderRight {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
width: 280px;
|
||||
}
|
||||
.el-button {
|
||||
width: 88px;
|
||||
height: 40px;
|
||||
}
|
||||
}
|
||||
.mainMain {
|
||||
height: calc(100% - $headerHeight);
|
||||
.tabsPart {
|
||||
height: calc(100% - $paginationHeight);
|
||||
:deep(.el-tabs__content) {
|
||||
height: calc(100% - 55px);
|
||||
.el-tab-pane {
|
||||
height: 100%;
|
||||
}
|
||||
}
|
||||
.tablePart {
|
||||
height: 100%;
|
||||
}
|
||||
.tableOperate {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
a {
|
||||
margin: 5px;
|
||||
color: #0064aa;
|
||||
font-weight: 600;
|
||||
&:hover {
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.mainFooter {
|
||||
display: flex;
|
||||
justify-content: right;
|
||||
background-color: #fff;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.modelOperate {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
width: 80px;
|
||||
height: 200px;
|
||||
.el-button {
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
173
ui/dasadmin/src/views/backend/auth/model/type.ts
Normal file
173
ui/dasadmin/src/views/backend/auth/model/type.ts
Normal file
@ -0,0 +1,173 @@
|
||||
export type RequestReturnType<T = never> = Promise<{
|
||||
code: number
|
||||
msg: string
|
||||
success: boolean
|
||||
data?: T
|
||||
}>
|
||||
export type RequestReturnRowType<T = never> = Promise<{
|
||||
code: number
|
||||
msg: string
|
||||
rows: T
|
||||
total: number
|
||||
}>
|
||||
|
||||
export enum ModelFieldsEnums {
|
||||
'id' = 'id',
|
||||
'objectType' = '设备类型',
|
||||
'iotModelCode' = '物模型编码',
|
||||
'iotModelName' = '物模型名称',
|
||||
'revision' = '乐观锁',
|
||||
'createdBy' = '创建人',
|
||||
'createdTime' = '创建时间',
|
||||
'updatedBy' = '更新人',
|
||||
'updatedTime' = '更新时间',
|
||||
}
|
||||
|
||||
export type ModelFieldsJointType = keyof typeof ModelFieldsEnums
|
||||
|
||||
export type ModelAttributeType = 138 | 139 | 140
|
||||
|
||||
export type ModelServiceType = 146 | 147
|
||||
|
||||
export type GetModelType = {
|
||||
objectType?: number
|
||||
iotModelName?: string
|
||||
iotModelCode?: string
|
||||
}
|
||||
|
||||
export type AddModelType = {
|
||||
objectType: number | null
|
||||
iotModelName: string
|
||||
iotModelCode: string
|
||||
revision: number
|
||||
createdBy?: string
|
||||
createdTime?: string
|
||||
}
|
||||
|
||||
export type UpdateModelType = {
|
||||
id: string | null
|
||||
updatedBy?: string
|
||||
updatedTime?: string
|
||||
} & Omit<AddModelType, 'createdBy' | 'createdTime'>
|
||||
|
||||
export type DelModelType = {
|
||||
id: string
|
||||
}
|
||||
|
||||
export enum ModelAttributeFieldsEnums {
|
||||
'id' = 'id',
|
||||
'iotModelId' = '所属物模型ID',
|
||||
'attributeCode' = '属性编码',
|
||||
'attributeName' = '属性名称',
|
||||
'attributeType' = '属性类型value',
|
||||
'attributeTypeName' = '属性类型',
|
||||
'porder' = '测点序号',
|
||||
'revision' = '乐观锁',
|
||||
'createdBy' = '创建人',
|
||||
'createdTime' = '创建时间',
|
||||
'updatedBy' = '更新人',
|
||||
'updatedTime' = '更新时间',
|
||||
}
|
||||
|
||||
export enum ModelServiceFieldsEnums {
|
||||
'id' = 'id',
|
||||
'iotModelId' = '所属物模型ID',
|
||||
'serviceCode' = '属性编码',
|
||||
'serviceName' = '属性名称',
|
||||
'serviceType' = '属性类型value',
|
||||
'serviceTypeName' = '属性类型',
|
||||
'porder' = '测点序号',
|
||||
'revision' = '乐观锁',
|
||||
'createdBy' = '创建人',
|
||||
'createdTime' = '创建时间',
|
||||
'updatedBy' = '更新人',
|
||||
'updatedTime' = '更新时间',
|
||||
}
|
||||
|
||||
export type GetModelAttributeType = {
|
||||
iotModelId: string
|
||||
attributeCode?: string
|
||||
attributeName?: string
|
||||
pageSize: number
|
||||
pageNum: number
|
||||
}
|
||||
|
||||
export type AddModelAttributeType = {
|
||||
iotModelId: string
|
||||
attributeCode: string
|
||||
attributeName: string
|
||||
attributeType: ModelAttributeType | null
|
||||
porder: number | null
|
||||
revision: number
|
||||
createdBy?: string
|
||||
createdTime?: string
|
||||
}
|
||||
|
||||
export type UpdateModelAttributeType = {
|
||||
id: string | null
|
||||
updatedBy?: string
|
||||
updatedTime?: string
|
||||
} & Omit<AddModelAttributeType, 'createdBy' | 'createdTime'>
|
||||
|
||||
export type DelModelAttributeType = {
|
||||
id: string
|
||||
}
|
||||
|
||||
export type GetModelServiceType = {
|
||||
iotModelId: string
|
||||
serviceCode?: string
|
||||
serviceName?: string
|
||||
pageSize: number
|
||||
pageNum: number
|
||||
}
|
||||
|
||||
export type AddModelServiceType = {
|
||||
iotModelId: string
|
||||
serviceCode: string
|
||||
serviceName: string
|
||||
serviceType: ModelServiceType | null
|
||||
porder: number | null
|
||||
revision: number
|
||||
createdBy?: string
|
||||
createdTime?: string
|
||||
}
|
||||
|
||||
export type UpdateModelServiceType = {
|
||||
id: string | null
|
||||
updatedBy?: string
|
||||
updatedTime?: string
|
||||
} & Omit<AddModelServiceType, 'createdBy' | 'createdTime'>
|
||||
|
||||
export enum ModelDialogTitleStateType {
|
||||
'add' = '新增物模型',
|
||||
'edit' = '编辑物模型',
|
||||
'detail' = '查看物模型',
|
||||
}
|
||||
export type ModelDialogTitleStateKeyType = keyof typeof ModelDialogTitleStateType
|
||||
export type ModelDialogTitleStateValueType = `${ModelDialogTitleStateType}`
|
||||
|
||||
export type radioGroupType = 'Code' | 'Name'
|
||||
|
||||
export enum modelTabsType {
|
||||
'attribute' = '属性',
|
||||
'service' = '方法',
|
||||
}
|
||||
export type modelTabsTypeKeyType = keyof typeof modelTabsType
|
||||
|
||||
export type ModelAttributeTableType = AddModelAttributeType &
|
||||
UpdateModelAttributeType & {
|
||||
attributeTypeName: '模拟量' | '累积量' | '离散量' | ModelAttributeType
|
||||
}
|
||||
export type ModelServiceTableType = AddModelServiceType &
|
||||
UpdateModelServiceType & {
|
||||
serviceTypeName: '遥调' | '遥控' | ModelServiceType
|
||||
}
|
||||
|
||||
export enum AttributeDialogTitleStateType {
|
||||
'add' = '新增物模型属性',
|
||||
'edit' = '编辑物模型属性',
|
||||
}
|
||||
export enum serviceDialogTitleStateType {
|
||||
'add' = '新增物模型方法',
|
||||
'edit' = '编辑物模型方法',
|
||||
}
|
@ -142,7 +142,7 @@ import {
|
||||
changeInstitutionalListReq,
|
||||
delInstitutionalListReq,
|
||||
getInstitutionalTreeListReq,
|
||||
} from './request'
|
||||
} from '/@/api/backend/org/request'
|
||||
import {
|
||||
getDataType,
|
||||
addDataEnum,
|
||||
@ -160,8 +160,8 @@ import { useAdminInfo } from '/@/stores/adminInfo'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
const { t } = useI18n()
|
||||
const adminInfo = useAdminInfo()
|
||||
const treeSearchInputPlaceholder = '搜索机构'
|
||||
const searchInputTreeValue = ref<string>('')
|
||||
// const treeSearchInputPlaceholder = '搜索机构'
|
||||
// const searchInputTreeValue = ref<string>('')
|
||||
|
||||
const formRef = ref<FormInstance>()
|
||||
|
||||
|
@ -106,7 +106,7 @@ import {
|
||||
tableDataEnum,
|
||||
} from './type'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { getRoleListReq, changeRoleListReq, addRoleListReq, delRoleListReq, getAllRoleListReq } from './request'
|
||||
import { getRoleListReq, changeRoleListReq, addRoleListReq, delRoleListReq, getAllRoleListReq } from '/@/api/backend/role/request'
|
||||
|
||||
const { t } = useI18n()
|
||||
const dialogTitle = ref('新增角色')
|
||||
|
@ -208,10 +208,10 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, onMounted, computed } from 'vue'
|
||||
import { Search, CirclePlusFilled } from '@element-plus/icons-vue'
|
||||
import { userQuery, userUpdate, userDelete, userAdd, userList, allRoleQuery } from '/@/api/backend'
|
||||
import { userQuery, userUpdate, userDelete, userAdd, userList, allRoleQuery } from '/@/api/backend/index'
|
||||
import { ElTable, ElMessage, FormRules } from 'element-plus'
|
||||
import type Node from 'element-plus/es/components/tree/src/model/node'
|
||||
import Avatar from '/@/views/backend/userInfo/avatar.vue'
|
||||
import Avatar from '/@/views/backend/auth/userInfo/avatar.vue'
|
||||
|
||||
const input2 = ref('')
|
||||
interface Tree {
|
||||
|
@ -20,7 +20,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed } from 'vue'
|
||||
import { ref } from 'vue'
|
||||
import { ElScrollbar, ElIcon, ElPopover, ElRow, ElCol } from 'element-plus'
|
||||
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
|
||||
const emits = defineEmits(['selectAvatar'])
|
||||
@ -29,9 +29,7 @@ for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
|
||||
iconArr.push(component)
|
||||
}
|
||||
const computedHeight = Math.ceil(iconArr.length / 4) * 40
|
||||
const computedIconArr = () => {
|
||||
return iconArr.slice()
|
||||
}
|
||||
|
||||
const popoverVisible = ref(false)
|
||||
const selectAvatar = (name: string) => {
|
||||
emits('selectAvatar', name)
|
@ -66,6 +66,7 @@
|
||||
autocomplete="new-password"
|
||||
:placeholder="t('userInfo.Please enter your old password')"
|
||||
v-model="state.passWordInfo.oldPassword"
|
||||
show-password
|
||||
></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item :label="t('userInfo.New password')" prop="newPassword">
|
||||
@ -74,6 +75,7 @@
|
||||
autocomplete="new-password"
|
||||
:placeholder="t('userInfo.Please enter Your New password')"
|
||||
v-model="state.passWordInfo.newPassword"
|
||||
show-password
|
||||
></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item :label="t('userInfo.New Repeat password')" prop="repeatPassword">
|
||||
@ -82,6 +84,7 @@
|
||||
autocomplete="new-password"
|
||||
:placeholder="t('userInfo.Please enter your password again')"
|
||||
v-model="state.passWordInfo.repeatPassword"
|
||||
show-password
|
||||
></el-input>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
@ -96,11 +99,11 @@
|
||||
<script setup lang="ts">
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { ref, reactive, watch } from 'vue'
|
||||
import { isEmpty, size } from 'lodash-es'
|
||||
// import { isEmpty, size } from 'lodash-es'
|
||||
import { useAdminInfo } from '/@/stores/adminInfo'
|
||||
import type { FormInstance } from 'element-plus'
|
||||
import { ElMessage, ElDialog, ElPopover, ElAvatar } from 'element-plus'
|
||||
import { userQuery, updateUserInfo, updatePassWordInfo } from './request'
|
||||
import { userQuery, updateUserInfo, updatePassWordInfo } from '/@/api/backend/auth/userInfo'
|
||||
import { userInfoReactiveDataType } from './type'
|
||||
import { buildValidatorData } from '/@/utils/validate'
|
||||
import AvatarComponent from './avatar.vue'
|
Loading…
Reference in New Issue
Block a user