From 67cc7c66cfdadcff4c524b59f70017f241395664 Mon Sep 17 00:00:00 2001 From: mh Date: Mon, 13 Jan 2025 17:30:21 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E8=AE=BE=E5=A4=87=E5=8F=B0=E8=B4=A6?= =?UTF-8?q?=E7=AE=A1=E7=90=86=EF=BC=9B=202=E3=80=81=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E9=87=87=E9=9B=86=E5=8F=82=E6=95=B0=E7=AE=A1=E7=90=86=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CollectionParamsManageController.java | 88 ++++ .../device/CommunicationParamsController.java | 10 +- .../domain/entity/CollectionParamsManage.java | 391 ++++++++++++++++++ .../device/CollectionParamsManageMapper.java | 16 + .../ICollectionParamsManageService.java | 26 ++ .../CollectionParamsManageServiceImpl.java | 78 ++++ .../impl/DeviceQrManageServiceImpl.java | 10 + 7 files changed, 614 insertions(+), 5 deletions(-) create mode 100644 mh-admin/src/main/java/com/mh/web/controller/device/CollectionParamsManageController.java create mode 100644 mh-common/src/main/java/com/mh/common/core/domain/entity/CollectionParamsManage.java create mode 100644 mh-system/src/main/java/com/mh/system/mapper/device/CollectionParamsManageMapper.java create mode 100644 mh-system/src/main/java/com/mh/system/service/device/ICollectionParamsManageService.java create mode 100644 mh-system/src/main/java/com/mh/system/service/device/impl/CollectionParamsManageServiceImpl.java diff --git a/mh-admin/src/main/java/com/mh/web/controller/device/CollectionParamsManageController.java b/mh-admin/src/main/java/com/mh/web/controller/device/CollectionParamsManageController.java new file mode 100644 index 0000000..72edd8e --- /dev/null +++ b/mh-admin/src/main/java/com/mh/web/controller/device/CollectionParamsManageController.java @@ -0,0 +1,88 @@ +package com.mh.web.controller.device; + +import com.mh.common.annotation.Log; +import com.mh.common.core.controller.BaseController; +import com.mh.common.core.domain.AjaxResult; +import com.mh.common.core.domain.entity.CollectionParamsManage; +import com.mh.common.core.page.TableDataInfo; +import com.mh.common.enums.BusinessType; +import com.mh.system.service.device.ICollectionParamsManageService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * @author LJF + * @version 1.0 + * @project EEMCS + * @description 仪表管理表控制类 + * @date 2025-01-13 16:10:17 + */ +@RestController +@RequestMapping("/device/cpm") +public class CollectionParamsManageController extends BaseController { + + @Autowired + private ICollectionParamsManageService iCollectionParamsManageService; + + /** + * 获取列表内容数据 + */ + @PreAuthorize("@ss.hasPermi('system:cpm:list')") + @GetMapping("/list") + public TableDataInfo list(CollectionParamsManage communicationParams) + { + startPage(); + List list = iCollectionParamsManageService.selectCollectionParamsManageList(communicationParams); + return getDataTable(list); + } + + /** + * 根据id获取详细信息 + */ + @PreAuthorize("@ss.hasPermi('system:cpm:query')") + @GetMapping(value = "/{cpmId}") + public AjaxResult getInfo(@PathVariable String cpmId) + { + return success(iCollectionParamsManageService.selectCollectionParamsManageById(cpmId)); + } + + /** + * 新增网关 + */ + @PreAuthorize("@ss.hasPermi('system:cpm:add')") + @Log(title = "设备采集参数管理", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@Validated @RequestBody CollectionParamsManage communicationParams) + { + communicationParams.setCreateBy(getUsername()); + return toAjax(iCollectionParamsManageService.insertCollectionParamsManage(communicationParams)); + } + + /** + * 修改网关信息 + */ + @PreAuthorize("@ss.hasPermi('system:cpm:edit')") + @Log(title = "设备采集参数管理", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@Validated @RequestBody CollectionParamsManage communicationParams) + { + communicationParams.setUpdateBy(getUsername()); + return toAjax(iCollectionParamsManageService.updateCollectionParamsManage(communicationParams)); + } + + /** + * 删除设备采集参数管理 + */ + @PreAuthorize("@ss.hasPermi('system:cpm:remove')") + @Log(title = "设备采集参数管理", businessType = BusinessType.DELETE) + @DeleteMapping("/{cpmIds}") + public AjaxResult remove(@PathVariable String[] cpmIds) + { + return toAjax(iCollectionParamsManageService.deleteCommunicationByIds(cpmIds)); + } + +} diff --git a/mh-admin/src/main/java/com/mh/web/controller/device/CommunicationParamsController.java b/mh-admin/src/main/java/com/mh/web/controller/device/CommunicationParamsController.java index 97308e9..eb848f5 100644 --- a/mh-admin/src/main/java/com/mh/web/controller/device/CommunicationParamsController.java +++ b/mh-admin/src/main/java/com/mh/web/controller/device/CommunicationParamsController.java @@ -18,7 +18,7 @@ import java.util.List; * @author LJF * @version 1.0 * @project EEMCS - * @description 设备采集参数管理 + * @description 设备通信采集参数管理 * @date 2025-01-08 14:36:24 */ @RestController @@ -54,7 +54,7 @@ public class CommunicationParamsController extends BaseController { * 新增网关 */ @PreAuthorize("@ss.hasPermi('system:cmp:add')") - @Log(title = "设备采集参数管理", businessType = BusinessType.INSERT) + @Log(title = "设备通信采集参数管理", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@Validated @RequestBody CommunicationParams communicationParams) { @@ -66,7 +66,7 @@ public class CommunicationParamsController extends BaseController { * 修改网关信息 */ @PreAuthorize("@ss.hasPermi('system:cmp:edit')") - @Log(title = "设备采集参数管理", businessType = BusinessType.UPDATE) + @Log(title = "设备通信采集参数管理", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@Validated @RequestBody CommunicationParams communicationParams) { @@ -75,10 +75,10 @@ public class CommunicationParamsController extends BaseController { } /** - * 删除设备采集参数管理 + * 删除设备通信采集参数管理 */ @PreAuthorize("@ss.hasPermi('system:cmp:remove')") - @Log(title = "设备采集参数管理", businessType = BusinessType.DELETE) + @Log(title = "设备通信采集参数管理", businessType = BusinessType.DELETE) @DeleteMapping("/{cmpIds}") public AjaxResult remove(@PathVariable String[] cmpIds) { diff --git a/mh-common/src/main/java/com/mh/common/core/domain/entity/CollectionParamsManage.java b/mh-common/src/main/java/com/mh/common/core/domain/entity/CollectionParamsManage.java new file mode 100644 index 0000000..c280dff --- /dev/null +++ b/mh-common/src/main/java/com/mh/common/core/domain/entity/CollectionParamsManage.java @@ -0,0 +1,391 @@ +package com.mh.common.core.domain.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.mh.common.core.domain.BaseEntity; +import org.apache.commons.lang3.builder.ToStringBuilder; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * @author LJF + * @version 1.0 + * @project EEMCS + * @description 数据采集参数配置管理 + * @date 2025-01-13 15:23:40 + */ +@TableName("collection_params_manage") +public class CollectionParamsManage extends BaseEntity { + + /** + * id + */ + private String id; + + /** + * 设备台账id + */ + private String deviceLedgerId; + + /** + * 仪表类型id + */ + private String mtType; + + /** + * 仪表编号 + */ + private String mtNum; + + /** + * 仪表代码 + */ + private String mtCode; + + /** + * 寄存器地址 + */ + private String registerAddr; + + /** + * 功能码 + */ + private String funcCode; + + /** + * 仪表标识码 + */ + private String identityCode; + + /** + * 仪表标定脉冲 + */ + private String mtCaliberPulse; + + /** + * 仪表范围 + */ + private String mtRange; + + /** + * 仪表比率 + */ + private Integer mtRatio; + + /** + * 初始值 + */ + private BigDecimal mtInitValue; + + /** + * 小数位数 + */ + private Integer digits; + + /** + * 数据类型 + */ + private Integer dataType; + + /** + * 当前值 + */ + private BigDecimal curValue; + + /** + * 当前时间 + */ + private Date curTime; + + /** + * 是否是总表累计值 + */ + private Integer mtIsSum; + + /** + * 单位 + */ + private String unit; + + /** + * 排序 + */ + private Integer sort; + + /** + * 网关id + */ + private String gatewayId; + + /** + * 参数id + */ + private String paramId; + + /** + * 通讯协议类型 + */ + private String protocolType; + + /** + * 通讯类型 + */ + private String communicationType; + + /** + * 备注 + */ + private String remark; + + /** + * 读取响应的寄存器大小(创建指令的时候需要) + */ + private Integer registerSize; + + /** + * 是否使用 + */ + private Integer isUse; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getDeviceLedgerId() { + return deviceLedgerId; + } + + public void setDeviceLedgerId(String deviceLedgerId) { + this.deviceLedgerId = deviceLedgerId; + } + + public String getMtType() { + return mtType; + } + + public void setMtType(String mtType) { + this.mtType = mtType; + } + + public String getMtNum() { + return mtNum; + } + + public void setMtNum(String mtNum) { + this.mtNum = mtNum; + } + + public String getMtCode() { + return mtCode; + } + + public void setMtCode(String mtCode) { + this.mtCode = mtCode; + } + + public String getRegisterAddr() { + return registerAddr; + } + + public void setRegisterAddr(String registerAddr) { + this.registerAddr = registerAddr; + } + + public String getFuncCode() { + return funcCode; + } + + public void setFuncCode(String funcCode) { + this.funcCode = funcCode; + } + + public String getIdentityCode() { + return identityCode; + } + + public void setIdentityCode(String identityCode) { + this.identityCode = identityCode; + } + + public String getMtCaliberPulse() { + return mtCaliberPulse; + } + + public void setMtCaliberPulse(String mtCaliberPulse) { + this.mtCaliberPulse = mtCaliberPulse; + } + + public String getMtRange() { + return mtRange; + } + + public void setMtRange(String mtRange) { + this.mtRange = mtRange; + } + + public Integer getMtRatio() { + return mtRatio; + } + + public void setMtRatio(Integer mtRatio) { + this.mtRatio = mtRatio; + } + + public BigDecimal getMtInitValue() { + return mtInitValue; + } + + public void setMtInitValue(BigDecimal mtInitValue) { + this.mtInitValue = mtInitValue; + } + + public Integer getDigits() { + return digits; + } + + public void setDigits(Integer digits) { + this.digits = digits; + } + + public Integer getDataType() { + return dataType; + } + + public void setDataType(Integer dataType) { + this.dataType = dataType; + } + + public BigDecimal getCurValue() { + return curValue; + } + + public void setCurValue(BigDecimal curValue) { + this.curValue = curValue; + } + + public Date getCurTime() { + return curTime; + } + + public void setCurTime(Date curTime) { + this.curTime = curTime; + } + + public Integer getMtIsSum() { + return mtIsSum; + } + + public void setMtIsSum(Integer mtIsSum) { + this.mtIsSum = mtIsSum; + } + + public String getUnit() { + return unit; + } + + public void setUnit(String unit) { + this.unit = unit; + } + + public Integer getSort() { + return sort; + } + + public void setSort(Integer sort) { + this.sort = sort; + } + + public String getGatewayId() { + return gatewayId; + } + + public void setGatewayId(String gatewayId) { + this.gatewayId = gatewayId; + } + + public String getParamId() { + return paramId; + } + + public void setParamId(String paramId) { + this.paramId = paramId; + } + + public String getProtocolType() { + return protocolType; + } + + public void setProtocolType(String protocolType) { + this.protocolType = protocolType; + } + + public String getCommunicationType() { + return communicationType; + } + + public void setCommunicationType(String communicationType) { + this.communicationType = communicationType; + } + + @Override + public String getRemark() { + return remark; + } + + @Override + public void setRemark(String remark) { + this.remark = remark; + } + + public Integer getRegisterSize() { + return registerSize; + } + + public void setRegisterSize(Integer registerSize) { + this.registerSize = registerSize; + } + + public Integer getIsUse() { + return isUse; + } + + public void setIsUse(Integer isUse) { + this.isUse = isUse; + } + + @Override + public String toString() { + return new ToStringBuilder(this) + .append("id", id) + .append("deviceLedgerId", deviceLedgerId) + .append("mtType", mtType) + .append("mtNum", mtNum) + .append("mtCode", mtCode) + .append("registerAddr", registerAddr) + .append("funcCode", funcCode) + .append("identityCode", identityCode) + .append("mtCaliberPulse", mtCaliberPulse) + .append("mtRange", mtRange) + .append("mtRatio", mtRatio) + .append("mtInitValue", mtInitValue) + .append("digits", digits) + .append("dataType", dataType) + .append("curValue", curValue) + .append("curTime", curTime) + .append("mtIsSum", mtIsSum) + .append("unit", unit) + .append("sort", sort) + .append("gatewayId", gatewayId) + .append("paramId", paramId) + .append("protocolType", protocolType) + .append("communicationType", communicationType) + .append("remark", remark) + .append("registerSize", registerSize) + .append("isUse", isUse) + .toString(); + } +} diff --git a/mh-system/src/main/java/com/mh/system/mapper/device/CollectionParamsManageMapper.java b/mh-system/src/main/java/com/mh/system/mapper/device/CollectionParamsManageMapper.java new file mode 100644 index 0000000..e67a425 --- /dev/null +++ b/mh-system/src/main/java/com/mh/system/mapper/device/CollectionParamsManageMapper.java @@ -0,0 +1,16 @@ +package com.mh.system.mapper.device; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.mh.common.core.domain.entity.CollectionParamsManage; +import org.apache.ibatis.annotations.Mapper; + +/** + * @author LJF + * @version 1.0 + * @project EEMCS + * @description 设备采集参数配置mapper + * @date 2025-01-13 16:34:52 + */ +@Mapper +public interface CollectionParamsManageMapper extends BaseMapper { +} diff --git a/mh-system/src/main/java/com/mh/system/service/device/ICollectionParamsManageService.java b/mh-system/src/main/java/com/mh/system/service/device/ICollectionParamsManageService.java new file mode 100644 index 0000000..dfd54b1 --- /dev/null +++ b/mh-system/src/main/java/com/mh/system/service/device/ICollectionParamsManageService.java @@ -0,0 +1,26 @@ +package com.mh.system.service.device; + +import com.mh.common.core.domain.entity.CollectionParamsManage; + +import java.util.List; + +/** + * @author LJF + * @version 1.0 + * @project EEMCS + * @description 设备采集参数 + * @date 2025-01-13 16:31:08 + */ +public interface ICollectionParamsManageService { + + List selectCollectionParamsManageList(CollectionParamsManage communicationParams); + + CollectionParamsManage selectCollectionParamsManageById(String cpmId); + + int insertCollectionParamsManage(CollectionParamsManage communicationParams); + + int updateCollectionParamsManage(CollectionParamsManage communicationParams); + + int deleteCommunicationByIds(String[] cpmIds); + +} diff --git a/mh-system/src/main/java/com/mh/system/service/device/impl/CollectionParamsManageServiceImpl.java b/mh-system/src/main/java/com/mh/system/service/device/impl/CollectionParamsManageServiceImpl.java new file mode 100644 index 0000000..4c83cf0 --- /dev/null +++ b/mh-system/src/main/java/com/mh/system/service/device/impl/CollectionParamsManageServiceImpl.java @@ -0,0 +1,78 @@ +package com.mh.system.service.device.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.mh.common.core.domain.entity.CollectionParamsManage; +import com.mh.system.mapper.device.CollectionParamsManageMapper; +import com.mh.system.service.device.ICollectionParamsManageService; +import jakarta.annotation.Resource; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * @author LJF + * @version 1.0 + * @project EEMCS + * @description 设备采集参数配置 + * @date 2025-01-13 16:33:47 + */ +@Service +public class CollectionParamsManageServiceImpl implements ICollectionParamsManageService { + + @Resource + private CollectionParamsManageMapper collectionParamsManageMapper; + + @Override + public List selectCollectionParamsManageList(CollectionParamsManage communicationParams) { + if (communicationParams == null) { + return List.of(); + } + QueryWrapper queryWrapper = new QueryWrapper<>(); + // 仪表类型 + if (communicationParams.getMtType() != null) { + queryWrapper.eq("mt_type", communicationParams.getMtType()); + } + // 表号 + if (communicationParams.getMtNum() != null) { + queryWrapper.like("mt_num", communicationParams.getMtNum()); + } + // 设备台账 + if (communicationParams.getDeviceLedgerId() != null) { + queryWrapper.eq("device_ledger_id", communicationParams.getDeviceLedgerId()); + } + queryWrapper.orderByDesc("cur_time"); + return collectionParamsManageMapper.selectList(queryWrapper); + } + + @Override + public CollectionParamsManage selectCollectionParamsManageById(String cpmId) { + return collectionParamsManageMapper.selectById(cpmId); + } + + @Override + public int insertCollectionParamsManage(CollectionParamsManage communicationParams) { + if (communicationParams != null) { + return collectionParamsManageMapper.insert(communicationParams); + } + return 0; + } + + @Override + public int updateCollectionParamsManage(CollectionParamsManage communicationParams) { + if (communicationParams != null) { + return collectionParamsManageMapper.updateById(communicationParams); + } + return 0; + } + + @Override + public int deleteCommunicationByIds(String[] cpmIds) { + if (cpmIds != null && cpmIds.length > 0) { + for (String cpmId : cpmIds) { + collectionParamsManageMapper.deleteById(cpmId); + } + return cpmIds.length; + } + return 0; + } +} diff --git a/mh-system/src/main/java/com/mh/system/service/device/impl/DeviceQrManageServiceImpl.java b/mh-system/src/main/java/com/mh/system/service/device/impl/DeviceQrManageServiceImpl.java index 4fdf042..e6e99b1 100644 --- a/mh-system/src/main/java/com/mh/system/service/device/impl/DeviceQrManageServiceImpl.java +++ b/mh-system/src/main/java/com/mh/system/service/device/impl/DeviceQrManageServiceImpl.java @@ -46,6 +46,16 @@ public class DeviceQrManageServiceImpl implements IDeviceQrManageService { @Override public int updateDeviceQrManage(DeviceQrManage deviceQrManage) { + // 判断是解绑还是绑定 + if (deviceQrManage.getStatus() == 0) { + // 绑定 + deviceQrManage.setBindTime(new Date()); + } else { + // 解绑 + deviceQrManage.setBindTime(null); + deviceQrManage.setDeviceLedgerId(null); + deviceQrManage.setDeviceName(null); + } return deviceQrManageMapper.updateById(deviceQrManage); }