对接逆变器
This commit is contained in:
@ -0,0 +1,106 @@
|
|||||||
|
package org.dromara.shebei.controller;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import jakarta.validation.constraints.*;
|
||||||
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
||||||
|
import org.dromara.common.log.annotation.Log;
|
||||||
|
import org.dromara.common.web.core.BaseController;
|
||||||
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||||
|
import org.dromara.common.core.domain.R;
|
||||||
|
import org.dromara.common.core.validate.AddGroup;
|
||||||
|
import org.dromara.common.core.validate.EditGroup;
|
||||||
|
import org.dromara.common.log.enums.BusinessType;
|
||||||
|
import org.dromara.common.excel.utils.ExcelUtil;
|
||||||
|
import org.dromara.shebei.domain.vo.OpsSbLiebiaoVo;
|
||||||
|
import org.dromara.shebei.domain.bo.OpsSbLiebiaoBo;
|
||||||
|
import org.dromara.shebei.service.IOpsSbLiebiaoService;
|
||||||
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 运维-设备管理-设备列
|
||||||
|
* 前端访问路由地址为:/shebei/sbLiebiao
|
||||||
|
*
|
||||||
|
* @author LionLi
|
||||||
|
* @date 2025-10-09
|
||||||
|
*/
|
||||||
|
@Validated
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/sbLiebiao")
|
||||||
|
public class OpsSbLiebiaoController extends BaseController {
|
||||||
|
|
||||||
|
private final IOpsSbLiebiaoService opsSbLiebiaoService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询运维-设备管理-设备列列表
|
||||||
|
*/
|
||||||
|
@SaCheckPermission("shebei:sbLiebiao:list")
|
||||||
|
@GetMapping("/list")
|
||||||
|
public TableDataInfo<OpsSbLiebiaoVo> list(OpsSbLiebiaoBo bo, PageQuery pageQuery) {
|
||||||
|
return opsSbLiebiaoService.queryPageList(bo, pageQuery);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出运维-设备管理-设备列列表
|
||||||
|
*/
|
||||||
|
@SaCheckPermission("shebei:sbLiebiao:export")
|
||||||
|
@Log(title = "运维-设备管理-设备列", businessType = BusinessType.EXPORT)
|
||||||
|
@PostMapping("/export")
|
||||||
|
public void export(OpsSbLiebiaoBo bo, HttpServletResponse response) {
|
||||||
|
List<OpsSbLiebiaoVo> list = opsSbLiebiaoService.queryList(bo);
|
||||||
|
ExcelUtil.exportExcel(list, "运维-设备管理-设备列", OpsSbLiebiaoVo.class, response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取运维-设备管理-设备列详细信息
|
||||||
|
*
|
||||||
|
* @param id 主键
|
||||||
|
*/
|
||||||
|
@SaCheckPermission("shebei:sbLiebiao:query")
|
||||||
|
@GetMapping("/{id}")
|
||||||
|
public R<OpsSbLiebiaoVo> getInfo(@NotNull(message = "主键不能为空")
|
||||||
|
@PathVariable("id") Long id) {
|
||||||
|
return R.ok(opsSbLiebiaoService.queryById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增运维-设备管理-设备列
|
||||||
|
*/
|
||||||
|
@SaCheckPermission("shebei:sbLiebiao:add")
|
||||||
|
@Log(title = "运维-设备管理-设备列", businessType = BusinessType.INSERT)
|
||||||
|
@RepeatSubmit()
|
||||||
|
@PostMapping()
|
||||||
|
public R<Void> add(@Validated(AddGroup.class) @RequestBody OpsSbLiebiaoBo bo) {
|
||||||
|
return toAjax(opsSbLiebiaoService.insertByBo(bo));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改运维-设备管理-设备列
|
||||||
|
*/
|
||||||
|
@SaCheckPermission("shebei:sbLiebiao:edit")
|
||||||
|
@Log(title = "运维-设备管理-设备列", businessType = BusinessType.UPDATE)
|
||||||
|
@RepeatSubmit()
|
||||||
|
@PutMapping()
|
||||||
|
public R<Void> edit(@Validated(EditGroup.class) @RequestBody OpsSbLiebiaoBo bo) {
|
||||||
|
return toAjax(opsSbLiebiaoService.updateByBo(bo));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除运维-设备管理-设备列
|
||||||
|
*
|
||||||
|
* @param ids 主键串
|
||||||
|
*/
|
||||||
|
@SaCheckPermission("shebei:sbLiebiao:remove")
|
||||||
|
@Log(title = "运维-设备管理-设备列", businessType = BusinessType.DELETE)
|
||||||
|
@DeleteMapping("/{ids}")
|
||||||
|
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||||
|
@PathVariable("ids") Long[] ids) {
|
||||||
|
return toAjax(opsSbLiebiaoService.deleteWithValidByIds(List.of(ids), true));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,106 @@
|
|||||||
|
package org.dromara.shebei.controller;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import jakarta.validation.constraints.*;
|
||||||
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
||||||
|
import org.dromara.common.log.annotation.Log;
|
||||||
|
import org.dromara.common.web.core.BaseController;
|
||||||
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||||
|
import org.dromara.common.core.domain.R;
|
||||||
|
import org.dromara.common.core.validate.AddGroup;
|
||||||
|
import org.dromara.common.core.validate.EditGroup;
|
||||||
|
import org.dromara.common.log.enums.BusinessType;
|
||||||
|
import org.dromara.common.excel.utils.ExcelUtil;
|
||||||
|
import org.dromara.shebei.domain.vo.OpsSbMbBianliangVo;
|
||||||
|
import org.dromara.shebei.domain.bo.OpsSbMbBianliangBo;
|
||||||
|
import org.dromara.shebei.service.IOpsSbMbBianliangService;
|
||||||
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 运维-设备管理-设备模板-变量
|
||||||
|
* 前端访问路由地址为:/shebei/sbMbBianliang
|
||||||
|
*
|
||||||
|
* @author LionLi
|
||||||
|
* @date 2025-10-09
|
||||||
|
*/
|
||||||
|
@Validated
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/sbMbBianliang")
|
||||||
|
public class OpsSbMbBianliangController extends BaseController {
|
||||||
|
|
||||||
|
private final IOpsSbMbBianliangService opsSbMbBianliangService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询运维-设备管理-设备模板-变量列表
|
||||||
|
*/
|
||||||
|
@SaCheckPermission("shebei:sbMbBianliang:list")
|
||||||
|
@GetMapping("/list")
|
||||||
|
public TableDataInfo<OpsSbMbBianliangVo> list(OpsSbMbBianliangBo bo, PageQuery pageQuery) {
|
||||||
|
return opsSbMbBianliangService.queryPageList(bo, pageQuery);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出运维-设备管理-设备模板-变量列表
|
||||||
|
*/
|
||||||
|
@SaCheckPermission("shebei:sbMbBianliang:export")
|
||||||
|
@Log(title = "运维-设备管理-设备模板-变量", businessType = BusinessType.EXPORT)
|
||||||
|
@PostMapping("/export")
|
||||||
|
public void export(OpsSbMbBianliangBo bo, HttpServletResponse response) {
|
||||||
|
List<OpsSbMbBianliangVo> list = opsSbMbBianliangService.queryList(bo);
|
||||||
|
ExcelUtil.exportExcel(list, "运维-设备管理-设备模板-变量", OpsSbMbBianliangVo.class, response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取运维-设备管理-设备模板-变量详细信息
|
||||||
|
*
|
||||||
|
* @param id 主键
|
||||||
|
*/
|
||||||
|
@SaCheckPermission("shebei:sbMbBianliang:query")
|
||||||
|
@GetMapping("/{id}")
|
||||||
|
public R<OpsSbMbBianliangVo> getInfo(@NotNull(message = "主键不能为空")
|
||||||
|
@PathVariable("id") Long id) {
|
||||||
|
return R.ok(opsSbMbBianliangService.queryById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增运维-设备管理-设备模板-变量
|
||||||
|
*/
|
||||||
|
@SaCheckPermission("shebei:sbMbBianliang:add")
|
||||||
|
@Log(title = "运维-设备管理-设备模板-变量", businessType = BusinessType.INSERT)
|
||||||
|
@RepeatSubmit()
|
||||||
|
@PostMapping()
|
||||||
|
public R<Void> add(@Validated(AddGroup.class) @RequestBody OpsSbMbBianliangBo bo) {
|
||||||
|
return toAjax(opsSbMbBianliangService.insertByBo(bo));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改运维-设备管理-设备模板-变量
|
||||||
|
*/
|
||||||
|
@SaCheckPermission("shebei:sbMbBianliang:edit")
|
||||||
|
@Log(title = "运维-设备管理-设备模板-变量", businessType = BusinessType.UPDATE)
|
||||||
|
@RepeatSubmit()
|
||||||
|
@PutMapping()
|
||||||
|
public R<Void> edit(@Validated(EditGroup.class) @RequestBody OpsSbMbBianliangBo bo) {
|
||||||
|
return toAjax(opsSbMbBianliangService.updateByBo(bo));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除运维-设备管理-设备模板-变量
|
||||||
|
*
|
||||||
|
* @param ids 主键串
|
||||||
|
*/
|
||||||
|
@SaCheckPermission("shebei:sbMbBianliang:remove")
|
||||||
|
@Log(title = "运维-设备管理-设备模板-变量", businessType = BusinessType.DELETE)
|
||||||
|
@DeleteMapping("/{ids}")
|
||||||
|
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||||
|
@PathVariable("ids") Long[] ids) {
|
||||||
|
return toAjax(opsSbMbBianliangService.deleteWithValidByIds(List.of(ids), true));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,106 @@
|
|||||||
|
package org.dromara.shebei.controller;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import jakarta.validation.constraints.*;
|
||||||
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
||||||
|
import org.dromara.common.log.annotation.Log;
|
||||||
|
import org.dromara.common.web.core.BaseController;
|
||||||
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||||
|
import org.dromara.common.core.domain.R;
|
||||||
|
import org.dromara.common.core.validate.AddGroup;
|
||||||
|
import org.dromara.common.core.validate.EditGroup;
|
||||||
|
import org.dromara.common.log.enums.BusinessType;
|
||||||
|
import org.dromara.common.excel.utils.ExcelUtil;
|
||||||
|
import org.dromara.shebei.domain.vo.OpsSbMobanVo;
|
||||||
|
import org.dromara.shebei.domain.bo.OpsSbMobanBo;
|
||||||
|
import org.dromara.shebei.service.IOpsSbMobanService;
|
||||||
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 运维-设备管理-设备模板
|
||||||
|
* 前端访问路由地址为:/shebei/sbMoban
|
||||||
|
*
|
||||||
|
* @author LionLi
|
||||||
|
* @date 2025-10-09
|
||||||
|
*/
|
||||||
|
@Validated
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/sbMoban")
|
||||||
|
public class OpsSbMobanController extends BaseController {
|
||||||
|
|
||||||
|
private final IOpsSbMobanService opsSbMobanService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询运维-设备管理-设备模板列表
|
||||||
|
*/
|
||||||
|
@SaCheckPermission("shebei:sbMoban:list")
|
||||||
|
@GetMapping("/list")
|
||||||
|
public TableDataInfo<OpsSbMobanVo> list(OpsSbMobanBo bo, PageQuery pageQuery) {
|
||||||
|
return opsSbMobanService.queryPageList(bo, pageQuery);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出运维-设备管理-设备模板列表
|
||||||
|
*/
|
||||||
|
@SaCheckPermission("shebei:sbMoban:export")
|
||||||
|
@Log(title = "运维-设备管理-设备模板", businessType = BusinessType.EXPORT)
|
||||||
|
@PostMapping("/export")
|
||||||
|
public void export(OpsSbMobanBo bo, HttpServletResponse response) {
|
||||||
|
List<OpsSbMobanVo> list = opsSbMobanService.queryList(bo);
|
||||||
|
ExcelUtil.exportExcel(list, "运维-设备管理-设备模板", OpsSbMobanVo.class, response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取运维-设备管理-设备模板详细信息
|
||||||
|
*
|
||||||
|
* @param id 主键
|
||||||
|
*/
|
||||||
|
@SaCheckPermission("shebei:sbMoban:query")
|
||||||
|
@GetMapping("/{id}")
|
||||||
|
public R<OpsSbMobanVo> getInfo(@NotNull(message = "主键不能为空")
|
||||||
|
@PathVariable("id") Long id) {
|
||||||
|
return R.ok(opsSbMobanService.queryById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增运维-设备管理-设备模板
|
||||||
|
*/
|
||||||
|
@SaCheckPermission("shebei:sbMoban:add")
|
||||||
|
@Log(title = "运维-设备管理-设备模板", businessType = BusinessType.INSERT)
|
||||||
|
@RepeatSubmit()
|
||||||
|
@PostMapping()
|
||||||
|
public R<Void> add(@Validated(AddGroup.class) @RequestBody OpsSbMobanBo bo) {
|
||||||
|
return toAjax(opsSbMobanService.insertByBo(bo));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改运维-设备管理-设备模板
|
||||||
|
*/
|
||||||
|
@SaCheckPermission("shebei:sbMoban:edit")
|
||||||
|
@Log(title = "运维-设备管理-设备模板", businessType = BusinessType.UPDATE)
|
||||||
|
@RepeatSubmit()
|
||||||
|
@PutMapping()
|
||||||
|
public R<Void> edit(@Validated(EditGroup.class) @RequestBody OpsSbMobanBo bo) {
|
||||||
|
return toAjax(opsSbMobanService.updateByBo(bo));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除运维-设备管理-设备模板
|
||||||
|
*
|
||||||
|
* @param ids 主键串
|
||||||
|
*/
|
||||||
|
@SaCheckPermission("shebei:sbMoban:remove")
|
||||||
|
@Log(title = "运维-设备管理-设备模板", businessType = BusinessType.DELETE)
|
||||||
|
@DeleteMapping("/{ids}")
|
||||||
|
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||||
|
@PathVariable("ids") Long[] ids) {
|
||||||
|
return toAjax(opsSbMobanService.deleteWithValidByIds(List.of(ids), true));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,81 @@
|
|||||||
|
package org.dromara.shebei.domain;
|
||||||
|
|
||||||
|
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||||
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 运维-设备管理-设备列对象 ops_sb_liebiao
|
||||||
|
*
|
||||||
|
* @author LionLi
|
||||||
|
* @date 2025-10-09
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@TableName("ops_sb_liebiao")
|
||||||
|
public class OpsSbLiebiao extends BaseEntity {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* id
|
||||||
|
*/
|
||||||
|
@TableId(value = "id")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 项目id
|
||||||
|
*/
|
||||||
|
private Long projectId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备名称
|
||||||
|
*/
|
||||||
|
private String sbName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件id
|
||||||
|
*/
|
||||||
|
private Long fileId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件地址
|
||||||
|
*/
|
||||||
|
private String fileUrl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sn码
|
||||||
|
*/
|
||||||
|
private String sn;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备描述
|
||||||
|
*/
|
||||||
|
private String sbMiaoshu;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备地址
|
||||||
|
*/
|
||||||
|
private String sbAdd;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模板id
|
||||||
|
*/
|
||||||
|
private Long mbId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从机地址
|
||||||
|
*/
|
||||||
|
private Long slaveId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备状态
|
||||||
|
*/
|
||||||
|
private String sbStatus;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,91 @@
|
|||||||
|
package org.dromara.shebei.domain;
|
||||||
|
|
||||||
|
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||||
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 运维-设备管理-设备模板-变量对象 ops_sb_mb_bianliang
|
||||||
|
*
|
||||||
|
* @author LionLi
|
||||||
|
* @date 2025-10-09
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@TableName("ops_sb_mb_bianliang")
|
||||||
|
public class OpsSbMbBianliang extends BaseEntity {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* id
|
||||||
|
*/
|
||||||
|
@TableId(value = "id")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模板id
|
||||||
|
*/
|
||||||
|
private Long mbId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 变量名称
|
||||||
|
*/
|
||||||
|
private String blName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 变量单位
|
||||||
|
*/
|
||||||
|
private String blDanwei;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 变量标识符
|
||||||
|
*/
|
||||||
|
private String blBiaoshifu;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 变量类型(1、直采变量)
|
||||||
|
*/
|
||||||
|
private String blType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 寄存器功能码
|
||||||
|
*/
|
||||||
|
private String jicunqiGnm;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 寄存器地址
|
||||||
|
*/
|
||||||
|
private String jicunqiAdd;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据格式
|
||||||
|
*/
|
||||||
|
private String shujvGeshi;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 采集频率
|
||||||
|
*/
|
||||||
|
private String caijiPinlu;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数字格式
|
||||||
|
*/
|
||||||
|
private String shuziGeshi;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 存储方式(1、变化存储,2、全部存储)
|
||||||
|
*/
|
||||||
|
private String cunchuFangshi;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 读写方式(1、读写,3、只读,5、只写)
|
||||||
|
*/
|
||||||
|
private String duxieFangshi;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,51 @@
|
|||||||
|
package org.dromara.shebei.domain;
|
||||||
|
|
||||||
|
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||||
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 运维-设备管理-设备模板对象 ops_sb_moban
|
||||||
|
*
|
||||||
|
* @author LionLi
|
||||||
|
* @date 2025-10-09
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@TableName("ops_sb_moban")
|
||||||
|
public class OpsSbMoban extends BaseEntity {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* id
|
||||||
|
*/
|
||||||
|
@TableId(value = "id")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 项目id
|
||||||
|
*/
|
||||||
|
private Long projectId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模板名称
|
||||||
|
*/
|
||||||
|
private String mbName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 变量数
|
||||||
|
*/
|
||||||
|
private Long blCount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关联设备数
|
||||||
|
*/
|
||||||
|
private Long sbCount;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,88 @@
|
|||||||
|
package org.dromara.shebei.domain.bo;
|
||||||
|
|
||||||
|
import org.dromara.shebei.domain.OpsSbLiebiao;
|
||||||
|
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||||
|
import org.dromara.common.core.validate.AddGroup;
|
||||||
|
import org.dromara.common.core.validate.EditGroup;
|
||||||
|
import io.github.linpeilie.annotations.AutoMapper;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import jakarta.validation.constraints.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 运维-设备管理-设备列业务对象 ops_sb_liebiao
|
||||||
|
*
|
||||||
|
* @author LionLi
|
||||||
|
* @date 2025-10-09
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@AutoMapper(target = OpsSbLiebiao.class, reverseConvertGenerate = false)
|
||||||
|
public class OpsSbLiebiaoBo extends BaseEntity {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* id
|
||||||
|
*/
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 项目id
|
||||||
|
*/
|
||||||
|
private Long projectId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备名称
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "设备名称不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||||
|
private String sbName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件id
|
||||||
|
*/
|
||||||
|
@NotNull(message = "文件id不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||||
|
private Long fileId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件地址
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "文件地址不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||||
|
private String fileUrl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sn码
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "sn码不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||||
|
private String sn;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备描述
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "设备描述不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||||
|
private String sbMiaoshu;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备地址
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "设备地址不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||||
|
private String sbAdd;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模板id
|
||||||
|
*/
|
||||||
|
@NotNull(message = "模板id不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||||
|
private Long mbId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从机地址
|
||||||
|
*/
|
||||||
|
@NotNull(message = "从机地址不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||||
|
private Long slaveId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备状态
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "设备状态不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||||
|
private String sbStatus;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,100 @@
|
|||||||
|
package org.dromara.shebei.domain.bo;
|
||||||
|
|
||||||
|
import org.dromara.shebei.domain.OpsSbMbBianliang;
|
||||||
|
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||||
|
import org.dromara.common.core.validate.AddGroup;
|
||||||
|
import org.dromara.common.core.validate.EditGroup;
|
||||||
|
import io.github.linpeilie.annotations.AutoMapper;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import jakarta.validation.constraints.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 运维-设备管理-设备模板-变量业务对象 ops_sb_mb_bianliang
|
||||||
|
*
|
||||||
|
* @author LionLi
|
||||||
|
* @date 2025-10-09
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@AutoMapper(target = OpsSbMbBianliang.class, reverseConvertGenerate = false)
|
||||||
|
public class OpsSbMbBianliangBo extends BaseEntity {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* id
|
||||||
|
*/
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模板id
|
||||||
|
*/
|
||||||
|
private Long mbId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 变量名称
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "变量名称不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||||
|
private String blName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 变量单位
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "变量单位不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||||
|
private String blDanwei;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 变量标识符
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "变量标识符不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||||
|
private String blBiaoshifu;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 变量类型(1、直采变量)
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "变量类型(1、直采变量)不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||||
|
private String blType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 寄存器功能码
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "寄存器功能码不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||||
|
private String jicunqiGnm;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 寄存器地址
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "寄存器地址不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||||
|
private String jicunqiAdd;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据格式
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "数据格式不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||||
|
private String shujvGeshi;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 采集频率
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "采集频率不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||||
|
private String caijiPinlu;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数字格式
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "数字格式不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||||
|
private String shuziGeshi;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 存储方式(1、变化存储,2、全部存储)
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "存储方式(1、变化存储,2、全部存储)不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||||
|
private String cunchuFangshi;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 读写方式(1、读写,3、只读,5、只写)
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "读写方式(1、读写,3、只读,5、只写)不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||||
|
private String duxieFangshi;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,52 @@
|
|||||||
|
package org.dromara.shebei.domain.bo;
|
||||||
|
|
||||||
|
import org.dromara.shebei.domain.OpsSbMoban;
|
||||||
|
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||||
|
import org.dromara.common.core.validate.AddGroup;
|
||||||
|
import org.dromara.common.core.validate.EditGroup;
|
||||||
|
import io.github.linpeilie.annotations.AutoMapper;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import jakarta.validation.constraints.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 运维-设备管理-设备模板业务对象 ops_sb_moban
|
||||||
|
*
|
||||||
|
* @author LionLi
|
||||||
|
* @date 2025-10-09
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@AutoMapper(target = OpsSbMoban.class, reverseConvertGenerate = false)
|
||||||
|
public class OpsSbMobanBo extends BaseEntity {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* id
|
||||||
|
*/
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 项目id
|
||||||
|
*/
|
||||||
|
private Long projectId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模板名称
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "模板名称不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||||
|
private String mbName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 变量数
|
||||||
|
*/
|
||||||
|
@NotNull(message = "变量数不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||||
|
private Long blCount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关联设备数
|
||||||
|
*/
|
||||||
|
@NotNull(message = "关联设备数不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||||
|
private Long sbCount;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,86 @@
|
|||||||
|
package org.dromara.shebei.domain.dto;
|
||||||
|
|
||||||
|
import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
|
||||||
|
import cn.idev.excel.annotation.ExcelProperty;
|
||||||
|
import io.github.linpeilie.annotations.AutoMapper;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.dromara.shebei.domain.OpsSbLiebiao;
|
||||||
|
import org.dromara.shebei.domain.vo.OpsSbMbBianliangVo;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 运维-设备管理-设备列视图对象 ops_sb_liebiao
|
||||||
|
*
|
||||||
|
* @author LionLi
|
||||||
|
* @date 2025-10-09
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class OpsSbLiebiaoDto implements Serializable {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* id
|
||||||
|
*/
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 项目id
|
||||||
|
*/
|
||||||
|
private Long projectId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备名称
|
||||||
|
*/
|
||||||
|
private String sbName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件id
|
||||||
|
*/
|
||||||
|
private Long fileId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件地址
|
||||||
|
*/
|
||||||
|
private String fileUrl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sn码
|
||||||
|
*/
|
||||||
|
private String sn;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备描述
|
||||||
|
*/
|
||||||
|
private String sbMiaoshu;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备地址
|
||||||
|
*/
|
||||||
|
private String sbAdd;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模板id
|
||||||
|
*/
|
||||||
|
private Long mbId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从机地址
|
||||||
|
*/
|
||||||
|
private Long slaveId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备状态
|
||||||
|
*/
|
||||||
|
private String sbStatus;
|
||||||
|
|
||||||
|
private List<OpsSbMbBianliangVo> sbMbBianliangVos = new ArrayList<>();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,98 @@
|
|||||||
|
package org.dromara.shebei.domain.vo;
|
||||||
|
|
||||||
|
import org.dromara.shebei.domain.OpsSbLiebiao;
|
||||||
|
import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
|
||||||
|
import cn.idev.excel.annotation.ExcelProperty;
|
||||||
|
import org.dromara.common.excel.annotation.ExcelDictFormat;
|
||||||
|
import org.dromara.common.excel.convert.ExcelDictConvert;
|
||||||
|
import io.github.linpeilie.annotations.AutoMapper;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 运维-设备管理-设备列视图对象 ops_sb_liebiao
|
||||||
|
*
|
||||||
|
* @author LionLi
|
||||||
|
* @date 2025-10-09
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@ExcelIgnoreUnannotated
|
||||||
|
@AutoMapper(target = OpsSbLiebiao.class)
|
||||||
|
public class OpsSbLiebiaoVo implements Serializable {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* id
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "id")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 项目id
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "项目id")
|
||||||
|
private Long projectId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备名称
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "设备名称")
|
||||||
|
private String sbName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件id
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "文件id")
|
||||||
|
private Long fileId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件地址
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "文件地址")
|
||||||
|
private String fileUrl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sn码
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "sn码")
|
||||||
|
private String sn;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备描述
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "设备描述")
|
||||||
|
private String sbMiaoshu;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备地址
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "设备地址")
|
||||||
|
private String sbAdd;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模板id
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "模板id")
|
||||||
|
private Long mbId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从机地址
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "从机地址")
|
||||||
|
private Long slaveId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备状态
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "设备状态")
|
||||||
|
private String sbStatus;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,113 @@
|
|||||||
|
package org.dromara.shebei.domain.vo;
|
||||||
|
|
||||||
|
import org.dromara.shebei.domain.OpsSbMbBianliang;
|
||||||
|
import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
|
||||||
|
import cn.idev.excel.annotation.ExcelProperty;
|
||||||
|
import org.dromara.common.excel.annotation.ExcelDictFormat;
|
||||||
|
import org.dromara.common.excel.convert.ExcelDictConvert;
|
||||||
|
import io.github.linpeilie.annotations.AutoMapper;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 运维-设备管理-设备模板-变量视图对象 ops_sb_mb_bianliang
|
||||||
|
*
|
||||||
|
* @author LionLi
|
||||||
|
* @date 2025-10-09
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@ExcelIgnoreUnannotated
|
||||||
|
@AutoMapper(target = OpsSbMbBianliang.class)
|
||||||
|
public class OpsSbMbBianliangVo implements Serializable {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* id
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "id")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模板id
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "模板id")
|
||||||
|
private Long mbId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 变量名称
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "变量名称")
|
||||||
|
private String blName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 变量单位
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "变量单位")
|
||||||
|
private String blDanwei;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 变量标识符
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "变量标识符")
|
||||||
|
private String blBiaoshifu;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 变量类型(1、直采变量)
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "变量类型", converter = ExcelDictConvert.class)
|
||||||
|
@ExcelDictFormat(readConverterExp = "1=、直采变量")
|
||||||
|
private String blType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 寄存器功能码
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "寄存器功能码")
|
||||||
|
private String jicunqiGnm;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 寄存器地址
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "寄存器地址")
|
||||||
|
private String jicunqiAdd;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据格式
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "数据格式")
|
||||||
|
private String shujvGeshi;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 采集频率
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "采集频率")
|
||||||
|
private String caijiPinlu;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数字格式
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "数字格式")
|
||||||
|
private String shuziGeshi;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 存储方式(1、变化存储,2、全部存储)
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "存储方式", converter = ExcelDictConvert.class)
|
||||||
|
@ExcelDictFormat(readConverterExp = "1=、变化存储,2、全部存储")
|
||||||
|
private String cunchuFangshi;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 读写方式(1、读写,3、只读,5、只写)
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "读写方式", converter = ExcelDictConvert.class)
|
||||||
|
@ExcelDictFormat(readConverterExp = "1=、读写,3、只读,5、只写")
|
||||||
|
private String duxieFangshi;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,62 @@
|
|||||||
|
package org.dromara.shebei.domain.vo;
|
||||||
|
|
||||||
|
import org.dromara.shebei.domain.OpsSbMoban;
|
||||||
|
import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
|
||||||
|
import cn.idev.excel.annotation.ExcelProperty;
|
||||||
|
import org.dromara.common.excel.annotation.ExcelDictFormat;
|
||||||
|
import org.dromara.common.excel.convert.ExcelDictConvert;
|
||||||
|
import io.github.linpeilie.annotations.AutoMapper;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 运维-设备管理-设备模板视图对象 ops_sb_moban
|
||||||
|
*
|
||||||
|
* @author LionLi
|
||||||
|
* @date 2025-10-09
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@ExcelIgnoreUnannotated
|
||||||
|
@AutoMapper(target = OpsSbMoban.class)
|
||||||
|
public class OpsSbMobanVo implements Serializable {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* id
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "id")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 项目id
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "项目id")
|
||||||
|
private Long projectId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模板名称
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "模板名称")
|
||||||
|
private String mbName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 变量数
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "变量数")
|
||||||
|
private Long blCount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关联设备数
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "关联设备数")
|
||||||
|
private Long sbCount;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
package org.dromara.shebei.mapper;
|
||||||
|
|
||||||
|
import org.dromara.shebei.domain.OpsSbLiebiao;
|
||||||
|
import org.dromara.shebei.domain.vo.OpsSbLiebiaoVo;
|
||||||
|
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 运维-设备管理-设备列Mapper接口
|
||||||
|
*
|
||||||
|
* @author LionLi
|
||||||
|
* @date 2025-10-09
|
||||||
|
*/
|
||||||
|
public interface OpsSbLiebiaoMapper extends BaseMapperPlus<OpsSbLiebiao, OpsSbLiebiaoVo> {
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
package org.dromara.shebei.mapper;
|
||||||
|
|
||||||
|
import org.dromara.shebei.domain.OpsSbMbBianliang;
|
||||||
|
import org.dromara.shebei.domain.vo.OpsSbMbBianliangVo;
|
||||||
|
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 运维-设备管理-设备模板-变量Mapper接口
|
||||||
|
*
|
||||||
|
* @author LionLi
|
||||||
|
* @date 2025-10-09
|
||||||
|
*/
|
||||||
|
public interface OpsSbMbBianliangMapper extends BaseMapperPlus<OpsSbMbBianliang, OpsSbMbBianliangVo> {
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
package org.dromara.shebei.mapper;
|
||||||
|
|
||||||
|
import org.dromara.shebei.domain.OpsSbMoban;
|
||||||
|
import org.dromara.shebei.domain.vo.OpsSbMobanVo;
|
||||||
|
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 运维-设备管理-设备模板Mapper接口
|
||||||
|
*
|
||||||
|
* @author LionLi
|
||||||
|
* @date 2025-10-09
|
||||||
|
*/
|
||||||
|
public interface OpsSbMobanMapper extends BaseMapperPlus<OpsSbMoban, OpsSbMobanVo> {
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,74 @@
|
|||||||
|
package org.dromara.shebei.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import org.dromara.personnel.domain.OpsBeipinBeijian;
|
||||||
|
import org.dromara.shebei.domain.OpsSbLiebiao;
|
||||||
|
import org.dromara.shebei.domain.dto.OpsSbLiebiaoDto;
|
||||||
|
import org.dromara.shebei.domain.vo.OpsSbLiebiaoVo;
|
||||||
|
import org.dromara.shebei.domain.bo.OpsSbLiebiaoBo;
|
||||||
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||||
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 运维-设备管理-设备列Service接口
|
||||||
|
*
|
||||||
|
* @author LionLi
|
||||||
|
* @date 2025-10-09
|
||||||
|
*/
|
||||||
|
public interface IOpsSbLiebiaoService extends IService<OpsSbLiebiao> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询运维-设备管理-设备列
|
||||||
|
*
|
||||||
|
* @param id 主键
|
||||||
|
* @return 运维-设备管理-设备列
|
||||||
|
*/
|
||||||
|
OpsSbLiebiaoVo queryById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询运维-设备管理-设备列列表
|
||||||
|
*
|
||||||
|
* @param bo 查询条件
|
||||||
|
* @param pageQuery 分页参数
|
||||||
|
* @return 运维-设备管理-设备列分页列表
|
||||||
|
*/
|
||||||
|
TableDataInfo<OpsSbLiebiaoVo> queryPageList(OpsSbLiebiaoBo bo, PageQuery pageQuery);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询符合条件的运维-设备管理-设备列列表
|
||||||
|
*
|
||||||
|
* @param bo 查询条件
|
||||||
|
* @return 运维-设备管理-设备列列表
|
||||||
|
*/
|
||||||
|
List<OpsSbLiebiaoVo> queryList(OpsSbLiebiaoBo bo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增运维-设备管理-设备列
|
||||||
|
*
|
||||||
|
* @param bo 运维-设备管理-设备列
|
||||||
|
* @return 是否新增成功
|
||||||
|
*/
|
||||||
|
Boolean insertByBo(OpsSbLiebiaoBo bo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改运维-设备管理-设备列
|
||||||
|
*
|
||||||
|
* @param bo 运维-设备管理-设备列
|
||||||
|
* @return 是否修改成功
|
||||||
|
*/
|
||||||
|
Boolean updateByBo(OpsSbLiebiaoBo bo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验并批量删除运维-设备管理-设备列信息
|
||||||
|
*
|
||||||
|
* @param ids 待删除的主键集合
|
||||||
|
* @param isValid 是否进行有效性校验
|
||||||
|
* @return 是否删除成功
|
||||||
|
*/
|
||||||
|
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||||
|
|
||||||
|
OpsSbLiebiaoDto getLiebiaoBianliangList(String snCode);
|
||||||
|
}
|
||||||
@ -0,0 +1,71 @@
|
|||||||
|
package org.dromara.shebei.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import org.dromara.personnel.domain.OpsBeipinBeijian;
|
||||||
|
import org.dromara.shebei.domain.OpsSbMbBianliang;
|
||||||
|
import org.dromara.shebei.domain.vo.OpsSbMbBianliangVo;
|
||||||
|
import org.dromara.shebei.domain.bo.OpsSbMbBianliangBo;
|
||||||
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||||
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 运维-设备管理-设备模板-变量Service接口
|
||||||
|
*
|
||||||
|
* @author LionLi
|
||||||
|
* @date 2025-10-09
|
||||||
|
*/
|
||||||
|
public interface IOpsSbMbBianliangService extends IService<OpsSbMbBianliang> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询运维-设备管理-设备模板-变量
|
||||||
|
*
|
||||||
|
* @param id 主键
|
||||||
|
* @return 运维-设备管理-设备模板-变量
|
||||||
|
*/
|
||||||
|
OpsSbMbBianliangVo queryById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询运维-设备管理-设备模板-变量列表
|
||||||
|
*
|
||||||
|
* @param bo 查询条件
|
||||||
|
* @param pageQuery 分页参数
|
||||||
|
* @return 运维-设备管理-设备模板-变量分页列表
|
||||||
|
*/
|
||||||
|
TableDataInfo<OpsSbMbBianliangVo> queryPageList(OpsSbMbBianliangBo bo, PageQuery pageQuery);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询符合条件的运维-设备管理-设备模板-变量列表
|
||||||
|
*
|
||||||
|
* @param bo 查询条件
|
||||||
|
* @return 运维-设备管理-设备模板-变量列表
|
||||||
|
*/
|
||||||
|
List<OpsSbMbBianliangVo> queryList(OpsSbMbBianliangBo bo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增运维-设备管理-设备模板-变量
|
||||||
|
*
|
||||||
|
* @param bo 运维-设备管理-设备模板-变量
|
||||||
|
* @return 是否新增成功
|
||||||
|
*/
|
||||||
|
Boolean insertByBo(OpsSbMbBianliangBo bo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改运维-设备管理-设备模板-变量
|
||||||
|
*
|
||||||
|
* @param bo 运维-设备管理-设备模板-变量
|
||||||
|
* @return 是否修改成功
|
||||||
|
*/
|
||||||
|
Boolean updateByBo(OpsSbMbBianliangBo bo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验并批量删除运维-设备管理-设备模板-变量信息
|
||||||
|
*
|
||||||
|
* @param ids 待删除的主键集合
|
||||||
|
* @param isValid 是否进行有效性校验
|
||||||
|
* @return 是否删除成功
|
||||||
|
*/
|
||||||
|
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||||
|
}
|
||||||
@ -0,0 +1,70 @@
|
|||||||
|
package org.dromara.shebei.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import org.dromara.shebei.domain.OpsSbMoban;
|
||||||
|
import org.dromara.shebei.domain.vo.OpsSbMobanVo;
|
||||||
|
import org.dromara.shebei.domain.bo.OpsSbMobanBo;
|
||||||
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||||
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 运维-设备管理-设备模板Service接口
|
||||||
|
*
|
||||||
|
* @author LionLi
|
||||||
|
* @date 2025-10-09
|
||||||
|
*/
|
||||||
|
public interface IOpsSbMobanService extends IService<OpsSbMoban> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询运维-设备管理-设备模板
|
||||||
|
*
|
||||||
|
* @param id 主键
|
||||||
|
* @return 运维-设备管理-设备模板
|
||||||
|
*/
|
||||||
|
OpsSbMobanVo queryById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询运维-设备管理-设备模板列表
|
||||||
|
*
|
||||||
|
* @param bo 查询条件
|
||||||
|
* @param pageQuery 分页参数
|
||||||
|
* @return 运维-设备管理-设备模板分页列表
|
||||||
|
*/
|
||||||
|
TableDataInfo<OpsSbMobanVo> queryPageList(OpsSbMobanBo bo, PageQuery pageQuery);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询符合条件的运维-设备管理-设备模板列表
|
||||||
|
*
|
||||||
|
* @param bo 查询条件
|
||||||
|
* @return 运维-设备管理-设备模板列表
|
||||||
|
*/
|
||||||
|
List<OpsSbMobanVo> queryList(OpsSbMobanBo bo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增运维-设备管理-设备模板
|
||||||
|
*
|
||||||
|
* @param bo 运维-设备管理-设备模板
|
||||||
|
* @return 是否新增成功
|
||||||
|
*/
|
||||||
|
Boolean insertByBo(OpsSbMobanBo bo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改运维-设备管理-设备模板
|
||||||
|
*
|
||||||
|
* @param bo 运维-设备管理-设备模板
|
||||||
|
* @return 是否修改成功
|
||||||
|
*/
|
||||||
|
Boolean updateByBo(OpsSbMobanBo bo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验并批量删除运维-设备管理-设备模板信息
|
||||||
|
*
|
||||||
|
* @param ids 待删除的主键集合
|
||||||
|
* @param isValid 是否进行有效性校验
|
||||||
|
* @return 是否删除成功
|
||||||
|
*/
|
||||||
|
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||||
|
}
|
||||||
@ -0,0 +1,170 @@
|
|||||||
|
package org.dromara.shebei.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import org.dromara.common.core.utils.MapstructUtils;
|
||||||
|
import org.dromara.common.core.utils.StringUtils;
|
||||||
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||||
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.dromara.personnel.domain.OpsBeipinBeijian;
|
||||||
|
import org.dromara.personnel.mapper.OpsBeipinBeijianMapper;
|
||||||
|
import org.dromara.shebei.domain.OpsSbMbBianliang;
|
||||||
|
import org.dromara.shebei.domain.dto.OpsSbLiebiaoDto;
|
||||||
|
import org.dromara.shebei.domain.vo.OpsSbMbBianliangVo;
|
||||||
|
import org.dromara.shebei.service.IOpsSbMbBianliangService;
|
||||||
|
import org.dromara.shebei.service.IOpsSbMobanService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.dromara.shebei.domain.bo.OpsSbLiebiaoBo;
|
||||||
|
import org.dromara.shebei.domain.vo.OpsSbLiebiaoVo;
|
||||||
|
import org.dromara.shebei.domain.OpsSbLiebiao;
|
||||||
|
import org.dromara.shebei.mapper.OpsSbLiebiaoMapper;
|
||||||
|
import org.dromara.shebei.service.IOpsSbLiebiaoService;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 运维-设备管理-设备列Service业务层处理
|
||||||
|
*
|
||||||
|
* @author LionLi
|
||||||
|
* @date 2025-10-09
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@Service
|
||||||
|
public class OpsSbLiebiaoServiceImpl extends ServiceImpl<OpsSbLiebiaoMapper, OpsSbLiebiao> implements IOpsSbLiebiaoService {
|
||||||
|
|
||||||
|
private final OpsSbLiebiaoMapper baseMapper;
|
||||||
|
private final IOpsSbMbBianliangService mbBianliangService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询运维-设备管理-设备列
|
||||||
|
*
|
||||||
|
* @param id 主键
|
||||||
|
* @return 运维-设备管理-设备列
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public OpsSbLiebiaoVo queryById(Long id){
|
||||||
|
return baseMapper.selectVoById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询运维-设备管理-设备列列表
|
||||||
|
*
|
||||||
|
* @param bo 查询条件
|
||||||
|
* @param pageQuery 分页参数
|
||||||
|
* @return 运维-设备管理-设备列分页列表
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public TableDataInfo<OpsSbLiebiaoVo> queryPageList(OpsSbLiebiaoBo bo, PageQuery pageQuery) {
|
||||||
|
LambdaQueryWrapper<OpsSbLiebiao> lqw = buildQueryWrapper(bo);
|
||||||
|
Page<OpsSbLiebiaoVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||||
|
return TableDataInfo.build(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询符合条件的运维-设备管理-设备列列表
|
||||||
|
*
|
||||||
|
* @param bo 查询条件
|
||||||
|
* @return 运维-设备管理-设备列列表
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<OpsSbLiebiaoVo> queryList(OpsSbLiebiaoBo bo) {
|
||||||
|
LambdaQueryWrapper<OpsSbLiebiao> lqw = buildQueryWrapper(bo);
|
||||||
|
return baseMapper.selectVoList(lqw);
|
||||||
|
}
|
||||||
|
|
||||||
|
private LambdaQueryWrapper<OpsSbLiebiao> buildQueryWrapper(OpsSbLiebiaoBo bo) {
|
||||||
|
Map<String, Object> params = bo.getParams();
|
||||||
|
LambdaQueryWrapper<OpsSbLiebiao> lqw = Wrappers.lambdaQuery();
|
||||||
|
lqw.orderByAsc(OpsSbLiebiao::getId);
|
||||||
|
lqw.eq(bo.getProjectId() != null, OpsSbLiebiao::getProjectId, bo.getProjectId());
|
||||||
|
lqw.like(StringUtils.isNotBlank(bo.getSbName()), OpsSbLiebiao::getSbName, bo.getSbName());
|
||||||
|
lqw.eq(bo.getFileId() != null, OpsSbLiebiao::getFileId, bo.getFileId());
|
||||||
|
lqw.eq(StringUtils.isNotBlank(bo.getFileUrl()), OpsSbLiebiao::getFileUrl, bo.getFileUrl());
|
||||||
|
lqw.eq(StringUtils.isNotBlank(bo.getSn()), OpsSbLiebiao::getSn, bo.getSn());
|
||||||
|
lqw.eq(StringUtils.isNotBlank(bo.getSbMiaoshu()), OpsSbLiebiao::getSbMiaoshu, bo.getSbMiaoshu());
|
||||||
|
lqw.eq(StringUtils.isNotBlank(bo.getSbAdd()), OpsSbLiebiao::getSbAdd, bo.getSbAdd());
|
||||||
|
lqw.eq(bo.getMbId() != null, OpsSbLiebiao::getMbId, bo.getMbId());
|
||||||
|
lqw.eq(bo.getSlaveId() != null, OpsSbLiebiao::getSlaveId, bo.getSlaveId());
|
||||||
|
lqw.eq(StringUtils.isNotBlank(bo.getSbStatus()), OpsSbLiebiao::getSbStatus, bo.getSbStatus());
|
||||||
|
return lqw;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增运维-设备管理-设备列
|
||||||
|
*
|
||||||
|
* @param bo 运维-设备管理-设备列
|
||||||
|
* @return 是否新增成功
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Boolean insertByBo(OpsSbLiebiaoBo bo) {
|
||||||
|
OpsSbLiebiao add = MapstructUtils.convert(bo, OpsSbLiebiao.class);
|
||||||
|
validEntityBeforeSave(add);
|
||||||
|
boolean flag = baseMapper.insert(add) > 0;
|
||||||
|
if (flag) {
|
||||||
|
bo.setId(add.getId());
|
||||||
|
}
|
||||||
|
return flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改运维-设备管理-设备列
|
||||||
|
*
|
||||||
|
* @param bo 运维-设备管理-设备列
|
||||||
|
* @return 是否修改成功
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Boolean updateByBo(OpsSbLiebiaoBo bo) {
|
||||||
|
OpsSbLiebiao update = MapstructUtils.convert(bo, OpsSbLiebiao.class);
|
||||||
|
validEntityBeforeSave(update);
|
||||||
|
return baseMapper.updateById(update) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存前的数据校验
|
||||||
|
*/
|
||||||
|
private void validEntityBeforeSave(OpsSbLiebiao entity){
|
||||||
|
//TODO 做一些数据校验,如唯一约束
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验并批量删除运维-设备管理-设备列信息
|
||||||
|
*
|
||||||
|
* @param ids 待删除的主键集合
|
||||||
|
* @param isValid 是否进行有效性校验
|
||||||
|
* @return 是否删除成功
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||||
|
if(isValid){
|
||||||
|
//TODO 做一些业务上的校验,判断是否需要校验
|
||||||
|
}
|
||||||
|
return baseMapper.deleteByIds(ids) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OpsSbLiebiaoDto getLiebiaoBianliangList(String snCode) {
|
||||||
|
if (StrUtil.isBlank(snCode)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
OpsSbLiebiao opsSbLiebiao = baseMapper.selectOne(new LambdaQueryWrapper<OpsSbLiebiao>().eq(OpsSbLiebiao::getSn, snCode));
|
||||||
|
if (opsSbLiebiao == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
OpsSbLiebiaoDto opsSbLiebiaoDto = BeanUtil.copyProperties(opsSbLiebiao, OpsSbLiebiaoDto.class);
|
||||||
|
List<OpsSbMbBianliang> opsSbMbBianliangs = mbBianliangService.getBaseMapper().selectList(new LambdaQueryWrapper<OpsSbMbBianliang>().eq(OpsSbMbBianliang::getMbId, opsSbLiebiaoDto.getMbId()));
|
||||||
|
if (opsSbMbBianliangs != null && !opsSbMbBianliangs.isEmpty()) {
|
||||||
|
List<OpsSbMbBianliangVo> opsSbMbBianliangVos = BeanUtil.copyToList(opsSbMbBianliangs, OpsSbMbBianliangVo.class);
|
||||||
|
opsSbLiebiaoDto.setSbMbBianliangVos(opsSbMbBianliangVos);
|
||||||
|
}
|
||||||
|
return opsSbLiebiaoDto;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,146 @@
|
|||||||
|
package org.dromara.shebei.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import org.dromara.common.core.utils.MapstructUtils;
|
||||||
|
import org.dromara.common.core.utils.StringUtils;
|
||||||
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||||
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.dromara.shebei.domain.OpsSbLiebiao;
|
||||||
|
import org.dromara.shebei.mapper.OpsSbLiebiaoMapper;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.dromara.shebei.domain.bo.OpsSbMbBianliangBo;
|
||||||
|
import org.dromara.shebei.domain.vo.OpsSbMbBianliangVo;
|
||||||
|
import org.dromara.shebei.domain.OpsSbMbBianliang;
|
||||||
|
import org.dromara.shebei.mapper.OpsSbMbBianliangMapper;
|
||||||
|
import org.dromara.shebei.service.IOpsSbMbBianliangService;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 运维-设备管理-设备模板-变量Service业务层处理
|
||||||
|
*
|
||||||
|
* @author LionLi
|
||||||
|
* @date 2025-10-09
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@Service
|
||||||
|
public class OpsSbMbBianliangServiceImpl extends ServiceImpl<OpsSbMbBianliangMapper, OpsSbMbBianliang> implements IOpsSbMbBianliangService {
|
||||||
|
|
||||||
|
private final OpsSbMbBianliangMapper baseMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询运维-设备管理-设备模板-变量
|
||||||
|
*
|
||||||
|
* @param id 主键
|
||||||
|
* @return 运维-设备管理-设备模板-变量
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public OpsSbMbBianliangVo queryById(Long id){
|
||||||
|
return baseMapper.selectVoById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询运维-设备管理-设备模板-变量列表
|
||||||
|
*
|
||||||
|
* @param bo 查询条件
|
||||||
|
* @param pageQuery 分页参数
|
||||||
|
* @return 运维-设备管理-设备模板-变量分页列表
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public TableDataInfo<OpsSbMbBianliangVo> queryPageList(OpsSbMbBianliangBo bo, PageQuery pageQuery) {
|
||||||
|
LambdaQueryWrapper<OpsSbMbBianliang> lqw = buildQueryWrapper(bo);
|
||||||
|
Page<OpsSbMbBianliangVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||||
|
return TableDataInfo.build(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询符合条件的运维-设备管理-设备模板-变量列表
|
||||||
|
*
|
||||||
|
* @param bo 查询条件
|
||||||
|
* @return 运维-设备管理-设备模板-变量列表
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<OpsSbMbBianliangVo> queryList(OpsSbMbBianliangBo bo) {
|
||||||
|
LambdaQueryWrapper<OpsSbMbBianliang> lqw = buildQueryWrapper(bo);
|
||||||
|
return baseMapper.selectVoList(lqw);
|
||||||
|
}
|
||||||
|
|
||||||
|
private LambdaQueryWrapper<OpsSbMbBianliang> buildQueryWrapper(OpsSbMbBianliangBo bo) {
|
||||||
|
Map<String, Object> params = bo.getParams();
|
||||||
|
LambdaQueryWrapper<OpsSbMbBianliang> lqw = Wrappers.lambdaQuery();
|
||||||
|
lqw.orderByAsc(OpsSbMbBianliang::getId);
|
||||||
|
lqw.eq(bo.getMbId() != null, OpsSbMbBianliang::getMbId, bo.getMbId());
|
||||||
|
lqw.like(StringUtils.isNotBlank(bo.getBlName()), OpsSbMbBianliang::getBlName, bo.getBlName());
|
||||||
|
lqw.eq(StringUtils.isNotBlank(bo.getBlDanwei()), OpsSbMbBianliang::getBlDanwei, bo.getBlDanwei());
|
||||||
|
lqw.eq(StringUtils.isNotBlank(bo.getBlBiaoshifu()), OpsSbMbBianliang::getBlBiaoshifu, bo.getBlBiaoshifu());
|
||||||
|
lqw.eq(StringUtils.isNotBlank(bo.getBlType()), OpsSbMbBianliang::getBlType, bo.getBlType());
|
||||||
|
lqw.eq(StringUtils.isNotBlank(bo.getJicunqiGnm()), OpsSbMbBianliang::getJicunqiGnm, bo.getJicunqiGnm());
|
||||||
|
lqw.eq(StringUtils.isNotBlank(bo.getJicunqiAdd()), OpsSbMbBianliang::getJicunqiAdd, bo.getJicunqiAdd());
|
||||||
|
lqw.eq(StringUtils.isNotBlank(bo.getShujvGeshi()), OpsSbMbBianliang::getShujvGeshi, bo.getShujvGeshi());
|
||||||
|
lqw.eq(StringUtils.isNotBlank(bo.getCaijiPinlu()), OpsSbMbBianliang::getCaijiPinlu, bo.getCaijiPinlu());
|
||||||
|
lqw.eq(StringUtils.isNotBlank(bo.getShuziGeshi()), OpsSbMbBianliang::getShuziGeshi, bo.getShuziGeshi());
|
||||||
|
lqw.eq(StringUtils.isNotBlank(bo.getCunchuFangshi()), OpsSbMbBianliang::getCunchuFangshi, bo.getCunchuFangshi());
|
||||||
|
lqw.eq(StringUtils.isNotBlank(bo.getDuxieFangshi()), OpsSbMbBianliang::getDuxieFangshi, bo.getDuxieFangshi());
|
||||||
|
return lqw;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增运维-设备管理-设备模板-变量
|
||||||
|
*
|
||||||
|
* @param bo 运维-设备管理-设备模板-变量
|
||||||
|
* @return 是否新增成功
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Boolean insertByBo(OpsSbMbBianliangBo bo) {
|
||||||
|
OpsSbMbBianliang add = MapstructUtils.convert(bo, OpsSbMbBianliang.class);
|
||||||
|
validEntityBeforeSave(add);
|
||||||
|
boolean flag = baseMapper.insert(add) > 0;
|
||||||
|
if (flag) {
|
||||||
|
bo.setId(add.getId());
|
||||||
|
}
|
||||||
|
return flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改运维-设备管理-设备模板-变量
|
||||||
|
*
|
||||||
|
* @param bo 运维-设备管理-设备模板-变量
|
||||||
|
* @return 是否修改成功
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Boolean updateByBo(OpsSbMbBianliangBo bo) {
|
||||||
|
OpsSbMbBianliang update = MapstructUtils.convert(bo, OpsSbMbBianliang.class);
|
||||||
|
validEntityBeforeSave(update);
|
||||||
|
return baseMapper.updateById(update) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存前的数据校验
|
||||||
|
*/
|
||||||
|
private void validEntityBeforeSave(OpsSbMbBianliang entity){
|
||||||
|
//TODO 做一些数据校验,如唯一约束
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验并批量删除运维-设备管理-设备模板-变量信息
|
||||||
|
*
|
||||||
|
* @param ids 待删除的主键集合
|
||||||
|
* @param isValid 是否进行有效性校验
|
||||||
|
* @return 是否删除成功
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||||
|
if(isValid){
|
||||||
|
//TODO 做一些业务上的校验,判断是否需要校验
|
||||||
|
}
|
||||||
|
return baseMapper.deleteByIds(ids) > 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,136 @@
|
|||||||
|
package org.dromara.shebei.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import org.dromara.common.core.utils.MapstructUtils;
|
||||||
|
import org.dromara.common.core.utils.StringUtils;
|
||||||
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||||
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.dromara.shebei.domain.bo.OpsSbMobanBo;
|
||||||
|
import org.dromara.shebei.domain.vo.OpsSbMobanVo;
|
||||||
|
import org.dromara.shebei.domain.OpsSbMoban;
|
||||||
|
import org.dromara.shebei.mapper.OpsSbMobanMapper;
|
||||||
|
import org.dromara.shebei.service.IOpsSbMobanService;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 运维-设备管理-设备模板Service业务层处理
|
||||||
|
*
|
||||||
|
* @author LionLi
|
||||||
|
* @date 2025-10-09
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@Service
|
||||||
|
public class OpsSbMobanServiceImpl extends ServiceImpl<OpsSbMobanMapper, OpsSbMoban> implements IOpsSbMobanService {
|
||||||
|
|
||||||
|
private final OpsSbMobanMapper baseMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询运维-设备管理-设备模板
|
||||||
|
*
|
||||||
|
* @param id 主键
|
||||||
|
* @return 运维-设备管理-设备模板
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public OpsSbMobanVo queryById(Long id){
|
||||||
|
return baseMapper.selectVoById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询运维-设备管理-设备模板列表
|
||||||
|
*
|
||||||
|
* @param bo 查询条件
|
||||||
|
* @param pageQuery 分页参数
|
||||||
|
* @return 运维-设备管理-设备模板分页列表
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public TableDataInfo<OpsSbMobanVo> queryPageList(OpsSbMobanBo bo, PageQuery pageQuery) {
|
||||||
|
LambdaQueryWrapper<OpsSbMoban> lqw = buildQueryWrapper(bo);
|
||||||
|
Page<OpsSbMobanVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||||
|
return TableDataInfo.build(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询符合条件的运维-设备管理-设备模板列表
|
||||||
|
*
|
||||||
|
* @param bo 查询条件
|
||||||
|
* @return 运维-设备管理-设备模板列表
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<OpsSbMobanVo> queryList(OpsSbMobanBo bo) {
|
||||||
|
LambdaQueryWrapper<OpsSbMoban> lqw = buildQueryWrapper(bo);
|
||||||
|
return baseMapper.selectVoList(lqw);
|
||||||
|
}
|
||||||
|
|
||||||
|
private LambdaQueryWrapper<OpsSbMoban> buildQueryWrapper(OpsSbMobanBo bo) {
|
||||||
|
Map<String, Object> params = bo.getParams();
|
||||||
|
LambdaQueryWrapper<OpsSbMoban> lqw = Wrappers.lambdaQuery();
|
||||||
|
lqw.orderByAsc(OpsSbMoban::getId);
|
||||||
|
lqw.eq(bo.getProjectId() != null, OpsSbMoban::getProjectId, bo.getProjectId());
|
||||||
|
lqw.like(StringUtils.isNotBlank(bo.getMbName()), OpsSbMoban::getMbName, bo.getMbName());
|
||||||
|
lqw.eq(bo.getBlCount() != null, OpsSbMoban::getBlCount, bo.getBlCount());
|
||||||
|
lqw.eq(bo.getSbCount() != null, OpsSbMoban::getSbCount, bo.getSbCount());
|
||||||
|
return lqw;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增运维-设备管理-设备模板
|
||||||
|
*
|
||||||
|
* @param bo 运维-设备管理-设备模板
|
||||||
|
* @return 是否新增成功
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Boolean insertByBo(OpsSbMobanBo bo) {
|
||||||
|
OpsSbMoban add = MapstructUtils.convert(bo, OpsSbMoban.class);
|
||||||
|
validEntityBeforeSave(add);
|
||||||
|
boolean flag = baseMapper.insert(add) > 0;
|
||||||
|
if (flag) {
|
||||||
|
bo.setId(add.getId());
|
||||||
|
}
|
||||||
|
return flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改运维-设备管理-设备模板
|
||||||
|
*
|
||||||
|
* @param bo 运维-设备管理-设备模板
|
||||||
|
* @return 是否修改成功
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Boolean updateByBo(OpsSbMobanBo bo) {
|
||||||
|
OpsSbMoban update = MapstructUtils.convert(bo, OpsSbMoban.class);
|
||||||
|
validEntityBeforeSave(update);
|
||||||
|
return baseMapper.updateById(update) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存前的数据校验
|
||||||
|
*/
|
||||||
|
private void validEntityBeforeSave(OpsSbMoban entity){
|
||||||
|
//TODO 做一些数据校验,如唯一约束
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验并批量删除运维-设备管理-设备模板信息
|
||||||
|
*
|
||||||
|
* @param ids 待删除的主键集合
|
||||||
|
* @param isValid 是否进行有效性校验
|
||||||
|
* @return 是否删除成功
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||||
|
if(isValid){
|
||||||
|
//TODO 做一些业务上的校验,判断是否需要校验
|
||||||
|
}
|
||||||
|
return baseMapper.deleteByIds(ids) > 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -11,6 +11,7 @@ import org.dromara.tcpfuwu.domain.ModbusVariable;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
@ -33,7 +34,7 @@ public class DeviceHandler {
|
|||||||
// 配置参数
|
// 配置参数
|
||||||
private static final long HEARTBEAT_EXPIRE_MS = 30 * 1000;
|
private static final long HEARTBEAT_EXPIRE_MS = 30 * 1000;
|
||||||
private static final int HEARTBEAT_LEN = 20;
|
private static final int HEARTBEAT_LEN = 20;
|
||||||
private static final int SN_CODE_LEN = 10;
|
private static final int SN_CODE_LEN = 20;
|
||||||
private static final int MODBUS_REQUEST_CYCLE = 10; // 请求周期(秒)
|
private static final int MODBUS_REQUEST_CYCLE = 10; // 请求周期(秒)
|
||||||
|
|
||||||
// 依赖注入
|
// 依赖注入
|
||||||
@ -111,7 +112,7 @@ public class DeviceHandler {
|
|||||||
byte[] data = Arrays.copyOf(buffer, len);
|
byte[] data = Arrays.copyOf(buffer, len);
|
||||||
if (isHeartbeatData(data)) {
|
if (isHeartbeatData(data)) {
|
||||||
// 解析SN码
|
// 解析SN码
|
||||||
String snCode = new String(Arrays.copyOfRange(data, 0, SN_CODE_LEN)).trim();
|
String snCode = new String(Arrays.copyOfRange(data, 0, data.length)).trim();
|
||||||
// 更新缓存
|
// 更新缓存
|
||||||
deviceCache.setSnCode(snCode);
|
deviceCache.setSnCode(snCode);
|
||||||
deviceCache.setLastHeartbeatTime(System.currentTimeMillis());
|
deviceCache.setLastHeartbeatTime(System.currentTimeMillis());
|
||||||
@ -173,36 +174,100 @@ public class DeviceHandler {
|
|||||||
/**
|
/**
|
||||||
* 处理单个变量的请求与解析
|
* 处理单个变量的请求与解析
|
||||||
*/
|
*/
|
||||||
|
// private void handleVariable(ModbusVariable var) throws Exception {
|
||||||
|
// // 生成请求帧
|
||||||
|
// byte[] request = generateModbusFrame(var);
|
||||||
|
// System.out.printf("【发送请求】SN:%s,变量:%s,帧:%s%n",
|
||||||
|
// deviceCache.getSnCode(), var.getVariableName(), bytesToHex(request));
|
||||||
|
//
|
||||||
|
// // 发送请求
|
||||||
|
// out.write(request);
|
||||||
|
// out.flush();
|
||||||
|
//
|
||||||
|
// // 接收响应(超时3秒)
|
||||||
|
// byte[] response = receiveResponse(10000);
|
||||||
|
// if (response == null) {
|
||||||
|
// throw new Exception("响应超时");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // 验证响应
|
||||||
|
// if (!validateResponse(response, var)) {
|
||||||
|
// throw new Exception("响应验证失败");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // 解析数据
|
||||||
|
// Object value = parseValue(response, var);
|
||||||
|
// System.out.printf("【解析成功】SN:%s,变量:%s,值:%s %s%n",
|
||||||
|
// deviceCache.getSnCode(), var.getVariableName(), value, var.getUnit());
|
||||||
|
//
|
||||||
|
// // 更新缓存
|
||||||
|
// deviceCache.getVariableValues().put(var.getVariableName(), value);
|
||||||
|
// }
|
||||||
private void handleVariable(ModbusVariable var) throws Exception {
|
private void handleVariable(ModbusVariable var) throws Exception {
|
||||||
// 生成请求帧
|
// 1. 校验设备是否在线(避免无效通信)
|
||||||
|
if (!isDeviceOnline()) {
|
||||||
|
throw new Exception("设备离线,无法通信");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. 生成请求帧并打印详细信息
|
||||||
byte[] request = generateModbusFrame(var);
|
byte[] request = generateModbusFrame(var);
|
||||||
System.out.printf("【发送请求】SN:%s,变量:%s,帧:%s%n",
|
String requestHex = bytesToHex(request);
|
||||||
deviceCache.getSnCode(), var.getVariableName(), bytesToHex(request));
|
System.out.printf("【发送请求】SN:%s,变量:%s,帧:%s,长度:%d字节%n",
|
||||||
|
deviceCache.getSnCode(), var.getVariableName(), requestHex, request.length);
|
||||||
|
|
||||||
// 发送请求
|
// 3. 发送请求(确保输出流正确)
|
||||||
out.write(request);
|
try {
|
||||||
out.flush();
|
out.write(request);
|
||||||
|
out.flush();
|
||||||
|
System.out.println("【发送成功】请求已提交到串口");
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new Exception("发送请求失败:" + e.getMessage(), e);
|
||||||
|
}
|
||||||
|
|
||||||
// 接收响应(超时3秒)
|
// 4. 接收响应(增加重试机制,最多3次)
|
||||||
byte[] response = receiveResponse(3000);
|
byte[] response = null;
|
||||||
|
int retryCount = 0;
|
||||||
|
while (retryCount < 3 && response == null) {
|
||||||
|
try {
|
||||||
|
response = receiveResponse(10000); // 每次超时10秒
|
||||||
|
if (response == null) {
|
||||||
|
retryCount++;
|
||||||
|
System.out.printf("【响应超时】第%d次重试...%n", retryCount);
|
||||||
|
// 重试前短暂延迟,避免设备繁忙
|
||||||
|
Thread.sleep(500);
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new Exception("接收响应失败:" + e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (response == null) {
|
if (response == null) {
|
||||||
throw new Exception("响应超时");
|
throw new Exception("多次重试后仍无响应,可能设备离线或参数错误");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 验证响应
|
// 5. 打印响应原始数据(关键调试信息)
|
||||||
|
String responseHex = bytesToHex(response);
|
||||||
|
System.out.printf("【收到响应】长度:%d字节,帧:%s%n", response.length, responseHex);
|
||||||
|
|
||||||
|
// 6. 验证响应
|
||||||
if (!validateResponse(response, var)) {
|
if (!validateResponse(response, var)) {
|
||||||
throw new Exception("响应验证失败");
|
throw new Exception("响应验证失败,原始帧:" + responseHex);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 解析数据
|
// 7. 解析数据(后续步骤不变)
|
||||||
Object value = parseValue(response, var);
|
Object value = parseValue(response, var);
|
||||||
System.out.printf("【解析成功】SN:%s,变量:%s,值:%s %s%n",
|
System.out.printf("【解析成功】SN:%s,变量:%s,值:%s %s%n",
|
||||||
deviceCache.getSnCode(), var.getVariableName(), value, var.getUnit());
|
deviceCache.getSnCode(), var.getVariableName(), value, var.getUnit());
|
||||||
|
|
||||||
// 更新缓存
|
// 8. 更新缓存
|
||||||
deviceCache.getVariableValues().put(var.getVariableName(), value);
|
deviceCache.getVariableValues().put(var.getVariableName(), value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 辅助方法:判断设备是否在线(如通过ping或前次通信时间)
|
||||||
|
private boolean isDeviceOnline() {
|
||||||
|
// 实现逻辑:如检查最近一次成功通信时间是否在有效期内
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 从数据库查询变量列表
|
* 从数据库查询变量列表
|
||||||
*/
|
*/
|
||||||
@ -216,8 +281,9 @@ public class DeviceHandler {
|
|||||||
modbusVariable.setVariableName(v.getBlName());
|
modbusVariable.setVariableName(v.getBlName());
|
||||||
modbusVariable.setUnit(v.getBlDanwei());
|
modbusVariable.setUnit(v.getBlDanwei());
|
||||||
modbusVariable.setSnCode(snCode);
|
modbusVariable.setSnCode(snCode);
|
||||||
modbusVariable.setSlaveId(Math.toIntExact(opsSbLiebiaoDto.getSlaveId()));
|
modbusVariable.setSlaveId(opsSbLiebiaoDto.getSlaveId().intValue());
|
||||||
modbusVariable.setFuncCode(Integer.parseInt(v.getJicunqiGnm()));
|
String pureHex = v.getJicunqiGnm().substring(2);
|
||||||
|
modbusVariable.setFuncCode(Integer.parseInt(pureHex,16));
|
||||||
modbusVariable.setStartRegAddr(Integer.parseInt(v.getJicunqiAdd()));
|
modbusVariable.setStartRegAddr(Integer.parseInt(v.getJicunqiAdd()));
|
||||||
switch (v.getShujvGeshi()) {
|
switch (v.getShujvGeshi()) {
|
||||||
case "S16": modbusVariable.setRegQuantity(1); break;
|
case "S16": modbusVariable.setRegQuantity(1); break;
|
||||||
@ -306,19 +372,56 @@ public class DeviceHandler {
|
|||||||
return Arrays.equals(receivedCrc, calculateCrc16(body));
|
return Arrays.equals(receivedCrc, calculateCrc16(body));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// private Object parseValue(byte[] response, ModbusVariable var) {
|
||||||
|
// ByteBuffer buffer = ByteBuffer.wrap(response, 3, response[2]).order(ByteOrder.BIG_ENDIAN);
|
||||||
|
// double rawValue;
|
||||||
|
//
|
||||||
|
// switch (var.getDataType().toUpperCase()) {
|
||||||
|
// case "S16": rawValue = buffer.getShort(); break;
|
||||||
|
// case "U16": rawValue = buffer.getShort() & 0xFFFF; break;
|
||||||
|
// case "S32": rawValue = buffer.getInt(); break;
|
||||||
|
// case "U32": rawValue = buffer.getLong() & 0xFFFFFFFFL; break;
|
||||||
|
// case "FLOAT": rawValue = buffer.getFloat(); break;
|
||||||
|
// default: throw new IllegalArgumentException("不支持的数据类型:" + var.getDataType());
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return rawValue * var.getMultiplier();
|
||||||
|
// }
|
||||||
|
|
||||||
private Object parseValue(byte[] response, ModbusVariable var) {
|
private Object parseValue(byte[] response, ModbusVariable var) {
|
||||||
|
// 1. 初始化缓冲区:从响应报文的"数据部分"开始读取(跳过前3字节:从站地址、功能码、字节计数)
|
||||||
|
// 字节序设置为BIG_ENDIAN(大端序),符合"高字节在前、高字在前"的规则
|
||||||
ByteBuffer buffer = ByteBuffer.wrap(response, 3, response[2]).order(ByteOrder.BIG_ENDIAN);
|
ByteBuffer buffer = ByteBuffer.wrap(response, 3, response[2]).order(ByteOrder.BIG_ENDIAN);
|
||||||
double rawValue;
|
double rawValue; // 用double统一存储原始值,兼容整数和后续倍率计算
|
||||||
|
|
||||||
switch (var.getDataType().toUpperCase()) {
|
switch (var.getDataType().toUpperCase()) {
|
||||||
case "S16": rawValue = buffer.getShort(); break;
|
case "U16":
|
||||||
case "U16": rawValue = buffer.getShort() & 0xFFFF; break;
|
// 读取2字节(高字节在前),转换为无符号整数
|
||||||
case "S32": rawValue = buffer.getInt(); break;
|
// getShort()返回有符号short,&0xFFFF转换为无符号(0~65535)
|
||||||
case "U32": rawValue = buffer.getLong() & 0xFFFFFFFFL; break;
|
rawValue = buffer.getShort() & 0xFFFF;
|
||||||
case "FLOAT": rawValue = buffer.getFloat(); break;
|
break;
|
||||||
default: throw new IllegalArgumentException("不支持的数据类型:" + var.getDataType());
|
case "S16":
|
||||||
|
// 读取2字节(高字节在前),直接按有符号short解析(-32768~32767)
|
||||||
|
rawValue = buffer.getShort();
|
||||||
|
break;
|
||||||
|
case "U32":
|
||||||
|
// 读取4字节(高字在前,每个字内高字节在前),转换为无符号整数
|
||||||
|
// getInt()返回有符号int,转换为long后&0xFFFFFFFFL得到无符号值(0~4294967295)
|
||||||
|
rawValue = (long) buffer.getInt() & 0xFFFFFFFFL;
|
||||||
|
break;
|
||||||
|
case "S32":
|
||||||
|
// 读取4字节(高字在前,每个字内高字节在前),直接按有符号int解析
|
||||||
|
rawValue = buffer.getInt();
|
||||||
|
break;
|
||||||
|
case "FLOAT":
|
||||||
|
// 单精度浮点型(32位),大端序解析(符合IEEE 754标准)
|
||||||
|
rawValue = buffer.getFloat();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException("不支持的数据类型:" + var.getDataType());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 原始值 × 倍率 = 实际物理量(如温度、压力等)
|
||||||
return rawValue * var.getMultiplier();
|
return rawValue * var.getMultiplier();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -13,6 +13,7 @@ import org.springframework.beans.factory.annotation.Value;
|
|||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
|
||||||
|
import java.net.InetSocketAddress;
|
||||||
import java.net.ServerSocket;
|
import java.net.ServerSocket;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -25,7 +26,7 @@ import java.util.concurrent.*;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class UnifiedTcpServer {
|
public class UnifiedTcpServer {
|
||||||
|
|
||||||
@Value("${tcp.server.port:8888}")
|
@Value("${tcp.server.port:12345}")
|
||||||
private int tcpPort;
|
private int tcpPort;
|
||||||
@Value("${tcp.server.heartbeat-timeout: 60000}")
|
@Value("${tcp.server.heartbeat-timeout: 60000}")
|
||||||
private int heartbeatExpireMs;
|
private int heartbeatExpireMs;
|
||||||
@ -50,9 +51,20 @@ public class UnifiedTcpServer {
|
|||||||
*/
|
*/
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void start() {
|
public void start() {
|
||||||
|
// 新增:判断是否已启动,避免重复执行
|
||||||
|
if (isRunning) {
|
||||||
|
System.out.println("【TCP服务】已启动,无需重复执行");
|
||||||
|
return;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
|
System.out.printf("【TCP服务启动】尝试绑定端口:%d%n", tcpPort);
|
||||||
// 初始化服务器Socket
|
// 初始化服务器Socket
|
||||||
serverSocket = new ServerSocket(tcpPort);
|
ServerSocket serverSocket = new ServerSocket();
|
||||||
|
// 允许端口复用(即使处于TIME_WAIT状态,也能重新绑定)
|
||||||
|
serverSocket.setReuseAddress(true);
|
||||||
|
// 绑定端口(替换原有的 new ServerSocket(tcpPort))
|
||||||
|
serverSocket.bind(new InetSocketAddress(tcpPort));
|
||||||
|
this.serverSocket = serverSocket;
|
||||||
// 初始化线程池(处理设备连接)
|
// 初始化线程池(处理设备连接)
|
||||||
clientExecutor = Executors.newCachedThreadPool(r -> {
|
clientExecutor = Executors.newCachedThreadPool(r -> {
|
||||||
Thread thread = new Thread(r);
|
Thread thread = new Thread(r);
|
||||||
|
|||||||
@ -0,0 +1,7 @@
|
|||||||
|
<?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="org.dromara.shebei.mapper.OpsSbLiebiaoMapper">
|
||||||
|
|
||||||
|
</mapper>
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
<?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="org.dromara.shebei.mapper.OpsSbMbBianliangMapper">
|
||||||
|
|
||||||
|
</mapper>
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
<?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="org.dromara.shebei.mapper.OpsSbMobanMapper">
|
||||||
|
|
||||||
|
</mapper>
|
||||||
Reference in New Issue
Block a user