提交不了

master
xins 2 years ago
parent cac6b971fb
commit 84cb7cdc4e

File diff suppressed because it is too large Load Diff

@ -0,0 +1,26 @@
package com.ruoyi.system.api;
import com.ruoyi.common.core.constant.ServiceNameConstants;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.system.api.factory.RemoteConfigFallbackFactory;
import com.ruoyi.system.api.factory.RemoteUserFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
/**
* @Description:
* @ClassName: RemoteConfigService
* @Author : xins
* @Date :2023-09-13 11:05
* @Version :1.0
*/
@FeignClient(contextId = "remoteConfigService", value = ServiceNameConstants.SYSTEM_SERVICE, fallbackFactory = RemoteConfigFallbackFactory.class)
public interface RemoteConfigService {
@GetMapping(value = "/config/configKeyStr/{configKey}")
R<String> getConfigKeyStr(@PathVariable("configKey") String configKey);
}

@ -0,0 +1,27 @@
package com.ruoyi.system.api.factory;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.system.api.RemoteConfigService;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
/**
* @Description:
* @ClassName: RemoteConfigFallbackFactory
* @Author : xins
* @Date :2023-09-13 11:10
* @Version :1.0
*/
@Component
public class RemoteConfigFallbackFactory implements FallbackFactory<RemoteConfigService> {
@Override
public RemoteConfigService create(Throwable throwable) {
return new RemoteConfigService()
{
@Override
public R<String> getConfigKeyStr(String configKey) {
return R.fail("获取参数失败:" + throwable.getMessage());
}
};
}
}

@ -1,3 +1,4 @@
com.ruoyi.system.api.factory.RemoteUserFallbackFactory com.ruoyi.system.api.factory.RemoteUserFallbackFactory
com.ruoyi.system.api.factory.RemoteLogFallbackFactory com.ruoyi.system.api.factory.RemoteLogFallbackFactory
com.ruoyi.system.api.factory.RemoteFileFallbackFactory com.ruoyi.system.api.factory.RemoteFileFallbackFactory
com.ruoyi.system.api.factory.RemoteConfigFallbackFactory

@ -26,4 +26,10 @@ public class HwDictConstants {
public static final String ALARM_INFO_TYPE_OFFLINE = "3";//离线报警 public static final String ALARM_INFO_TYPE_OFFLINE = "3";//离线报警
public static final String ALARM_INFO_TYPE_ELECTRONIC_FENCE = "4";//电子围栏 public static final String ALARM_INFO_TYPE_ELECTRONIC_FENCE = "4";//电子围栏
public static final String FUNCTION_MODE_ATTRIBUTE = "1";//设备模型功能模式属性
public static final String FUNCTION_MODE_SERVICE = "2";//设备模型功能模式服务
public static final String FUNCTION_MODE_EVENT = "3";//设备模型功能模式事件
public static final String DEVICE_STATUS_PUBLISH = "1";//设备状态:已发布
} }

@ -26,12 +26,31 @@ public class TdEngineConstants {
public static final String DEFAULT_DB_NAME_PREFIX = "db_scene_";//数据库名称前缀 public static final String DEFAULT_DB_NAME_PREFIX = "db_scene_";//数据库名称前缀
public static final String DEFAULT_SUPER_TABLE_NAME_PREFIX = "st_devicemode_";//超级表名称前缀
public static final String DEFAULT_TABLE_NAME_PREFIX = "t_device_";//数据表名称前缀 public static final String DEFAULT_TABLE_NAME_PREFIX = "t_device_";//数据表名称前缀
public static final String DEFAULT_DEVICE_STATUS_SUPER_TABLE_NAME= "st_ds";//设备状态超级表名称 public static final String DEFAULT_DEVICE_STATUS_SUPER_TABLE_NAME= "st_ds";//设备状态超级表名称
public static final String DEFAULT_DEVICE_STATUS_TABLE_NAME_PREFIX = "t_ds_";//设备状态数据表名称前缀 public static final String DEFAULT_DEVICE_STATUS_TABLE_NAME_PREFIX = "t_ds_";//设备状态数据表名称前缀
public static final String PLATFORM_DB_NAME = "db_hwsaas";//全局数据库名称 public static final String PLATFORM_DB_NAME = "db_hwsaas";//全局数据库名称
public static final String ST_TAG_DEVICECODE = "devicecode";
public static final int ST_TAG_DEVICECODE_TYPE = 10;
public static final int ST_TAG_DEVICECODE_SIZE=50;
public static final String ST_TAG_DEVICENAME = "devicename";
public static final int ST_TAG_DEVICENAME_TYPE = 10;
public static final int ST_TAG_DEVICENAME_SIZE=200;
public static final String ST_TAG_DEVICEID = "deviceid";
public static final int ST_TAG_DEVICEID_TYPE = 2;
public static final String ST_TAG_DEVICEMODEID = "devicemodeid";
public static final int ST_TAG_DEVICEMODEID_TYPE = 2;
public static final String ST_TAG_MONITORUNITID = "monitorunitid";
public static final int ST_TAG_MONITORUNITID_TYPE = 2;
/** /**
* key * key
*/ */

@ -35,6 +35,21 @@ public class HwLanguageController extends BaseController
@Autowired @Autowired
private IHwLanguageService hwLanguageService; private IHwLanguageService hwLanguageService;
/**
* @param: hwLanguage
* @description 使
* @author xins
* @date 2023-09-07 9:57
* @return AjaxResult
*/
@GetMapping("/getLanguages")
public AjaxResult getLanguages(HwLanguage hwLanguage)
{
return success(hwLanguageService.selectHwLanguageList(hwLanguage));
}
/** /**
* *
*/ */

@ -83,6 +83,11 @@
<artifactId>ruoyi-api-system</artifactId> <artifactId>ruoyi-api-system</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>hw-api-tdengine</artifactId>
</dependency>
<!-- RuoYi Common International Language --> <!-- RuoYi Common International Language -->
<dependency> <dependency>
<groupId>com.ruoyi</groupId> <groupId>com.ruoyi</groupId>
@ -94,16 +99,12 @@
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>hw-api-tdengine</artifactId>
<version>3.6.3</version>
<scope>compile</scope>
</dependency>
</dependencies> </dependencies>
<build> <build>

@ -1,8 +1,18 @@
package com.ruoyi.business.controller; package com.ruoyi.business.controller;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.io.IOException; import java.io.IOException;
import java.util.Map;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.ruoyi.business.domain.HwDeviceModeFunction;
import com.ruoyi.common.core.constant.SecurityConstants;
import com.ruoyi.common.core.context.SecurityContextHolder;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.system.api.domain.SysUser;
import com.ruoyi.system.api.model.LoginUser;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
@ -24,14 +34,13 @@ import com.ruoyi.common.core.web.page.TableDataInfo;
/** /**
* Controller * Controller
* *
* @author xins * @author xins
* @date 2023-09-04 * @date 2023-09-04
*/ */
@RestController @RestController
@RequestMapping("/deviceMode") @RequestMapping("/deviceMode")
public class HwDeviceModeController extends BaseController public class HwDeviceModeController extends BaseController {
{
@Autowired @Autowired
private IHwDeviceModeService hwDeviceModeService; private IHwDeviceModeService hwDeviceModeService;
@ -40,8 +49,7 @@ public class HwDeviceModeController extends BaseController
*/ */
@RequiresPermissions("business:deviceMode:list") @RequiresPermissions("business:deviceMode:list")
@GetMapping("/list") @GetMapping("/list")
public TableDataInfo list(HwDeviceMode hwDeviceMode) public TableDataInfo list(HwDeviceMode hwDeviceMode) {
{
startPage(); startPage();
List<HwDeviceMode> list = hwDeviceModeService.selectHwDeviceModeList(hwDeviceMode); List<HwDeviceMode> list = hwDeviceModeService.selectHwDeviceModeList(hwDeviceMode);
return getDataTable(list); return getDataTable(list);
@ -53,8 +61,7 @@ public class HwDeviceModeController extends BaseController
@RequiresPermissions("business:deviceMode:export") @RequiresPermissions("business:deviceMode:export")
@Log(title = "设备模型", businessType = BusinessType.EXPORT) @Log(title = "设备模型", businessType = BusinessType.EXPORT)
@PostMapping("/export") @PostMapping("/export")
public void export(HttpServletResponse response, HwDeviceMode hwDeviceMode) public void export(HttpServletResponse response, HwDeviceMode hwDeviceMode) {
{
List<HwDeviceMode> list = hwDeviceModeService.selectHwDeviceModeList(hwDeviceMode); List<HwDeviceMode> list = hwDeviceModeService.selectHwDeviceModeList(hwDeviceMode);
ExcelUtil<HwDeviceMode> util = new ExcelUtil<HwDeviceMode>(HwDeviceMode.class); ExcelUtil<HwDeviceMode> util = new ExcelUtil<HwDeviceMode>(HwDeviceMode.class);
util.exportExcel(response, list, "设备模型数据"); util.exportExcel(response, list, "设备模型数据");
@ -65,9 +72,16 @@ public class HwDeviceModeController extends BaseController
*/ */
@RequiresPermissions("business:deviceMode:query") @RequiresPermissions("business:deviceMode:query")
@GetMapping(value = "/{deviceModeId}") @GetMapping(value = "/{deviceModeId}")
public AjaxResult getInfo(@PathVariable("deviceModeId") Long deviceModeId) public AjaxResult getInfo(@PathVariable("deviceModeId") Long deviceModeId) {
{ HwDeviceMode hwDeviceMode = hwDeviceModeService.selectHwDeviceModeByDeviceModeId(deviceModeId);
return success(hwDeviceModeService.selectHwDeviceModeByDeviceModeId(deviceModeId)); List<HwDeviceModeFunction> hwDeviceModeFunctions = hwDeviceMode.getHwDeviceModeFunctionList();
hwDeviceMode.setHwDeviceModeFunctionList(null);
Map<String, List<HwDeviceModeFunction>> hwDeviceModeFunctionMap = hwDeviceModeFunctions.stream()
.collect(Collectors.groupingBy(HwDeviceModeFunction::getFunctionMode));
Map<String, Object> map = new HashMap<>();
map.put("deviceMode", hwDeviceMode);
map.put("deviceModeFunctionMap", hwDeviceModeFunctionMap);
return success(map);
} }
/** /**
@ -76,8 +90,7 @@ public class HwDeviceModeController extends BaseController
@RequiresPermissions("business:deviceMode:add") @RequiresPermissions("business:deviceMode:add")
@Log(title = "设备模型", businessType = BusinessType.INSERT) @Log(title = "设备模型", businessType = BusinessType.INSERT)
@PostMapping @PostMapping
public AjaxResult add(@RequestBody HwDeviceMode hwDeviceMode) public AjaxResult add(@RequestBody HwDeviceMode hwDeviceMode) {
{
return toAjax(hwDeviceModeService.insertHwDeviceMode(hwDeviceMode)); return toAjax(hwDeviceModeService.insertHwDeviceMode(hwDeviceMode));
} }
@ -87,8 +100,7 @@ public class HwDeviceModeController extends BaseController
@RequiresPermissions("business:deviceMode:edit") @RequiresPermissions("business:deviceMode:edit")
@Log(title = "设备模型", businessType = BusinessType.UPDATE) @Log(title = "设备模型", businessType = BusinessType.UPDATE)
@PutMapping @PutMapping
public AjaxResult edit(@RequestBody HwDeviceMode hwDeviceMode) public AjaxResult edit(@RequestBody HwDeviceMode hwDeviceMode) {
{
return toAjax(hwDeviceModeService.updateHwDeviceMode(hwDeviceMode)); return toAjax(hwDeviceModeService.updateHwDeviceMode(hwDeviceMode));
} }
@ -97,9 +109,9 @@ public class HwDeviceModeController extends BaseController
*/ */
@RequiresPermissions("business:deviceMode:remove") @RequiresPermissions("business:deviceMode:remove")
@Log(title = "设备模型", businessType = BusinessType.DELETE) @Log(title = "设备模型", businessType = BusinessType.DELETE)
@DeleteMapping("/{deviceModeIds}") @DeleteMapping("/{deviceModeIds}")
public AjaxResult remove(@PathVariable Long[] deviceModeIds) public AjaxResult remove(@PathVariable Long[] deviceModeIds) {
{
return toAjax(hwDeviceModeService.deleteHwDeviceModeByDeviceModeIds(deviceModeIds)); return toAjax(hwDeviceModeService.deleteHwDeviceModeByDeviceModeIds(deviceModeIds));
} }
} }

@ -1,74 +1,26 @@
package com.ruoyi.business.controller; package com.ruoyi.business.controller;
import java.util.List; import com.ruoyi.business.domain.HwDeviceModeFunction;
import java.io.IOException; import com.ruoyi.business.service.IHwDeviceModeService;
import javax.servlet.http.HttpServletResponse; import com.ruoyi.common.core.web.controller.BaseController;
import org.springframework.beans.factory.annotation.Autowired; import com.ruoyi.common.core.web.domain.AjaxResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log; import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType; import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions; import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.business.domain.HwDeviceModeFunction; import org.springframework.beans.factory.annotation.Autowired;
import com.ruoyi.business.service.IHwDeviceModeFunctionService; import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;
/** /**
* Controller * Controller
* *
* @author xins * @author xins
* @date 2023-09-05 * @date 2023-09-05
*/ */
@RestController @RestController
@RequestMapping("/deviceModeFunction") @RequestMapping("/deviceModeFunction")
public class HwDeviceModeFunctionController extends BaseController public class HwDeviceModeFunctionController extends BaseController {
{
@Autowired @Autowired
private IHwDeviceModeFunctionService hwDeviceModeFunctionService; private IHwDeviceModeService hwDeviceModeService;
/**
*
*/
@RequiresPermissions("business:deviceModeFunction:list")
@GetMapping("/list")
public TableDataInfo list(HwDeviceModeFunction hwDeviceModeFunction)
{
startPage();
List<HwDeviceModeFunction> list = hwDeviceModeFunctionService.selectHwDeviceModeFunctionList(hwDeviceModeFunction);
return getDataTable(list);
}
/**
*
*/
@RequiresPermissions("business:deviceModeFunction:export")
@Log(title = "设备模型功能", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, HwDeviceModeFunction hwDeviceModeFunction)
{
List<HwDeviceModeFunction> list = hwDeviceModeFunctionService.selectHwDeviceModeFunctionList(hwDeviceModeFunction);
ExcelUtil<HwDeviceModeFunction> util = new ExcelUtil<HwDeviceModeFunction>(HwDeviceModeFunction.class);
util.exportExcel(response, list, "设备模型功能数据");
}
/**
*
*/
@RequiresPermissions("business:deviceModeFunction:query")
@GetMapping(value = "/{modeFunctionId}")
public AjaxResult getInfo(@PathVariable("modeFunctionId") Long modeFunctionId)
{
return success(hwDeviceModeFunctionService.selectHwDeviceModeFunctionByModeFunctionId(modeFunctionId));
}
/** /**
* *
@ -76,9 +28,8 @@ public class HwDeviceModeFunctionController extends BaseController
@RequiresPermissions("business:deviceModeFunction:add") @RequiresPermissions("business:deviceModeFunction:add")
@Log(title = "设备模型功能", businessType = BusinessType.INSERT) @Log(title = "设备模型功能", businessType = BusinessType.INSERT)
@PostMapping @PostMapping
public AjaxResult add(@RequestBody HwDeviceModeFunction hwDeviceModeFunction) public AjaxResult add(@RequestBody HwDeviceModeFunction hwDeviceModeFunction) {
{ return success(hwDeviceModeService.insertHwDeviceModeFunction(hwDeviceModeFunction));
return toAjax(hwDeviceModeFunctionService.insertHwDeviceModeFunction(hwDeviceModeFunction));
} }
/** /**
@ -87,9 +38,8 @@ public class HwDeviceModeFunctionController extends BaseController
@RequiresPermissions("business:deviceModeFunction:edit") @RequiresPermissions("business:deviceModeFunction:edit")
@Log(title = "设备模型功能", businessType = BusinessType.UPDATE) @Log(title = "设备模型功能", businessType = BusinessType.UPDATE)
@PutMapping @PutMapping
public AjaxResult edit(@RequestBody HwDeviceModeFunction hwDeviceModeFunction) public AjaxResult edit(@RequestBody HwDeviceModeFunction hwDeviceModeFunction) {
{ return toAjax(hwDeviceModeService.updateHwDeviceModeFunction(hwDeviceModeFunction));
return toAjax(hwDeviceModeFunctionService.updateHwDeviceModeFunction(hwDeviceModeFunction));
} }
/** /**
@ -97,9 +47,13 @@ public class HwDeviceModeFunctionController extends BaseController
*/ */
@RequiresPermissions("business:deviceModeFunction:remove") @RequiresPermissions("business:deviceModeFunction:remove")
@Log(title = "设备模型功能", businessType = BusinessType.DELETE) @Log(title = "设备模型功能", businessType = BusinessType.DELETE)
@DeleteMapping("/{modeFunctionIds}") @DeleteMapping("/{modeFunctionId}")
public AjaxResult remove(@PathVariable Long[] modeFunctionIds) public AjaxResult remove(@PathVariable Long modeFunctionId) {
{ return toAjax(hwDeviceModeService.deleteHwDeviceModeFunctionByModeFunctionId(modeFunctionId));
return toAjax(hwDeviceModeFunctionService.deleteHwDeviceModeFunctionByModeFunctionIds(modeFunctionIds)); }
@GetMapping("/getDeviceModeParameters/{modeFunctionId}")
public AjaxResult getDeviceModeParameters(@PathVariable("modeFunctionId") Long modeFunctionId) {
return success(hwDeviceModeService.selectDeviceModeParametersByModeFunctionId(modeFunctionId));
} }
} }

@ -11,7 +11,7 @@ import com.ruoyi.common.core.web.domain.BaseEntity;
* hw_device * hw_device
* *
* @author xins * @author xins
* @date 2023-08-24 * @date 2023-09-13
*/ */
public class HwDevice extends BaseEntity public class HwDevice extends BaseEntity
{ {
@ -106,6 +106,14 @@ public class HwDevice extends BaseEntity
@Excel(name = "预留字段") @Excel(name = "预留字段")
private String deviceField; private String deviceField;
/** 租户ID关联hw_tenant的tenant_id */
@Excel(name = "租户ID关联hw_tenant的tenant_id")
private Long tenantId;
/** 在线状态1、在线0、离线 */
@Excel(name = "在线状态", readConverterExp = "1=、在线0、离线")
private String onlineStatus;
public void setDeviceId(Long deviceId) public void setDeviceId(Long deviceId)
{ {
this.deviceId = deviceId; this.deviceId = deviceId;
@ -304,6 +312,24 @@ public class HwDevice extends BaseEntity
{ {
return deviceField; return deviceField;
} }
public void setTenantId(Long tenantId)
{
this.tenantId = tenantId;
}
public Long getTenantId()
{
return tenantId;
}
public void setOnlineStatus(String onlineStatus)
{
this.onlineStatus = onlineStatus;
}
public String getOnlineStatus()
{
return onlineStatus;
}
@Override @Override
public String toString() { public String toString() {
@ -335,6 +361,8 @@ public class HwDevice extends BaseEntity
.append("updateBy", getUpdateBy()) .append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime()) .append("updateTime", getUpdateTime())
.append("deviceField", getDeviceField()) .append("deviceField", getDeviceField())
.append("tenantId", getTenantId())
.append("onlineStatus", getOnlineStatus())
.toString(); .toString();
} }
} }

@ -1,6 +1,8 @@
package com.ruoyi.business.domain; package com.ruoyi.business.domain;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.List;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.core.annotation.Excel; import com.ruoyi.common.core.annotation.Excel;
@ -110,6 +112,12 @@ public class HwDeviceModeFunction extends BaseEntity
@Excel(name = "预留字段") @Excel(name = "预留字段")
private String propertyField; private String propertyField;
private List<HwDeviceModeParameter> inputParameters;
private List<HwDeviceModeParameter> outputParameters;
// private List<HwDeviceP>
public void setModeFunctionId(Long modeFunctionId) public void setModeFunctionId(Long modeFunctionId)
{ {
this.modeFunctionId = modeFunctionId; this.modeFunctionId = modeFunctionId;
@ -291,6 +299,22 @@ public class HwDeviceModeFunction extends BaseEntity
return propertyField; return propertyField;
} }
public List<HwDeviceModeParameter> getInputParameters() {
return inputParameters;
}
public void setInputParameters(List<HwDeviceModeParameter> inputParameters) {
this.inputParameters = inputParameters;
}
public List<HwDeviceModeParameter> getOutputParameters() {
return outputParameters;
}
public void setOutputParameters(List<HwDeviceModeParameter> outputParameters) {
this.outputParameters = outputParameters;
}
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

@ -0,0 +1,173 @@
package com.ruoyi.business.domain;
import java.math.BigDecimal;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.core.annotation.Excel;
import com.ruoyi.common.core.web.domain.BaseEntity;
/**
* hw_device_mode_parameter
*
* @author xins
* @date 2023-09-11
*/
public class HwDeviceModeParameter extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 设备属性参数ID */
private Long modeParameterId;
/** 设备模型功能ID关联表hw_device_mode_function的字段mode_function_id */
@Excel(name = "设备模型功能ID关联表hw_device_mode_function的字段mode_function_id")
private Long modeFunctionId;
/** 设备属性参数ID,关联本表的字段mode_parameter_id。如果数据类型为struct类型定义json参数时需要用此字段 */
@Excel(name = "设备属性参数ID,关联本表的字段mode_parameter_id。如果数据类型为struct类型定义json参数时需要用此字段")
private Long releatedParameterId;
/** 参数类型1、输入参数2、输出参数 */
@Excel(name = "参数类型", readConverterExp = "1=、输入参数2、输出参数")
private String parameterType;
/** 参数名称 */
@Excel(name = "参数名称")
private String parameterName;
/** 标识符支持大小写字母、数字和下划线对外暂时不超过50个字符 */
@Excel(name = "标识符", readConverterExp = "支=持大小写字母、数字和下划线对外暂时不超过50个字符")
private String parameterIdentifier;
/** 数据类型(在平台字典表中定义) */
@Excel(name = "数据类型", readConverterExp = "在=平台字典表中定义")
private String dataType;
/** json
1{'minValue':1,'maxValue':100},
2
{'1':'','2','','3','}
3bool
{'0':'关','1','开'}
4Text
{'dataLength'1024}
5Date
{'dateFormat':'StringUTC()'} */
@Excel(name = "数据定义按json保存")
private String dataDefinition;
/** 单位 */
@Excel(name = "单位")
private String propertyUnit;
/** 预留字段,步长 */
@Excel(name = "预留字段,步长")
private BigDecimal propertyStep;
public void setModeParameterId(Long modeParameterId)
{
this.modeParameterId = modeParameterId;
}
public Long getModeParameterId()
{
return modeParameterId;
}
public void setModeFunctionId(Long modeFunctionId)
{
this.modeFunctionId = modeFunctionId;
}
public Long getModeFunctionId()
{
return modeFunctionId;
}
public void setReleatedParameterId(Long releatedParameterId)
{
this.releatedParameterId = releatedParameterId;
}
public Long getReleatedParameterId()
{
return releatedParameterId;
}
public void setParameterType(String parameterType)
{
this.parameterType = parameterType;
}
public String getParameterType()
{
return parameterType;
}
public void setParameterName(String parameterName)
{
this.parameterName = parameterName;
}
public String getParameterName()
{
return parameterName;
}
public void setParameterIdentifier(String parameterIdentifier)
{
this.parameterIdentifier = parameterIdentifier;
}
public String getParameterIdentifier()
{
return parameterIdentifier;
}
public void setDataType(String dataType)
{
this.dataType = dataType;
}
public String getDataType()
{
return dataType;
}
public void setDataDefinition(String dataDefinition)
{
this.dataDefinition = dataDefinition;
}
public String getDataDefinition()
{
return dataDefinition;
}
public void setPropertyUnit(String propertyUnit)
{
this.propertyUnit = propertyUnit;
}
public String getPropertyUnit()
{
return propertyUnit;
}
public void setPropertyStep(BigDecimal propertyStep)
{
this.propertyStep = propertyStep;
}
public BigDecimal getPropertyStep()
{
return propertyStep;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("modeParameterId", getModeParameterId())
.append("modeFunctionId", getModeFunctionId())
.append("releatedParameterId", getReleatedParameterId())
.append("parameterType", getParameterType())
.append("parameterName", getParameterName())
.append("parameterIdentifier", getParameterIdentifier())
.append("dataType", getDataType())
.append("dataDefinition", getDataDefinition())
.append("propertyUnit", getPropertyUnit())
.append("propertyStep", getPropertyStep())
.toString();
}
}

@ -3,6 +3,7 @@ package com.ruoyi.business.mapper;
import java.util.List; import java.util.List;
import com.ruoyi.business.domain.HwDeviceMode; import com.ruoyi.business.domain.HwDeviceMode;
import com.ruoyi.business.domain.HwDeviceModeFunction; import com.ruoyi.business.domain.HwDeviceModeFunction;
import com.ruoyi.business.domain.HwDeviceModeParameter;
/** /**
* Mapper * Mapper
@ -84,4 +85,54 @@ public interface HwDeviceModeMapper
* @return * @return
*/ */
public int deleteHwDeviceModeFunctionByDeviceModeId(Long deviceModeId); public int deleteHwDeviceModeFunctionByDeviceModeId(Long deviceModeId);
/**
*
*
* @param hwDeviceModeFunction
* @return
*/
public int insertHwDeviceModeFunction(HwDeviceModeFunction hwDeviceModeFunction);
/**
*
*
* @param hwDeviceModeFunction
* @return
*/
public int updateHwDeviceModeFunction(HwDeviceModeFunction hwDeviceModeFunction);
/**
*
*
* @param modeFunctionId
* @return
*/
public int deleteHwDeviceModeFunctionByModeFunctionId(Long modeFunctionId);
/**
*
*
* @param hwDeviceModeParameterList
* @return
*/
public int batchHwDeviceModeParameters(List<HwDeviceModeParameter> hwDeviceModeParameterList);
/**
*
*
* @param deviceModeId ID
* @return
*/
public int deleteHwDeviceModeParameterByModeFunctionId(Long modeFunctionId);
/**
* @param: modeFunctionId
* @description
* @author xins
* @date 2023-09-12 10:44
* @return List<HwDeviceModeParameter>
*/
public List<HwDeviceModeParameter> selectDeviceModeParametersByModeFunctionId(Long modeFunctionId);
} }

@ -1,61 +0,0 @@
package com.ruoyi.business.service;
import java.util.List;
import com.ruoyi.business.domain.HwDeviceModeFunction;
/**
* Service
*
* @author xins
* @date 2023-09-05
*/
public interface IHwDeviceModeFunctionService
{
/**
*
*
* @param modeFunctionId
* @return
*/
public HwDeviceModeFunction selectHwDeviceModeFunctionByModeFunctionId(Long modeFunctionId);
/**
*
*
* @param hwDeviceModeFunction
* @return
*/
public List<HwDeviceModeFunction> selectHwDeviceModeFunctionList(HwDeviceModeFunction hwDeviceModeFunction);
/**
*
*
* @param hwDeviceModeFunction
* @return
*/
public int insertHwDeviceModeFunction(HwDeviceModeFunction hwDeviceModeFunction);
/**
*
*
* @param hwDeviceModeFunction
* @return
*/
public int updateHwDeviceModeFunction(HwDeviceModeFunction hwDeviceModeFunction);
/**
*
*
* @param modeFunctionIds
* @return
*/
public int deleteHwDeviceModeFunctionByModeFunctionIds(Long[] modeFunctionIds);
/**
*
*
* @param modeFunctionId
* @return
*/
public int deleteHwDeviceModeFunctionByModeFunctionId(Long modeFunctionId);
}

@ -1,7 +1,11 @@
package com.ruoyi.business.service; package com.ruoyi.business.service;
import java.util.List; import java.util.List;
import java.util.Map;
import com.ruoyi.business.domain.HwDeviceMode; import com.ruoyi.business.domain.HwDeviceMode;
import com.ruoyi.business.domain.HwDeviceModeFunction;
import com.ruoyi.business.domain.HwDeviceModeParameter;
/** /**
* Service * Service
@ -58,4 +62,41 @@ public interface IHwDeviceModeService
* @return * @return
*/ */
public int deleteHwDeviceModeByDeviceModeId(Long deviceModeId); public int deleteHwDeviceModeByDeviceModeId(Long deviceModeId);
/**
*
*
* @param hwDeviceModeFunction
* @return
*/
public Long insertHwDeviceModeFunction(HwDeviceModeFunction hwDeviceModeFunction);
/**
*
*
* @param hwDeviceModeFunction
* @return
*/
public int updateHwDeviceModeFunction(HwDeviceModeFunction hwDeviceModeFunction);
/**
*
*
* @param modeFunctionId
* @return
*/
public int deleteHwDeviceModeFunctionByModeFunctionId(Long modeFunctionId);
/**
* @param: modeFunctionId
* @description
* @author xins
* @date 2023-09-12 10:45
* @return Map<String, List<HwDeviceModeParameter>>
*/
public Map<String, List<HwDeviceModeParameter>> selectDeviceModeParametersByModeFunctionId(Long modeFunctionId);
} }

@ -1,93 +0,0 @@
package com.ruoyi.business.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.business.mapper.HwDeviceModeFunctionMapper;
import com.ruoyi.business.domain.HwDeviceModeFunction;
import com.ruoyi.business.service.IHwDeviceModeFunctionService;
/**
* Service
*
* @author xins
* @date 2023-09-05
*/
@Service
public class HwDeviceModeFunctionServiceImpl implements IHwDeviceModeFunctionService
{
@Autowired
private HwDeviceModeFunctionMapper hwDeviceModeFunctionMapper;
/**
*
*
* @param modeFunctionId
* @return
*/
@Override
public HwDeviceModeFunction selectHwDeviceModeFunctionByModeFunctionId(Long modeFunctionId)
{
return hwDeviceModeFunctionMapper.selectHwDeviceModeFunctionByModeFunctionId(modeFunctionId);
}
/**
*
*
* @param hwDeviceModeFunction
* @return
*/
@Override
public List<HwDeviceModeFunction> selectHwDeviceModeFunctionList(HwDeviceModeFunction hwDeviceModeFunction)
{
return hwDeviceModeFunctionMapper.selectHwDeviceModeFunctionList(hwDeviceModeFunction);
}
/**
*
*
* @param hwDeviceModeFunction
* @return
*/
@Override
public int insertHwDeviceModeFunction(HwDeviceModeFunction hwDeviceModeFunction)
{
return hwDeviceModeFunctionMapper.insertHwDeviceModeFunction(hwDeviceModeFunction);
}
/**
*
*
* @param hwDeviceModeFunction
* @return
*/
@Override
public int updateHwDeviceModeFunction(HwDeviceModeFunction hwDeviceModeFunction)
{
return hwDeviceModeFunctionMapper.updateHwDeviceModeFunction(hwDeviceModeFunction);
}
/**
*
*
* @param modeFunctionIds
* @return
*/
@Override
public int deleteHwDeviceModeFunctionByModeFunctionIds(Long[] modeFunctionIds)
{
return hwDeviceModeFunctionMapper.deleteHwDeviceModeFunctionByModeFunctionIds(modeFunctionIds);
}
/**
*
*
* @param modeFunctionId
* @return
*/
@Override
public int deleteHwDeviceModeFunctionByModeFunctionId(Long modeFunctionId)
{
return hwDeviceModeFunctionMapper.deleteHwDeviceModeFunctionByModeFunctionId(modeFunctionId);
}
}

@ -1,134 +1,454 @@
package com.ruoyi.business.service.impl; package com.ruoyi.business.service.impl;
import java.util.List; import com.ruoyi.business.domain.HwDevice;
import com.ruoyi.business.domain.HwDeviceMode;
import com.ruoyi.business.domain.HwDeviceModeFunction;
import com.ruoyi.business.domain.HwDeviceModeParameter;
import com.ruoyi.business.mapper.HwDeviceMapper;
import com.ruoyi.business.mapper.HwDeviceModeMapper;
import com.ruoyi.business.service.IHwDeviceModeService;
import com.ruoyi.common.core.constant.HwDictConstants;
import com.ruoyi.common.core.constant.TdEngineConstants;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.enums.DataTypeEnums;
import com.ruoyi.common.core.exception.ServiceException;
import com.ruoyi.common.core.utils.DateUtils; import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.system.api.RemoteConfigService;
import com.ruoyi.tdengine.api.RemoteTdEngineService;
import com.ruoyi.tdengine.api.domain.TdField;
import com.ruoyi.tdengine.api.domain.TdSuperTableVo;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList;
import com.ruoyi.common.core.utils.StringUtils;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import com.ruoyi.business.domain.HwDeviceModeFunction;
import com.ruoyi.business.mapper.HwDeviceModeMapper; import javax.annotation.Resource;
import com.ruoyi.business.domain.HwDeviceMode; import java.util.ArrayList;
import com.ruoyi.business.service.IHwDeviceModeService; import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/** /**
* Service * Service
* *
* @author xins * @author xins
* @date 2023-09-04 * @date 2023-09-04
*/ */
@Service @Service
public class HwDeviceModeServiceImpl implements IHwDeviceModeService public class HwDeviceModeServiceImpl implements IHwDeviceModeService {
{
@Autowired @Autowired
private HwDeviceModeMapper hwDeviceModeMapper; private HwDeviceModeMapper hwDeviceModeMapper;
@Autowired
private HwDeviceModeFunctionMapper hwDeviceModeFunctionMapper;
@Autowired
private HwDeviceMapper hwDeviceMapper;
@Resource
private RemoteConfigService remoteConfigService;
@Resource
private RemoteTdEngineService remoteTdEngineService;
/** /**
* *
* *
* @param deviceModeId * @param deviceModeId
* @return * @return
*/ */
@Override @Override
public HwDeviceMode selectHwDeviceModeByDeviceModeId(Long deviceModeId) public HwDeviceMode selectHwDeviceModeByDeviceModeId(Long deviceModeId) {
{
return hwDeviceModeMapper.selectHwDeviceModeByDeviceModeId(deviceModeId); return hwDeviceModeMapper.selectHwDeviceModeByDeviceModeId(deviceModeId);
} }
/** /**
* *
* *
* @param hwDeviceMode * @param hwDeviceMode
* @return * @return
*/ */
@Override @Override
public List<HwDeviceMode> selectHwDeviceModeList(HwDeviceMode hwDeviceMode) public List<HwDeviceMode> selectHwDeviceModeList(HwDeviceMode hwDeviceMode) {
{
return hwDeviceModeMapper.selectHwDeviceModeList(hwDeviceMode); return hwDeviceModeMapper.selectHwDeviceModeList(hwDeviceMode);
} }
/** /**
* *
* *
* @param hwDeviceMode * @param hwDeviceMode
* @return * @return
*/ */
@Transactional @Transactional
@Override @Override
public int insertHwDeviceMode(HwDeviceMode hwDeviceMode) public int insertHwDeviceMode(HwDeviceMode hwDeviceMode) {
{ //先判断是否有重复的标识符
List<HwDeviceModeFunction> hwDeviceModeFunctionList = hwDeviceMode.getHwDeviceModeFunctionList();
List<String> duplicateFunctionIdentifiers = hwDeviceModeFunctionList.stream()
.collect(Collectors.groupingBy(p -> p.getFunctionIdentifier(), Collectors.counting())).entrySet().stream()
.filter(entry -> entry.getValue() > 1) // >1 查找重复的集合;== 查找不重复的集合
.map(entry -> entry.getKey())
.collect(Collectors.toList());
if (duplicateFunctionIdentifiers != null && !duplicateFunctionIdentifiers.isEmpty()) {
throw new ServiceException("存在重复的标识符:" + duplicateFunctionIdentifiers.toString());
}
//再判断是否不是定位的标识符与定位标识符相同
R<String> keyLongitudeR = remoteConfigService.getConfigKeyStr("hw.gps.longitude");
R<String> keyLatitudeR = remoteConfigService.getConfigKeyStr("hw.gps.latitude");
String keyLongitude = keyLongitudeR.getData();
String keyLatitude = keyLatitudeR.getData();
hwDeviceModeFunctionList.forEach(d -> {
if (d.getFunctionIdentifier().equalsIgnoreCase(TdEngineConstants.DEFAULT_FIRST_FIELD_NAME)) {
throw new ServiceException("标识符不能等于:" + TdEngineConstants.DEFAULT_FIRST_FIELD_NAME);
}
if (StringUtils.isEmpty(d.getCoordinate()) &&
(d.getFunctionIdentifier().equalsIgnoreCase(keyLongitude)
|| d.getFunctionIdentifier().equalsIgnoreCase(keyLatitude))) {
throw new ServiceException("非定位设备模型标识符不能等于:" + keyLongitude + "或" + keyLatitude);
}
});
hwDeviceMode.setCreateTime(DateUtils.getNowDate()); hwDeviceMode.setCreateTime(DateUtils.getNowDate());
hwDeviceMode.setCreateBy(SecurityUtils.getUsername());
int rows = hwDeviceModeMapper.insertHwDeviceMode(hwDeviceMode); int rows = hwDeviceModeMapper.insertHwDeviceMode(hwDeviceMode);
insertHwDeviceModeFunction(hwDeviceMode); batchInsertHwDeviceModeFunction(hwDeviceMode);
this.createTdSuperTable(hwDeviceMode);
return rows; return rows;
} }
/** /**
* *
* *
* @param hwDeviceMode * @param hwDeviceMode
* @return * @return
*/ */
@Transactional @Transactional
@Override @Override
public int updateHwDeviceMode(HwDeviceMode hwDeviceMode) public int updateHwDeviceMode(HwDeviceMode hwDeviceMode) {
{ hwDeviceMode.setUpdateBy(SecurityUtils.getUsername());
hwDeviceMode.setUpdateTime(DateUtils.getNowDate()); hwDeviceMode.setUpdateTime(DateUtils.getNowDate());
hwDeviceModeMapper.deleteHwDeviceModeFunctionByDeviceModeId(hwDeviceMode.getDeviceModeId()); // hwDeviceModeMapper.deleteHwDeviceModeFunctionByDeviceModeId(hwDeviceMode.getDeviceModeId());
insertHwDeviceModeFunction(hwDeviceMode); // insertHwDeviceModeFunction(hwDeviceMode);
return hwDeviceModeMapper.updateHwDeviceMode(hwDeviceMode); return hwDeviceModeMapper.updateHwDeviceMode(hwDeviceMode);
} }
/** /**
* *
* *
* @param deviceModeIds * @param deviceModeIds
* @return * @return
*/ */
@Transactional @Transactional
@Override @Override
public int deleteHwDeviceModeByDeviceModeIds(Long[] deviceModeIds) public int deleteHwDeviceModeByDeviceModeIds(Long[] deviceModeIds) {
{
hwDeviceModeMapper.deleteHwDeviceModeFunctionByDeviceModeIds(deviceModeIds); hwDeviceModeMapper.deleteHwDeviceModeFunctionByDeviceModeIds(deviceModeIds);
return hwDeviceModeMapper.deleteHwDeviceModeByDeviceModeIds(deviceModeIds); return hwDeviceModeMapper.deleteHwDeviceModeByDeviceModeIds(deviceModeIds);
} }
/** /**
* *
* *
* @param deviceModeId * @param deviceModeId
* @return * @return
*/ */
@Transactional @Transactional
@Override @Override
public int deleteHwDeviceModeByDeviceModeId(Long deviceModeId) public int deleteHwDeviceModeByDeviceModeId(Long deviceModeId) {
{
hwDeviceModeMapper.deleteHwDeviceModeFunctionByDeviceModeId(deviceModeId); hwDeviceModeMapper.deleteHwDeviceModeFunctionByDeviceModeId(deviceModeId);
return hwDeviceModeMapper.deleteHwDeviceModeByDeviceModeId(deviceModeId); return hwDeviceModeMapper.deleteHwDeviceModeByDeviceModeId(deviceModeId);
} }
/** /**
* *
* *
* @param hwDeviceMode * @param hwDeviceMode
*/ */
public void insertHwDeviceModeFunction(HwDeviceMode hwDeviceMode) private void batchInsertHwDeviceModeFunction(HwDeviceMode hwDeviceMode) {
{
List<HwDeviceModeFunction> hwDeviceModeFunctionList = hwDeviceMode.getHwDeviceModeFunctionList(); List<HwDeviceModeFunction> hwDeviceModeFunctionList = hwDeviceMode.getHwDeviceModeFunctionList();
Long deviceModeId = hwDeviceMode.getDeviceModeId(); Long deviceModeId = hwDeviceMode.getDeviceModeId();
if (StringUtils.isNotNull(hwDeviceModeFunctionList)) if (StringUtils.isNotNull(hwDeviceModeFunctionList)) {
{ List<HwDeviceModeFunction> list = new ArrayList<>();
List<HwDeviceModeFunction> list = new ArrayList<HwDeviceModeFunction>(); for (HwDeviceModeFunction hwDeviceModeFunction : hwDeviceModeFunctionList) {
for (HwDeviceModeFunction hwDeviceModeFunction : hwDeviceModeFunctionList)
{
hwDeviceModeFunction.setDeviceModeId(deviceModeId); hwDeviceModeFunction.setDeviceModeId(deviceModeId);
list.add(hwDeviceModeFunction); list.add(hwDeviceModeFunction);
} }
if (list.size() > 0) if (list.size() > 0) {
{
hwDeviceModeMapper.batchHwDeviceModeFunction(list); hwDeviceModeMapper.batchHwDeviceModeFunction(list);
batchInsertHwDeviceModeParameters(list);
} }
} }
} }
/**
* @param: list
* @description
* @author xins
* @date 2023-09-12 9:54
*/
private void batchInsertHwDeviceModeParameters(List<HwDeviceModeFunction> list) {
List<HwDeviceModeParameter> toInsertedParameters = new ArrayList<>();
for (HwDeviceModeFunction insertedDeviceModeFunction : list) {
List<HwDeviceModeParameter> inputParameters = insertedDeviceModeFunction.getInputParameters();
List<HwDeviceModeParameter> outputParameters = insertedDeviceModeFunction.getOutputParameters();
if (inputParameters != null && !inputParameters.isEmpty()) {
for (HwDeviceModeParameter inputParameter : inputParameters) {
inputParameter.setModeFunctionId(insertedDeviceModeFunction.getModeFunctionId());
toInsertedParameters.add(inputParameter);
}
}
if (outputParameters != null && !outputParameters.isEmpty()) {
for (HwDeviceModeParameter outputParameter : outputParameters) {
outputParameter.setModeFunctionId(insertedDeviceModeFunction.getModeFunctionId());
toInsertedParameters.add(outputParameter);
}
}
}
if (!toInsertedParameters.isEmpty()) {
hwDeviceModeMapper.batchHwDeviceModeParameters(toInsertedParameters);
}
}
/**
*
*
* @param hwDeviceModeFunction
* @return
*/
@Override
@Transactional
public Long insertHwDeviceModeFunction(HwDeviceModeFunction hwDeviceModeFunction) {
checkDuplicateIdentifiers(hwDeviceModeFunction);
int rows = hwDeviceModeMapper.insertHwDeviceModeFunction(hwDeviceModeFunction);
List<HwDeviceModeFunction> hwDeviceModeFunctions = new ArrayList<>();
hwDeviceModeFunctions.add(hwDeviceModeFunction);
batchInsertHwDeviceModeParameters(hwDeviceModeFunctions);
this.addTdSuperTableColumn(hwDeviceModeFunction);
return hwDeviceModeFunction.getModeFunctionId();
}
/**
*
*
* @param hwDeviceModeFunction
* @return
*/
@Override
@Transactional
public int updateHwDeviceModeFunction(HwDeviceModeFunction hwDeviceModeFunction) {
//查询是否有已发布的设备关联此设备模型
HwDevice queryHwDevice = new HwDevice();
queryHwDevice.setDeviceModeId(hwDeviceModeFunction.getDeviceModeId());
queryHwDevice.setDeviceStatus(HwDictConstants.DEVICE_STATUS_PUBLISH);
List<HwDevice> hwDevices = hwDeviceMapper.selectHwDeviceList(queryHwDevice);
if (hwDevices.size() > 0) {
throw new ServiceException("已有已发布状态设备关联,不能修改");
}
checkDuplicateIdentifiers(hwDeviceModeFunction);
hwDeviceModeMapper.deleteHwDeviceModeParameterByModeFunctionId(hwDeviceModeFunction.getModeFunctionId());
List<HwDeviceModeFunction> hwDeviceModeFunctions = new ArrayList<>();
hwDeviceModeFunctions.add(hwDeviceModeFunction);
batchInsertHwDeviceModeParameters(hwDeviceModeFunctions);
//与数据库中的数据判断标识符有没有修改如果修改则在tdengine超级表删除老的字段增加修改的字段
String functionMode = hwDeviceModeFunction.getFunctionMode();
if (functionMode.equals(HwDictConstants.FUNCTION_MODE_ATTRIBUTE)) {
HwDeviceModeFunction dbHwDeviceModeFunction = hwDeviceModeFunctionMapper
.selectHwDeviceModeFunctionByModeFunctionId(hwDeviceModeFunction.getModeFunctionId());
String dbFunctionIdentifier = dbHwDeviceModeFunction.getFunctionIdentifier();
String functionIdentifier = hwDeviceModeFunction.getFunctionIdentifier();
Long dbDataType = dbHwDeviceModeFunction.getDataType();
Long dataType = hwDeviceModeFunction.getDataType();
//标识符或数据类型变化时需要先删除超级表column再增加新的column
if (!dbFunctionIdentifier.equalsIgnoreCase(functionIdentifier)
|| !dbDataType.equals(dataType)) {
this.dropTdSuperTableColumn(dbHwDeviceModeFunction);
this.addTdSuperTableColumn(hwDeviceModeFunction);
}
}
return hwDeviceModeMapper.updateHwDeviceModeFunction(hwDeviceModeFunction);
}
/**
*
*
* @param modeFunctionId
* @return
*/
@Override
@Transactional
public int deleteHwDeviceModeFunctionByModeFunctionId(Long modeFunctionId) {
HwDeviceModeFunction hwDeviceModeFunction = hwDeviceModeFunctionMapper.selectHwDeviceModeFunctionByModeFunctionId(modeFunctionId);
hwDeviceModeMapper.deleteHwDeviceModeParameterByModeFunctionId(modeFunctionId);
int rows = hwDeviceModeMapper.deleteHwDeviceModeFunctionByModeFunctionId(modeFunctionId);
this.dropTdSuperTableColumn(hwDeviceModeFunction);
return rows;
}
/**
* @return Map<String, List < HwDeviceModeParameter>>
* @param: modeFunctionId
* @description (map)
* @author xins
* @date 2023-09-12 10:45
*/
@Override
public Map<String, List<HwDeviceModeParameter>> selectDeviceModeParametersByModeFunctionId(Long modeFunctionId) {
List<HwDeviceModeParameter> hwDeviceModeParameters = hwDeviceModeMapper.selectDeviceModeParametersByModeFunctionId(modeFunctionId);
Map<String, List<HwDeviceModeParameter>> hwDeviceModeParametersMap = hwDeviceModeParameters.stream()
.collect(Collectors.groupingBy(HwDeviceModeParameter::getParameterType));
return hwDeviceModeParametersMap;
}
/**
* @param: hwDeviceModeFunction
* @description
* @author xins
* @date 2023-09-13 13:38
*/
private void checkDuplicateIdentifiers(HwDeviceModeFunction hwDeviceModeFunction) {
if (hwDeviceModeFunction.getFunctionIdentifier().equalsIgnoreCase(TdEngineConstants.DEFAULT_FIRST_FIELD_NAME)) {
throw new ServiceException("标识符不能等于:" + TdEngineConstants.DEFAULT_FIRST_FIELD_NAME);
}
R<String> keyLongitudeR = remoteConfigService.getConfigKeyStr("hw.gps.longitude");
R<String> keyLatitudeR = remoteConfigService.getConfigKeyStr("hw.gps.latitude");
String keyLongitude = keyLongitudeR.getData();
String keyLatitude = keyLatitudeR.getData();
if (StringUtils.isEmpty(hwDeviceModeFunction.getCoordinate()) &&
(hwDeviceModeFunction.getFunctionIdentifier().equalsIgnoreCase(keyLongitude)
|| hwDeviceModeFunction.getFunctionIdentifier().equalsIgnoreCase(keyLatitude))) {
throw new ServiceException("非定位设备模型标识符不能等于:" + keyLongitude + "或" + keyLatitude);
}
Long deviceModeId = hwDeviceModeFunction.getDeviceModeId();
HwDeviceModeFunction queryDeviceModeFunction = new HwDeviceModeFunction();
queryDeviceModeFunction.setDeviceModeId(deviceModeId);
List<HwDeviceModeFunction> hwDeviceModeFunctions = hwDeviceModeFunctionMapper.selectHwDeviceModeFunctionList(queryDeviceModeFunction);
/**
*
*/
long duplicateCount = hwDeviceModeFunctions.stream().filter(dmf ->
((hwDeviceModeFunction.getModeFunctionId() == null) ||
(hwDeviceModeFunction.getModeFunctionId() != null && !hwDeviceModeFunction.getModeFunctionId().equals(dmf.getModeFunctionId())))
&& dmf.getFunctionIdentifier().equalsIgnoreCase(hwDeviceModeFunction.getFunctionIdentifier())).count();
if (duplicateCount > 0) {
throw new ServiceException("标识符重复");
}
}
private void createTdSuperTable(HwDeviceMode hwDeviceMode) {
TdSuperTableVo tdSuperTableVo = new TdSuperTableVo();
Long sceneId = hwDeviceMode.getSceneId();
String dbName = TdEngineConstants.DEFAULT_DB_NAME_PREFIX + sceneId;
String superTableName = TdEngineConstants.DEFAULT_SUPER_TABLE_NAME_PREFIX + hwDeviceMode.getDeviceModeId();
List<TdField> tagFields = new ArrayList<TdField>();
TdField tagField = new TdField();
tagField.setFieldName(TdEngineConstants.ST_TAG_DEVICECODE);
tagField.setDataTypeCode(TdEngineConstants.ST_TAG_DEVICECODE_TYPE);
tagField.setSize(TdEngineConstants.ST_TAG_DEVICECODE_SIZE);
tagFields.add(tagField);
tagField = new TdField();
tagField.setFieldName(TdEngineConstants.ST_TAG_DEVICENAME);
tagField.setDataTypeCode(TdEngineConstants.ST_TAG_DEVICENAME_TYPE);
tagField.setSize(TdEngineConstants.ST_TAG_DEVICENAME_SIZE);
tagFields.add(tagField);
tagField = new TdField();
tagField.setFieldName(TdEngineConstants.ST_TAG_DEVICEID);
tagField.setDataTypeCode(TdEngineConstants.ST_TAG_DEVICEID_TYPE);
tagFields.add(tagField);
tagField = new TdField();
tagField.setFieldName(TdEngineConstants.ST_TAG_DEVICEMODEID);
tagField.setDataTypeCode(TdEngineConstants.ST_TAG_DEVICEMODEID_TYPE);
tagFields.add(tagField);
tagField = new TdField();
tagField.setFieldName(TdEngineConstants.ST_TAG_MONITORUNITID);
tagField.setDataTypeCode(TdEngineConstants.ST_TAG_MONITORUNITID_TYPE);
tagFields.add(tagField);
List<TdField> schemaFields = new ArrayList<TdField>();
List<HwDeviceModeFunction> hwDeviceModeFunctions = hwDeviceMode.getHwDeviceModeFunctionList();
TdField schemaField;
for (HwDeviceModeFunction hwDeviceModeFunction : hwDeviceModeFunctions) {
String functionMode = hwDeviceModeFunction.getFunctionMode();
if (functionMode.equalsIgnoreCase(HwDictConstants.FUNCTION_MODE_ATTRIBUTE)) {
schemaField = new TdField();
schemaField.setFieldName(hwDeviceModeFunction.getFunctionIdentifier());
Long dataType = hwDeviceModeFunction.getDataType();
schemaField.setDataTypeCode(dataType.intValue());
if (String.valueOf(dataType).equals(String.valueOf(DataTypeEnums.NCHAR.getDataCode()))) {
schemaField.setSize(Integer.valueOf(hwDeviceModeFunction.getDataDefinition()));
}
schemaFields.add(schemaField);
}
}
tdSuperTableVo.setDatabaseName(dbName);
tdSuperTableVo.setSuperTableName(superTableName);
tdSuperTableVo.setFirstFieldName(TdEngineConstants.DEFAULT_FIRST_FIELD_NAME);
tdSuperTableVo.setSchemaFields(schemaFields);
tdSuperTableVo.setTagsFields(tagFields);
this.remoteTdEngineService.createSuperTable(tdSuperTableVo);
}
private void addTdSuperTableColumn(HwDeviceModeFunction hwDeviceModeFunction) {
String functionMode = hwDeviceModeFunction.getFunctionMode();
if (functionMode.equals(HwDictConstants.FUNCTION_MODE_ATTRIBUTE)) {
Long deviceModeId = hwDeviceModeFunction.getDeviceModeId();
HwDeviceMode hwDeviceMode = hwDeviceModeMapper.selectHwDeviceModeByDeviceModeId(deviceModeId);
String dbName = TdEngineConstants.DEFAULT_DB_NAME_PREFIX + hwDeviceMode.getSceneId();
String superTableName = TdEngineConstants.DEFAULT_SUPER_TABLE_NAME_PREFIX + deviceModeId;
TdSuperTableVo tdSuperTableVo = new TdSuperTableVo();
TdField schemaField = new TdField();
schemaField.setFieldName(hwDeviceModeFunction.getFunctionIdentifier());
Long dataType = hwDeviceModeFunction.getDataType();
schemaField.setDataTypeCode(dataType.intValue());
//一个integer类型一个long类型需要转换为string类型比较
if (String.valueOf(dataType).equals(String.valueOf(DataTypeEnums.NCHAR.getDataCode()))) {
schemaField.setSize(Integer.valueOf(hwDeviceModeFunction.getDataDefinition()));
}
tdSuperTableVo.setDatabaseName(dbName);
tdSuperTableVo.setSuperTableName(superTableName);
tdSuperTableVo.setField(schemaField);
this.remoteTdEngineService.addSuperTableColumn(tdSuperTableVo);
}
}
private void dropTdSuperTableColumn(HwDeviceModeFunction hwDeviceModeFunction) {
String functionMode = hwDeviceModeFunction.getFunctionMode();
if (functionMode.equals(HwDictConstants.FUNCTION_MODE_ATTRIBUTE)) {
Long deviceModeId = hwDeviceModeFunction.getDeviceModeId();
HwDeviceMode hwDeviceMode = hwDeviceModeMapper.selectHwDeviceModeByDeviceModeId(deviceModeId);
String dbName = TdEngineConstants.DEFAULT_DB_NAME_PREFIX + hwDeviceMode.getSceneId();
String superTableName = TdEngineConstants.DEFAULT_SUPER_TABLE_NAME_PREFIX + deviceModeId;
TdSuperTableVo tdSuperTableVo = new TdSuperTableVo();
TdField schemaField = new TdField();
schemaField.setFieldName(hwDeviceModeFunction.getFunctionIdentifier());
tdSuperTableVo.setDatabaseName(dbName);
tdSuperTableVo.setSuperTableName(superTableName);
tdSuperTableVo.setField(schemaField);
this.remoteTdEngineService.dropColumnForSuperTable(tdSuperTableVo);
}
}
} }

@ -52,10 +52,28 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="propertyField" column="sub_property_field" /> <result property="propertyField" column="sub_property_field" />
</resultMap> </resultMap>
<resultMap type="HwDeviceModeParameter" id="HwDeviceModeParameterResult">
<result property="modeParameterId" column="mode_parameter_id" />
<result property="modeFunctionId" column="mode_function_id" />
<result property="releatedParameterId" column="releated_parameter_id" />
<result property="parameterType" column="parameter_type" />
<result property="parameterName" column="parameter_name" />
<result property="parameterIdentifier" column="parameter_identifier" />
<result property="dataType" column="data_type" />
<result property="dataDefinition" column="data_definition" />
<result property="propertyUnit" column="property_unit" />
<result property="propertyStep" column="property_step" />
</resultMap>
<sql id="selectHwDeviceModeVo"> <sql id="selectHwDeviceModeVo">
select device_mode_id, device_mode_name, tenant_id, scene_id, language_code, gps_flag, device_mode_status, common_flag, mode_classfication, device_mode_pic, data_verify_level, remark, create_by, create_time, update_by, update_time, device_mode_field from hw_device_mode select device_mode_id, device_mode_name, tenant_id, scene_id, language_code, gps_flag, device_mode_status, common_flag, mode_classfication, device_mode_pic, data_verify_level, remark, create_by, create_time, update_by, update_time, device_mode_field from hw_device_mode
</sql> </sql>
<sql id="selectHwDeviceModeParameterVo">
select mode_parameter_id, mode_function_id, releated_parameter_id, parameter_type, parameter_name, parameter_identifier, data_type, data_definition, property_unit, property_step from hw_device_mode_parameter
</sql>
<select id="selectHwDeviceModeList" parameterType="HwDeviceMode" resultMap="HwDeviceModeResult"> <select id="selectHwDeviceModeList" parameterType="HwDeviceMode" resultMap="HwDeviceModeResult">
<include refid="selectHwDeviceModeVo"/> <include refid="selectHwDeviceModeVo"/>
<where> <where>
@ -166,10 +184,107 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
delete from hw_device_mode_function where device_mode_id = #{deviceModeId} delete from hw_device_mode_function where device_mode_id = #{deviceModeId}
</delete> </delete>
<insert id="batchHwDeviceModeFunction"> <insert id="batchHwDeviceModeFunction" useGeneratedKeys="true" keyProperty="modeFunctionId">
insert into hw_device_mode_function( mode_function_id, device_mode_id, function_mode, coordinate, function_name, function_identifier, function_type, data_type, data_definition, function_formula, property_unit, display_flag, rw_flag, invoke_method, event_type, remark, acquisition_formula, order_flag, device_register, property_step, property_field) values insert into hw_device_mode_function( mode_function_id, device_mode_id, function_mode, coordinate, function_name, function_identifier, function_type, data_type, data_definition, function_formula, property_unit, display_flag, rw_flag, invoke_method, event_type, remark, acquisition_formula, order_flag, device_register, property_step, property_field) values
<foreach item="item" index="index" collection="list" separator=","> <foreach item="item" index="index" collection="list" separator=",">
( #{item.modeFunctionId}, #{item.deviceModeId}, #{item.functionMode}, #{item.coordinate}, #{item.functionName}, #{item.functionIdentifier}, #{item.functionType}, #{item.dataType}, #{item.dataDefinition}, #{item.functionFormula}, #{item.propertyUnit}, #{item.displayFlag}, #{item.rwFlag}, #{item.invokeMethod}, #{item.eventType}, #{item.remark}, #{item.acquisitionFormula}, #{item.orderFlag}, #{item.deviceRegister}, #{item.propertyStep}, #{item.propertyField}) ( #{item.modeFunctionId}, #{item.deviceModeId}, #{item.functionMode}, #{item.coordinate}, #{item.functionName}, #{item.functionIdentifier}, #{item.functionType}, #{item.dataType}, #{item.dataDefinition}, #{item.functionFormula}, #{item.propertyUnit}, #{item.displayFlag}, #{item.rwFlag}, #{item.invokeMethod}, #{item.eventType}, #{item.remark}, #{item.acquisitionFormula}, #{item.orderFlag}, #{item.deviceRegister}, #{item.propertyStep}, #{item.propertyField})
</foreach> </foreach>
</insert> </insert>
<insert id="insertHwDeviceModeFunction" parameterType="HwDeviceModeFunction" useGeneratedKeys="true" keyProperty="modeFunctionId">
insert into hw_device_mode_function
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="deviceModeId != null">device_mode_id,</if>
<if test="functionMode != null and functionMode != ''">function_mode,</if>
<if test="coordinate != null">coordinate,</if>
<if test="functionName != null and functionName != ''">function_name,</if>
<if test="functionIdentifier != null and functionIdentifier != ''">function_identifier,</if>
<if test="functionType != null">function_type,</if>
<if test="dataType != null">data_type,</if>
<if test="dataDefinition != null">data_definition,</if>
<if test="functionFormula != null">function_formula,</if>
<if test="propertyUnit != null">property_unit,</if>
<if test="displayFlag != null">display_flag,</if>
<if test="rwFlag != null">rw_flag,</if>
<if test="invokeMethod != null">invoke_method,</if>
<if test="eventType != null">event_type,</if>
<if test="remark != null">remark,</if>
<if test="acquisitionFormula != null">acquisition_formula,</if>
<if test="orderFlag != null">order_flag,</if>
<if test="deviceRegister != null">device_register,</if>
<if test="propertyStep != null">property_step,</if>
<if test="propertyField != null">property_field,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="deviceModeId != null">#{deviceModeId},</if>
<if test="functionMode != null and functionMode != ''">#{functionMode},</if>
<if test="coordinate != null">#{coordinate},</if>
<if test="functionName != null and functionName != ''">#{functionName},</if>
<if test="functionIdentifier != null and functionIdentifier != ''">#{functionIdentifier},</if>
<if test="functionType != null">#{functionType},</if>
<if test="dataType != null">#{dataType},</if>
<if test="dataDefinition != null">#{dataDefinition},</if>
<if test="functionFormula != null">#{functionFormula},</if>
<if test="propertyUnit != null">#{propertyUnit},</if>
<if test="displayFlag != null">#{displayFlag},</if>
<if test="rwFlag != null">#{rwFlag},</if>
<if test="invokeMethod != null">#{invokeMethod},</if>
<if test="eventType != null">#{eventType},</if>
<if test="remark != null">#{remark},</if>
<if test="acquisitionFormula != null">#{acquisitionFormula},</if>
<if test="orderFlag != null">#{orderFlag},</if>
<if test="deviceRegister != null">#{deviceRegister},</if>
<if test="propertyStep != null">#{propertyStep},</if>
<if test="propertyField != null">#{propertyField},</if>
</trim>
</insert>
<update id="updateHwDeviceModeFunction" parameterType="HwDeviceModeFunction">
update hw_device_mode_function
<trim prefix="SET" suffixOverrides=",">
<if test="deviceModeId != null">device_mode_id = #{deviceModeId},</if>
<if test="functionMode != null and functionMode != ''">function_mode = #{functionMode},</if>
<if test="coordinate != null">coordinate = #{coordinate},</if>
<if test="functionName != null and functionName != ''">function_name = #{functionName},</if>
<if test="functionIdentifier != null and functionIdentifier != ''">function_identifier = #{functionIdentifier},</if>
<if test="functionType != null">function_type = #{functionType},</if>
<if test="dataType != null">data_type = #{dataType},</if>
<if test="dataDefinition != null">data_definition = #{dataDefinition},</if>
<if test="functionFormula != null">function_formula = #{functionFormula},</if>
<if test="propertyUnit != null">property_unit = #{propertyUnit},</if>
<if test="displayFlag != null">display_flag = #{displayFlag},</if>
<if test="rwFlag != null">rw_flag = #{rwFlag},</if>
<if test="invokeMethod != null">invoke_method = #{invokeMethod},</if>
<if test="eventType != null">event_type = #{eventType},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="acquisitionFormula != null">acquisition_formula = #{acquisitionFormula},</if>
<if test="orderFlag != null">order_flag = #{orderFlag},</if>
<if test="deviceRegister != null">device_register = #{deviceRegister},</if>
<if test="propertyStep != null">property_step = #{propertyStep},</if>
<if test="propertyField != null">property_field = #{propertyField},</if>
</trim>
where mode_function_id = #{modeFunctionId}
</update>
<delete id="deleteHwDeviceModeFunctionByModeFunctionId" parameterType="Long">
delete from hw_device_mode_function where mode_function_id = #{modeFunctionId}
</delete>
<insert id="batchHwDeviceModeParameters">
insert into hw_device_mode_parameter( mode_function_id, parameter_type, parameter_name, parameter_identifier, data_type, data_definition, property_unit, property_step) values
<foreach item="item" index="index" collection="list" separator=",">
( #{item.modeFunctionId}, #{item.parameterType}, #{item.parameterName}, #{item.parameterIdentifier}, #{item.dataType}, #{item.dataDefinition}, #{item.propertyUnit}, #{item.propertyStep})
</foreach>
</insert>
<delete id="deleteHwDeviceModeParameterByModeFunctionId" parameterType="Long">
delete from hw_device_mode_parameter where mode_function_id = #{modeFunctionId}
</delete>
<select id="selectDeviceModeParametersByModeFunctionId" parameterType="Long" resultMap="HwDeviceModeParameterResult">
<include refid="selectHwDeviceModeParameterVo"/>
where mode_function_id = #{modeFunctionId}
</select>
</mapper> </mapper>

@ -0,0 +1,105 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.business.mapper.HwDeviceModeParameterMapper">
<resultMap type="HwDeviceModeParameter" id="HwDeviceModeParameterResult">
<result property="modeParameterId" column="mode_parameter_id" />
<result property="modeFunctionId" column="mode_function_id" />
<result property="releatedParameterId" column="releated_parameter_id" />
<result property="parameterType" column="parameter_type" />
<result property="parameterName" column="parameter_name" />
<result property="parameterIdentifier" column="parameter_identifier" />
<result property="dataType" column="data_type" />
<result property="dataDefinition" column="data_definition" />
<result property="propertyUnit" column="property_unit" />
<result property="propertyStep" column="property_step" />
</resultMap>
<sql id="selectHwDeviceModeParameterVo">
select mode_parameter_id, mode_function_id, releated_parameter_id, parameter_type, parameter_name, parameter_identifier, data_type, data_definition, property_unit, property_step from hw_device_mode_parameter
</sql>
<select id="selectHwDeviceModeParameterList" parameterType="HwDeviceModeParameter" resultMap="HwDeviceModeParameterResult">
<include refid="selectHwDeviceModeParameterVo"/>
<where>
<if test="modeFunctionId != null "> and mode_function_id = #{modeFunctionId}</if>
<if test="releatedParameterId != null "> and releated_parameter_id = #{releatedParameterId}</if>
<if test="parameterType != null and parameterType != ''"> and parameter_type = #{parameterType}</if>
<if test="parameterName != null and parameterName != ''"> and parameter_name like concat('%', #{parameterName}, '%')</if>
<if test="parameterIdentifier != null and parameterIdentifier != ''"> and parameter_identifier = #{parameterIdentifier}</if>
<if test="dataType != null and dataType != ''"> and data_type = #{dataType}</if>
<if test="dataDefinition != null and dataDefinition != ''"> and data_definition = #{dataDefinition}</if>
<if test="propertyUnit != null and propertyUnit != ''"> and property_unit = #{propertyUnit}</if>
<if test="propertyStep != null "> and property_step = #{propertyStep}</if>
</where>
</select>
<select id="selectHwDeviceModeParameterByModeParameterId" parameterType="Long" resultMap="HwDeviceModeParameterResult">
<include refid="selectHwDeviceModeParameterVo"/>
where mode_parameter_id = #{modeParameterId}
</select>
<insert id="insertHwDeviceModeParameter" parameterType="HwDeviceModeParameter" useGeneratedKeys="true" keyProperty="modeParameterId">
insert into hw_device_mode_parameter
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="modeFunctionId != null">mode_function_id,</if>
<if test="releatedParameterId != null">releated_parameter_id,</if>
<if test="parameterType != null and parameterType != ''">parameter_type,</if>
<if test="parameterName != null and parameterName != ''">parameter_name,</if>
<if test="parameterIdentifier != null and parameterIdentifier != ''">parameter_identifier,</if>
<if test="dataType != null and dataType != ''">data_type,</if>
<if test="dataDefinition != null">data_definition,</if>
<if test="propertyUnit != null">property_unit,</if>
<if test="propertyStep != null">property_step,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="modeFunctionId != null">#{modeFunctionId},</if>
<if test="releatedParameterId != null">#{releatedParameterId},</if>
<if test="parameterType != null and parameterType != ''">#{parameterType},</if>
<if test="parameterName != null and parameterName != ''">#{parameterName},</if>
<if test="parameterIdentifier != null and parameterIdentifier != ''">#{parameterIdentifier},</if>
<if test="dataType != null and dataType != ''">#{dataType},</if>
<if test="dataDefinition != null">#{dataDefinition},</if>
<if test="propertyUnit != null">#{propertyUnit},</if>
<if test="propertyStep != null">#{propertyStep},</if>
</trim>
</insert>
<update id="updateHwDeviceModeParameter" parameterType="HwDeviceModeParameter">
update hw_device_mode_parameter
<trim prefix="SET" suffixOverrides=",">
<if test="modeFunctionId != null">mode_function_id = #{modeFunctionId},</if>
<if test="releatedParameterId != null">releated_parameter_id = #{releatedParameterId},</if>
<if test="parameterType != null and parameterType != ''">parameter_type = #{parameterType},</if>
<if test="parameterName != null and parameterName != ''">parameter_name = #{parameterName},</if>
<if test="parameterIdentifier != null and parameterIdentifier != ''">parameter_identifier = #{parameterIdentifier},</if>
<if test="dataType != null and dataType != ''">data_type = #{dataType},</if>
<if test="dataDefinition != null">data_definition = #{dataDefinition},</if>
<if test="propertyUnit != null">property_unit = #{propertyUnit},</if>
<if test="propertyStep != null">property_step = #{propertyStep},</if>
</trim>
where mode_parameter_id = #{modeParameterId}
</update>
<delete id="deleteHwDeviceModeParameterByModeParameterId" parameterType="Long">
delete from hw_device_mode_parameter where mode_parameter_id = #{modeParameterId}
</delete>
<delete id="deleteHwDeviceModeParameterByModeParameterIds" parameterType="String">
delete from hw_device_mode_parameter where mode_parameter_id in
<foreach item="modeParameterId" collection="array" open="(" separator="," close=")">
#{modeParameterId}
</foreach>
</delete>
<insert id="batchHwDeviceModeParameters">
insert into hw_device_mode_parameter( mode_function_id, parameter_type, parameter_name, parameter_identifier, data_type, data_definition, property_unit, property_step) values
<foreach item="item" index="index" collection="list" separator=",">
( #{item.modeFunctionId}, #{item.parameterType}, #{item.parameterName}, #{item.parameterIdentifier}, #{item.dataType}, #{item.dataDefinition}, #{item.propertyUnit}, #{item.propertyStep})
</foreach>
</insert>
</mapper>

@ -1,18 +1,17 @@
package com.ruoyi.dataprocess.domain; package com.ruoyi.dataprocess.domain;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.core.annotation.Excel;
import com.ruoyi.common.core.web.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.core.annotation.Excel;
import java.util.Date; import com.ruoyi.common.core.web.domain.BaseEntity;
/** /**
* hw_device * hw_device
* *
* @author xins * @author xins
* @date 2023-08-24 * @date 2023-09-13
*/ */
public class HwDevice extends BaseEntity public class HwDevice extends BaseEntity
{ {
@ -107,6 +106,14 @@ public class HwDevice extends BaseEntity
@Excel(name = "预留字段") @Excel(name = "预留字段")
private String deviceField; private String deviceField;
/** 租户ID关联hw_tenant的tenant_id */
@Excel(name = "租户ID关联hw_tenant的tenant_id")
private Long tenantId;
/** 在线状态1、在线0、离线 */
@Excel(name = "在线状态", readConverterExp = "1=、在线0、离线")
private String onlineStatus;
public void setDeviceId(Long deviceId) public void setDeviceId(Long deviceId)
{ {
this.deviceId = deviceId; this.deviceId = deviceId;
@ -305,6 +312,24 @@ public class HwDevice extends BaseEntity
{ {
return deviceField; return deviceField;
} }
public void setTenantId(Long tenantId)
{
this.tenantId = tenantId;
}
public Long getTenantId()
{
return tenantId;
}
public void setOnlineStatus(String onlineStatus)
{
this.onlineStatus = onlineStatus;
}
public String getOnlineStatus()
{
return onlineStatus;
}
@Override @Override
public String toString() { public String toString() {
@ -336,6 +361,8 @@ public class HwDevice extends BaseEntity
.append("updateBy", getUpdateBy()) .append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime()) .append("updateTime", getUpdateTime())
.append("deviceField", getDeviceField()) .append("deviceField", getDeviceField())
.append("tenantId", getTenantId())
.append("onlineStatus", getOnlineStatus())
.toString(); .toString();
} }
} }

@ -21,5 +21,11 @@ public interface HwDeviceMapper
*/ */
public HwDevice selectHwDeviceByDeviceCode(String deviceCode); public HwDevice selectHwDeviceByDeviceCode(String deviceCode);
/**
*
*
* @param hwDevice
* @return
*/
public int updateHwDevice(HwDevice hwDevice);
} }

@ -20,7 +20,7 @@ import java.util.List;
* @Description: * @Description:
* @ClassName: DeviceStatusServiceImpl * @ClassName: DeviceStatusServiceImpl
* @Author : xins * @Author : xins
* @Date :2023-09-04 15:31 * @Date :2023-09-12 15:31
* @Version :1.0 * @Version :1.0
*/ */
@Service @Service
@ -34,7 +34,6 @@ public class DeviceStatusServiceImpl implements IDeviceStatusService {
@Override @Override
public void handleDeviceStatus(String payloadString, String clientId) { public void handleDeviceStatus(String payloadString, String clientId) {
System.out.println("ddd:" + payloadString);
// ddd:{"msg":"设备设备连接状态信息","deviceType":"edge","connectStatus":1, // ddd:{"msg":"设备设备连接状态信息","deviceType":"edge","connectStatus":1,
// "statusTime":1694506127199,"deviceCode":"hw-data-process-1"} // "statusTime":1694506127199,"deviceCode":"hw-data-process-1"}
JSONObject json = JSON.parseObject(payloadString); JSONObject json = JSON.parseObject(payloadString);
@ -68,6 +67,10 @@ public class DeviceStatusServiceImpl implements IDeviceStatusService {
tdTableVo.setSchemaFields(schemaFields); tdTableVo.setSchemaFields(schemaFields);
this.remoteTdEngineService.insertTable(tdTableVo); this.remoteTdEngineService.insertTable(tdTableVo);
//更新设备当前状态信息
hwDevice.setOnlineStatus(String.valueOf(json.getInteger("connectStatus")));
hwDeviceMapper.updateHwDevice(hwDevice);
} }
} }
} }

@ -4,7 +4,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.dataprocess.mapper.HwDeviceMapper"> <mapper namespace="com.ruoyi.dataprocess.mapper.HwDeviceMapper">
<resultMap type="com.ruoyi.dataprocess.domain.HwDevice" id="HwDeviceResult"> <resultMap type="HwDevice" id="HwDeviceResult">
<result property="deviceId" column="device_id" /> <result property="deviceId" column="device_id" />
<result property="deviceCode" column="device_code" /> <result property="deviceCode" column="device_code" />
<result property="deviceName" column="device_name" /> <result property="deviceName" column="device_name" />
@ -32,16 +32,52 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateBy" column="update_by" /> <result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" /> <result property="updateTime" column="update_time" />
<result property="deviceField" column="device_field" /> <result property="deviceField" column="device_field" />
<result property="tenantId" column="tenant_id" />
<result property="onlineStatus" column="online_status" />
</resultMap> </resultMap>
<sql id="selectHwDeviceVo"> <sql id="selectHwDeviceVo">
select device_id, device_code, scene_id, monitor_unit_id, device_type, device_mode_id, device_status from hw_device select device_id, device_code, device_name, scene_id, monitor_unit_id, device_type, networking_mode, access_protocol, data_format, releated_device_id, device_mode_id, access_gw_protocol, active_status, device_status, active_time, device_pic, ip_address, area_id, device_location, current_module_version, current_singlechip_version, remark, create_by, create_time, update_by, update_time, device_field, tenant_id, online_status from hw_device
</sql> </sql>
<select id="selectHwDeviceByDeviceCode" parameterType="String" resultMap="HwDeviceResult"> <select id="selectHwDeviceByDeviceCode" parameterType="String" resultMap="HwDeviceResult">
<include refid="selectHwDeviceVo"/> <include refid="selectHwDeviceVo"/>
where device_code = #{deviceCode} limit 1 where device_code = #{deviceCode} limit 1
</select> </select>
<update id="updateHwDevice" parameterType="HwDevice">
update hw_device
<trim prefix="SET" suffixOverrides=",">
<if test="deviceCode != null and deviceCode != ''">device_code = #{deviceCode},</if>
<if test="deviceName != null and deviceName != ''">device_name = #{deviceName},</if>
<if test="sceneId != null">scene_id = #{sceneId},</if>
<if test="monitorUnitId != null">monitor_unit_id = #{monitorUnitId},</if>
<if test="deviceType != null and deviceType != ''">device_type = #{deviceType},</if>
<if test="networkingMode != null and networkingMode != ''">networking_mode = #{networkingMode},</if>
<if test="accessProtocol != null">access_protocol = #{accessProtocol},</if>
<if test="dataFormat != null">data_format = #{dataFormat},</if>
<if test="releatedDeviceId != null">releated_device_id = #{releatedDeviceId},</if>
<if test="deviceModeId != null">device_mode_id = #{deviceModeId},</if>
<if test="accessGwProtocol != null">access_gw_protocol = #{accessGwProtocol},</if>
<if test="activeStatus != null and activeStatus != ''">active_status = #{activeStatus},</if>
<if test="deviceStatus != null and deviceStatus != ''">device_status = #{deviceStatus},</if>
<if test="activeTime != null">active_time = #{activeTime},</if>
<if test="devicePic != null">device_pic = #{devicePic},</if>
<if test="ipAddress != null">ip_address = #{ipAddress},</if>
<if test="areaId != null">area_id = #{areaId},</if>
<if test="deviceLocation != null">device_location = #{deviceLocation},</if>
<if test="currentModuleVersion != null">current_module_version = #{currentModuleVersion},</if>
<if test="currentSinglechipVersion != null">current_singlechip_version = #{currentSinglechipVersion},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="deviceField != null">device_field = #{deviceField},</if>
<if test="tenantId != null">tenant_id = #{tenantId},</if>
<if test="onlineStatus != null and onlineStatus != ''">online_status = #{onlineStatus},</if>
</trim>
where device_id = #{deviceId}
</update>
</mapper> </mapper>

@ -181,8 +181,8 @@ public class TdEngineController {
TdField dropField = tdSuperTableVo.getField(); TdField dropField = tdSuperTableVo.getField();
try { try {
TdFieldVo dropFieldVo = TdFieldVo.convertField(dropField); // TdFieldVo dropFieldVo = TdFieldVo.convertField(dropField);
this.tdEngineService.dropSuperTableColumn(databaseName, superTableName, dropFieldVo); this.tdEngineService.dropSuperTableColumn(databaseName, superTableName, dropField);
log.info("successfully droped column of superTable " + superTableName); log.info("successfully droped column of superTable " + superTableName);
return R.ok("successfully droped column of superTable " + superTableName); return R.ok("successfully droped column of superTable " + superTableName);
} catch (UncategorizedSQLException e) { } catch (UncategorizedSQLException e) {

@ -77,7 +77,7 @@ public interface TdEngineMapper {
*/ */
void dropSuperTableColumn(@Param("databaseName") String databaseName, void dropSuperTableColumn(@Param("databaseName") String databaseName,
@Param("superTableName") String superTableName, @Param("superTableName") String superTableName,
@Param("dropFieldsVo") TdFieldVo dropFieldsVo); @Param("dropField") TdField dropField);
/** /**

@ -67,7 +67,7 @@ public interface ITdEngineService {
* @author xins * @author xins
* @date 2023-08-28 17:13 * @date 2023-08-28 17:13
*/ */
public void dropSuperTableColumn(String databaseName,String superTableName, TdFieldVo dropFieldsVo) throws Exception; public void dropSuperTableColumn(String databaseName,String superTableName, TdField dropField) throws Exception;
/** /**
* @param: databaseName * @param: databaseName

@ -99,8 +99,8 @@ public class TdEngineServiceImpl implements ITdEngineService {
* @author xins * @author xins
* @date 2023-08-28 17:13 * @date 2023-08-28 17:13
*/ */
public void dropSuperTableColumn(String databaseName, String superTableName, TdFieldVo dropFieldsVo) throws Exception { public void dropSuperTableColumn(String databaseName, String superTableName, TdField dropField) throws Exception {
this.tdEngineMapper.dropSuperTableColumn(databaseName, superTableName, dropFieldsVo); this.tdEngineMapper.dropSuperTableColumn(databaseName, superTableName, dropField);
} }
/** /**

@ -168,8 +168,8 @@
<update id="dropSuperTableColumn"> <update id="dropSuperTableColumn">
ALTER STABLE #{databaseName}.#{superTableName} DROP COLUMN ALTER STABLE #{databaseName}.#{superTableName} DROP COLUMN
<if test="dropFieldsVo.fieldName != null and dropFieldsVo.fieldName != ''"> <if test="dropField.fieldName != null and dropField.fieldName != ''">
${dropFieldsVo.fieldName} ${dropField.fieldName}
</if> </if>
</update> </update>

@ -2,6 +2,8 @@ package com.ruoyi.system.controller;
import java.util.List; import java.util.List;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.ruoyi.common.core.domain.R;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.DeleteMapping;
@ -130,4 +132,13 @@ public class SysConfigController extends BaseController
configService.resetConfigCache(); configService.resetConfigCache();
return success(); return success();
} }
/**
*
*/
@GetMapping(value = "/configKeyStr/{configKey}")
public R<String> getConfigKeyStr(@PathVariable String configKey)
{
return R.ok(configService.selectConfigByKey(configKey));
}
} }

@ -42,3 +42,13 @@ export function delLanguage(languageId) {
method: 'delete' method: 'delete'
}) })
} }
// 查询语言信息列表供选择使用
export function getLanguages(query) {
return request({
url: '/basic/language/getLanguages',
method: 'get',
params: query
})
}

@ -42,3 +42,4 @@ export function delDeviceMode(deviceModeId) {
method: 'delete' method: 'delete'
}) })
} }

@ -42,3 +42,12 @@ export function delDeviceModeFunction(modeFunctionId) {
method: 'delete' method: 'delete'
}) })
} }
// 查询设备模型功能参数列表
export function getDeviceModeParameters(modeFunctionId) {
return request({
url: '/business/deviceModeFunction/getDeviceModeParameters/'+modeFunctionId,
method: 'get'
})
}

@ -42,3 +42,13 @@ export function delScene(sceneId) {
method: 'delete' method: 'delete'
}) })
} }
// 查询场景信息列表供选择使用(例如下拉列表)
export function getScenes(query) {
return request({
url: '/business/scene/getScenes',
method: 'get',
params: query
})
}

@ -1,551 +0,0 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="设备模型ID关联表hw_device_mode的device_mode_id" prop="deviceModeId">
<el-input
v-model="queryParams.deviceModeId"
placeholder="请输入设备模型ID关联表hw_device_mode的device_mode_id"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="功能模式" prop="functionMode">
<el-input
v-model="queryParams.functionMode"
placeholder="请输入功能模式"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="坐标标识" prop="coordinate">
<el-input
v-model="queryParams.coordinate"
placeholder="请输入坐标标识"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="功能名称" prop="functionName">
<el-input
v-model="queryParams.functionName"
placeholder="请输入功能名称"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="标识符" prop="functionIdentifier">
<el-input
v-model="queryParams.functionIdentifier"
placeholder="请输入标识符"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="json
1取值范围{'minValue':1,'maxValue':100},
2枚举型
{'1':'成功','2','失败','3','提示}
3bool型
{'0':'关','1','开'}
4Text型
{'dataLength'1024}
5String类型" prop="dataDefinition">
<el-input
v-model="queryParams.dataDefinition"
placeholder="请输入数据定义按json保存示例如下
1取值范围{'minValue':1,'maxValue':100},
2枚举型
{'1':'成功','2','失败','3','提示}
3bool型
{'0':'关','1','开'}
4Text型
{'dataLength'1024}
5String类型"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="运算性变量公式" prop="functionFormula">
<el-input
v-model="queryParams.functionFormula"
placeholder="请输入运算性变量公式"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="单位" prop="propertyUnit">
<el-input
v-model="queryParams.propertyUnit"
placeholder="请输入单位"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="显示标识" prop="displayFlag">
<el-input
v-model="queryParams.displayFlag"
placeholder="请输入显示标识"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="读写标识" prop="rwFlag">
<el-input
v-model="queryParams.rwFlag"
placeholder="请输入读写标识"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="调用方式" prop="invokeMethod">
<el-input
v-model="queryParams.invokeMethod"
placeholder="请输入调用方式"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="%s
%s+10
%s-10
%s10
%s/10
余数%s%10" prop="acquisitionFormula">
<el-input
v-model="queryParams.acquisitionFormula"
placeholder="请输入预留字段采集公式设备上行数据经采集公式计算后显示公式中的%s为占位符是固定字段
%s+10
%s-10
%s10
%s/10
余数%s%10"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="预留字段,顺序" prop="orderFlag">
<el-input
v-model="queryParams.orderFlag"
placeholder="请输入预留字段,顺序"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="预留字段,寄存器" prop="deviceRegister">
<el-input
v-model="queryParams.deviceRegister"
placeholder="请输入预留字段,寄存器"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="预留字段,步长" prop="propertyStep">
<el-input
v-model="queryParams.propertyStep"
placeholder="请输入预留字段,步长"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="预留字段" prop="propertyField">
<el-input
v-model="queryParams.propertyField"
placeholder="请输入预留字段"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery"></el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery"></el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['business:deviceModeFunction:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['business:deviceModeFunction:edit']"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['business:deviceModeFunction:remove']"
>删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['business:deviceModeFunction:export']"
>导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="deviceModeFunctionList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="设备模型功能ID" align="center" prop="modeFunctionId" />
<el-table-column label="设备模型ID关联表hw_device_mode的device_mode_id" align="center" prop="deviceModeId" />
<el-table-column label="功能模式" align="center" prop="functionMode" />
<el-table-column label="坐标标识" align="center" prop="coordinate" />
<el-table-column label="功能名称" align="center" prop="functionName" />
<el-table-column label="标识符" align="center" prop="functionIdentifier" />
<el-table-column label="功能类型(1、直采变量 2、手录变量 3、运算性变量)" align="center" prop="functionType" />
<el-table-column label="数据类型" align="center" prop="dataType" />
<el-table-column label="json
1取值范围{'minValue':1,'maxValue':100},
2枚举型
{'1':'成功','2','失败','3','提示}
3bool型
{'0':'关','1','开'}
4Text型
{'dataLength'1024}
5String类型" align="center" prop="dataDefinition" />
<el-table-column label="运算性变量公式" align="center" prop="functionFormula" />
<el-table-column label="单位" align="center" prop="propertyUnit" />
<el-table-column label="显示标识" align="center" prop="displayFlag" />
<el-table-column label="读写标识" align="center" prop="rwFlag" />
<el-table-column label="调用方式" align="center" prop="invokeMethod" />
<el-table-column label="事件类型" align="center" prop="eventType" />
<el-table-column label="描述" align="center" prop="remark" />
<el-table-column label="%s
%s+10
%s-10
%s10
%s/10
余数%s%10" align="center" prop="acquisitionFormula" />
<el-table-column label="预留字段,顺序" align="center" prop="orderFlag" />
<el-table-column label="预留字段,寄存器" align="center" prop="deviceRegister" />
<el-table-column label="预留字段,步长" align="center" prop="propertyStep" />
<el-table-column label="预留字段" align="center" prop="propertyField" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['business:deviceModeFunction:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['business:deviceModeFunction:remove']"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改设备模型功能对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="设备模型ID关联表hw_device_mode的device_mode_id" prop="deviceModeId">
<el-input v-model="form.deviceModeId" placeholder="请输入设备模型ID关联表hw_device_mode的device_mode_id" />
</el-form-item>
<el-form-item label="功能模式" prop="functionMode">
<el-input v-model="form.functionMode" placeholder="请输入功能模式" />
</el-form-item>
<el-form-item label="坐标标识" prop="coordinate">
<el-input v-model="form.coordinate" placeholder="请输入坐标标识" />
</el-form-item>
<el-form-item label="功能名称" prop="functionName">
<el-input v-model="form.functionName" placeholder="请输入功能名称" />
</el-form-item>
<el-form-item label="标识符" prop="functionIdentifier">
<el-input v-model="form.functionIdentifier" placeholder="请输入标识符" />
</el-form-item>
<el-form-item label="json
1取值范围{'minValue':1,'maxValue':100},
2枚举型
{'1':'成功','2','失败','3','提示}
3bool型
{'0':'关','1','开'}
4Text型
{'dataLength'1024}
5String类型" prop="dataDefinition">
<el-input v-model="form.dataDefinition" placeholder="json
1取值范围{'minValue':1,'maxValue':100},
2枚举型
{'1':'成功','2','失败','3','提示}
3bool型
{'0':'关','1','开'}
4Text型
{'dataLength'1024}
5String类型" />
</el-form-item>
<el-form-item label="运算性变量公式" prop="functionFormula">
<el-input v-model="form.functionFormula" placeholder="请输入运算性变量公式" />
</el-form-item>
<el-form-item label="单位" prop="propertyUnit">
<el-input v-model="form.propertyUnit" placeholder="请输入单位" />
</el-form-item>
<el-form-item label="显示标识" prop="displayFlag">
<el-input v-model="form.displayFlag" placeholder="请输入显示标识" />
</el-form-item>
<el-form-item label="读写标识" prop="rwFlag">
<el-input v-model="form.rwFlag" placeholder="请输入读写标识" />
</el-form-item>
<el-form-item label="调用方式" prop="invokeMethod">
<el-input v-model="form.invokeMethod" placeholder="请输入调用方式" />
</el-form-item>
<el-form-item label="描述" prop="remark">
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
</el-form-item>
<el-form-item label="%s
%s+10
%s-10
%s10
%s/10
余数%s%10" prop="acquisitionFormula">
<el-input v-model="form.acquisitionFormula" placeholder="%s
%s+10
%s-10
%s10
%s/10
余数%s%10" />
</el-form-item>
<el-form-item label="预留字段,顺序" prop="orderFlag">
<el-input v-model="form.orderFlag" placeholder="请输入预留字段,顺序" />
</el-form-item>
<el-form-item label="预留字段,寄存器" prop="deviceRegister">
<el-input v-model="form.deviceRegister" placeholder="请输入预留字段,寄存器" />
</el-form-item>
<el-form-item label="预留字段,步长" prop="propertyStep">
<el-input v-model="form.propertyStep" placeholder="请输入预留字段,步长" />
</el-form-item>
<el-form-item label="预留字段" prop="propertyField">
<el-input v-model="form.propertyField" placeholder="请输入预留字段" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listDeviceModeFunction, getDeviceModeFunction, delDeviceModeFunction, addDeviceModeFunction, updateDeviceModeFunction } from "@/api/business/deviceModeFunction";
export default {
name: "DeviceModeFunction",
data() {
return {
//
loading: true,
//
ids: [],
//
single: true,
//
multiple: true,
//
showSearch: true,
//
total: 0,
//
deviceModeFunctionList: [],
//
title: "",
//
open: false,
//
queryParams: {
pageNum: 1,
pageSize: 10,
deviceModeId: null,
functionMode: null,
coordinate: null,
functionName: null,
functionIdentifier: null,
functionType: null,
dataType: null,
dataDefinition: null,
functionFormula: null,
propertyUnit: null,
displayFlag: null,
rwFlag: null,
invokeMethod: null,
eventType: null,
acquisitionFormula: null,
orderFlag: null,
deviceRegister: null,
propertyStep: null,
propertyField: null
},
//
form: {},
//
rules: {
deviceModeId: [
{ required: true, message: "设备模型ID关联表hw_device_mode的device_mode_id不能为空", trigger: "blur" }
],
functionMode: [
{ required: true, message: "功能模式不能为空", trigger: "blur" }
],
functionName: [
{ required: true, message: "功能名称不能为空", trigger: "blur" }
],
functionIdentifier: [
{ required: true, message: "标识符不能为空", trigger: "blur" }
],
}
};
},
created() {
this.getList();
},
methods: {
/** 查询设备模型功能列表 */
getList() {
this.loading = true;
listDeviceModeFunction(this.queryParams).then(response => {
this.deviceModeFunctionList = response.rows;
this.total = response.total;
this.loading = false;
});
},
//
cancel() {
this.open = false;
this.reset();
},
//
reset() {
this.form = {
modeFunctionId: null,
deviceModeId: null,
functionMode: null,
coordinate: null,
functionName: null,
functionIdentifier: null,
functionType: null,
dataType: null,
dataDefinition: null,
functionFormula: null,
propertyUnit: null,
displayFlag: null,
rwFlag: null,
invokeMethod: null,
eventType: null,
remark: null,
acquisitionFormula: null,
orderFlag: null,
deviceRegister: null,
propertyStep: null,
propertyField: null
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
//
handleSelectionChange(selection) {
this.ids = selection.map(item => item.modeFunctionId)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加设备模型功能";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const modeFunctionId = row.modeFunctionId || this.ids
getDeviceModeFunction(modeFunctionId).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改设备模型功能";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.modeFunctionId != null) {
updateDeviceModeFunction(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addDeviceModeFunction(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const modeFunctionIds = row.modeFunctionId || this.ids;
this.$modal.confirm('是否确认删除设备模型功能编号为"' + modeFunctionIds + '"的数据项?').then(function() {
return delDeviceModeFunction(modeFunctionIds);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
this.download('business/deviceModeFunction/export', {
...this.queryParams
}, `deviceModeFunction_${new Date().getTime()}.xlsx`)
}
}
};
</script>

@ -1,550 +1,464 @@
<template> <template>
<div class="app-container"> <div>
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="设备模型ID关联表hw_device_mode的device_mode_id" prop="deviceModeId">
<el-input
v-model="queryParams.deviceModeId"
placeholder="请输入设备模型ID关联表hw_device_mode的device_mode_id"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="功能模式" prop="functionMode">
<el-input
v-model="queryParams.functionMode"
placeholder="请输入功能模式"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="坐标标识" prop="coordinate">
<el-input
v-model="queryParams.coordinate"
placeholder="请输入坐标标识"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="功能名称" prop="functionName">
<el-input
v-model="queryParams.functionName"
placeholder="请输入功能名称"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="标识符" prop="functionIdentifier">
<el-input
v-model="queryParams.functionIdentifier"
placeholder="请输入标识符"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="json
1取值范围{'minValue':1,'maxValue':100},
2枚举型
{'1':'成功','2','失败','3','提示}
3bool型
{'0':'关','1','开'}
4Text型
{'dataLength'1024}
5String类型" prop="dataDefinition">
<el-input
v-model="queryParams.dataDefinition"
placeholder="请输入数据定义按json保存示例如下
1取值范围{'minValue':1,'maxValue':100},
2枚举型
{'1':'成功','2','失败','3','提示}
3bool型
{'0':'关','1','开'}
4Text型
{'dataLength'1024}
5String类型"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="运算性变量公式" prop="functionFormula">
<el-input
v-model="queryParams.functionFormula"
placeholder="请输入运算性变量公式"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="单位" prop="propertyUnit">
<el-input
v-model="queryParams.propertyUnit"
placeholder="请输入单位"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="显示标识" prop="displayFlag">
<el-input
v-model="queryParams.displayFlag"
placeholder="请输入显示标识"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="读写标识" prop="rwFlag">
<el-input
v-model="queryParams.rwFlag"
placeholder="请输入读写标识"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="调用方式" prop="invokeMethod">
<el-input
v-model="queryParams.invokeMethod"
placeholder="请输入调用方式"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="%s
%s+10
%s-10
%s10
%s/10
余数%s%10" prop="acquisitionFormula">
<el-input
v-model="queryParams.acquisitionFormula"
placeholder="请输入预留字段采集公式设备上行数据经采集公式计算后显示公式中的%s为占位符是固定字段
%s+10
%s-10
%s10
%s/10
余数%s%10"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="预留字段,顺序" prop="orderFlag">
<el-input
v-model="queryParams.orderFlag"
placeholder="请输入预留字段,顺序"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="预留字段,寄存器" prop="deviceRegister">
<el-input
v-model="queryParams.deviceRegister"
placeholder="请输入预留字段,寄存器"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="预留字段,步长" prop="propertyStep">
<el-input
v-model="queryParams.propertyStep"
placeholder="请输入预留字段,步长"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="预留字段" prop="propertyField">
<el-input
v-model="queryParams.propertyField"
placeholder="请输入预留字段"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery"></el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery"></el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8"> <el-row :gutter="5" class="mb8">
<el-col :span="1.5"> <el-col :span="15">
<el-button <el-button
type="primary" type="primary"
plain plain
icon="el-icon-plus" icon="el-icon-plus"
size="mini" size="mini"
@click="handleAdd" @click="handleAdd"
v-hasPermi="['business:deviceModeFunction:add']" >新增
>新增</el-button> </el-button>
</el-col> </el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['business:deviceModeFunction:edit']"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['business:deviceModeFunction:remove']"
>删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['business:deviceModeFunction:export']"
>导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row> </el-row>
<el-table v-loading="loading" :data="deviceModeFunctionList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" /> <el-table ref="eventTable" :data="eventsData" row-key="columnId">
<el-table-column label="设备模型功能ID" align="center" prop="modeFunctionId" /> <el-table-column label="序号" type="index" prop="index" min-width="5%" class-name="allowDrag"/>
<el-table-column label="设备模型ID关联表hw_device_mode的device_mode_id" align="center" prop="deviceModeId" /> <el-table-column
<el-table-column label="功能模式" align="center" prop="functionMode" /> label="功能模式"
<el-table-column label="坐标标识" align="center" prop="coordinate" /> prop="functionMode"
<el-table-column label="功能名称" align="center" prop="functionName" /> v-if="false"
<el-table-column label="标识符" align="center" prop="functionIdentifier" /> />
<el-table-column label="功能类型(1、直采变量 2、手录变量 3、运算性变量)" align="center" prop="functionType" /> <el-table-column
<el-table-column label="数据类型" align="center" prop="dataType" /> label="功能名称"
<el-table-column label="json prop="functionName"
1取值范围{'minValue':1,'maxValue':100}, min-width="10%"
2枚举型 :show-overflow-tooltip="true"
{'1':'成功','2','失败','3','提示} />
3bool型 <el-table-column
{'0':'关','1','开'} label="标识符"
4Text型 prop="functionIdentifier"
{'dataLength'1024} min-width="10%"
5String类型" align="center" prop="dataDefinition" /> :show-overflow-tooltip="true"
<el-table-column label="运算性变量公式" align="center" prop="functionFormula" /> />
<el-table-column label="单位" align="center" prop="propertyUnit" />
<el-table-column label="显示标识" align="center" prop="displayFlag" /> <el-table-column prop="eventType" label="事件类型" min-width="10%">
<el-table-column label="读写标识" align="center" prop="rwFlag" /> <template slot-scope="scope">
<el-table-column label="调用方式" align="center" prop="invokeMethod" /> <dict-tag :options="dict.type.hw_mode_function_event_type" :value="scope.row.eventType"/>
<el-table-column label="事件类型" align="center" prop="eventType" /> </template>
<el-table-column label="描述" align="center" prop="remark" /> </el-table-column>
<el-table-column label="%s
%s+10 <el-table-column label="操作" align="center" min-width="10%">
%s-10
%s10
%s/10
余数%s%10" align="center" prop="acquisitionFormula" />
<el-table-column label="预留字段,顺序" align="center" prop="orderFlag" />
<el-table-column label="预留字段,寄存器" align="center" prop="deviceRegister" />
<el-table-column label="预留字段,步长" align="center" prop="propertyStep" />
<el-table-column label="预留字段" align="center" prop="propertyField" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button <el-button
size="mini" size="mini"
type="text" type="text"
icon="el-icon-edit" icon="el-icon-edit"
@click="handleUpdate(scope.row)" @click="handleUpdateEvent(scope.row)"
v-hasPermi="['business:deviceModeFunction:edit']" >修改
>修改</el-button> </el-button>
<el-button <el-button
size="mini" size="mini"
type="text" type="text"
icon="el-icon-delete" icon="el-icon-delete"
@click="handleDelete(scope.row)" @click="handleDeleteEvent(scope.row)"
v-hasPermi="['business:deviceModeFunction:remove']" >删除
>删除</el-button> </el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改设备模型功能对话框 --> </el-table>
<!-- 添加或修改设备模型事件对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body> <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px"> <el-form ref="modeFunctionForm" :model="modeFunctionForm" :rules="modeFunctionRules" label-width="80px">
<el-form-item label="设备模型ID关联表hw_device_mode的device_mode_id" prop="deviceModeId">
<el-input v-model="form.deviceModeId" placeholder="请输入设备模型ID关联表hw_device_mode的device_mode_id" />
</el-form-item>
<el-form-item label="功能模式" prop="functionMode">
<el-input v-model="form.functionMode" placeholder="请输入功能模式" />
</el-form-item>
<el-form-item label="坐标标识" prop="coordinate">
<el-input v-model="form.coordinate" placeholder="请输入坐标标识" />
</el-form-item>
<el-form-item label="功能名称" prop="functionName"> <el-form-item label="功能名称" prop="functionName">
<el-input v-model="form.functionName" placeholder="请输入功能名称" /> <el-input v-model="modeFunctionForm.functionName" placeholder="请输入功能名称"/>
</el-form-item> </el-form-item>
<el-form-item label="标识符" prop="functionIdentifier"> <el-form-item label="标识符" prop="functionIdentifier">
<el-input v-model="form.functionIdentifier" placeholder="请输入标识符" /> <el-input v-model="modeFunctionForm.functionIdentifier" placeholder="请输入标识符"/>
</el-form-item> </el-form-item>
<el-form-item label="json
1取值范围{'minValue':1,'maxValue':100}, <el-form-item label="事件类型" prop="eventType">
2枚举型 <el-radio-group v-model="modeFunctionForm.eventType">
{'1':'成功','2','失败','3','提示} <el-radio
3bool型 v-for="dict in dict.type.hw_mode_function_event_type"
{'0':'关','1','开'} :key="dict.value"
4Text型 :label="dict.value"
{'dataLength'1024} >{{ dict.label }}
5String类型" prop="dataDefinition"> </el-radio>
<el-input v-model="form.dataDefinition" placeholder="json </el-radio-group>
1取值范围{'minValue':1,'maxValue':100},
2枚举型
{'1':'成功','2','失败','3','提示}
3bool型
{'0':'关','1','开'}
4Text型
{'dataLength'1024}
5String类型" />
</el-form-item> </el-form-item>
<el-form-item label="运算性变量公式" prop="functionFormula">
<el-input v-model="form.functionFormula" placeholder="请输入运算性变量公式" />
<el-form-item label="输出参数" prop="outputParametersData">
<el-table ref="outputParametersTable" :data="modeFunctionForm.outputParameters" row-key="columnId">
<el-table-column
label="参数名称"
prop="parameterName"
min-width="10%"
height="10px"
:show-overflow-tooltip="true"
/>
<el-table-column
label="标识符"
prop="parameterIdentifier"
min-width="10%"
:show-overflow-tooltip="true"
/>
<el-table-column label="操作" align="center" min-width="10%">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdateOutputParameter(scope.row)"
>修改
</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDeleteOutputParameter(scope.row)"
>删除
</el-button>
</template>
</el-table-column>
</el-table>
</el-form-item> </el-form-item>
<el-form-item label="单位" prop="propertyUnit">
<el-input v-model="form.propertyUnit" placeholder="请输入单位" /> <el-form-item label="" prop="outputParameterBtn">
</el-form-item> <el-button type="primary" @click="handleAddOutputParameter" size="mini">添加输出参数</el-button>
<el-form-item label="显示标识" prop="displayFlag">
<el-input v-model="form.displayFlag" placeholder="请输入显示标识" />
</el-form-item>
<el-form-item label="读写标识" prop="rwFlag">
<el-input v-model="form.rwFlag" placeholder="请输入读写标识" />
</el-form-item>
<el-form-item label="调用方式" prop="invokeMethod">
<el-input v-model="form.invokeMethod" placeholder="请输入调用方式" />
</el-form-item> </el-form-item>
<el-form-item label="描述" prop="remark"> <el-form-item label="描述" prop="remark">
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" /> <el-input v-model="modeFunctionForm.remark" type="textarea" placeholder="请输入内容"/>
</el-form-item>
<el-form-item label="%s
%s+10
%s-10
%s10
%s/10
余数%s%10" prop="acquisitionFormula">
<el-input v-model="form.acquisitionFormula" placeholder="%s
%s+10
%s-10
%s10
%s/10
余数%s%10" />
</el-form-item>
<el-form-item label="预留字段,顺序" prop="orderFlag">
<el-input v-model="form.orderFlag" placeholder="请输入预留字段,顺序" />
</el-form-item>
<el-form-item label="预留字段,寄存器" prop="deviceRegister">
<el-input v-model="form.deviceRegister" placeholder="请输入预留字段,寄存器" />
</el-form-item>
<el-form-item label="预留字段,步长" prop="propertyStep">
<el-input v-model="form.propertyStep" placeholder="请输入预留字段,步长" />
</el-form-item>
<el-form-item label="预留字段" prop="propertyField">
<el-input v-model="form.propertyField" placeholder="请输入预留字段" />
</el-form-item> </el-form-item>
</el-form> </el-form>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button> <el-button type="primary" @click="submitDeviceModeEventForm"> </el-button>
<el-button @click="cancel"> </el-button> <el-button @click="cancel"> </el-button>
</div> </div>
</el-dialog> </el-dialog>
<!-- 添加或修改设备模型服务参数对话框(输入和输出参数复用此对话框) -->
<el-dialog :title="inputParameterTitle" :visible.sync="inputParameterOpen" width="500px" append-to-body>
<el-form ref="inputParameterForm" :model="inputParameterForm" :rules="inputParameterRules" label-width="80px">
<el-form-item label="参数类型" prop="parameterType" v-show="false">
<el-input v-model="inputParameterForm.parameterType"/>
</el-form-item>
<el-form-item label="参数名称" prop="parameterName">
<el-input v-model="inputParameterForm.parameterName" placeholder="请输入参数名称"/>
</el-form-item>
<el-form-item label="标识符" prop="parameterIdentifier">
<el-input v-model="inputParameterForm.parameterIdentifier" placeholder="请输入标识符"/>
</el-form-item>
<el-form-item label="数据类型" prop="dataType">
<el-select v-model="inputParameterForm.dataType" placeholder="请选择数据类型">
<el-option
v-for="dict in dict.type.hw_mode_function_data_type"
:key="dict.value"
:label="dict.label"
:value="dict.value"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="取值范围" prop="dataDefinition" v-show="false">
<el-input v-model="inputParameterForm.minValue" placeholder="请输入最小值" style="width:150px;"/>
<el-input v-model="inputParameterForm.maxValue" placeholder="请输入最大值" style="width:150px;"/>
</el-form-item>
<el-form-item label="布尔值" prop="dataDefinition" v-show="inputParameterForm.dataType == '8'">
0
<el-input v-model="inputParameterForm.boolFalse" placeholder="请输入值" style="width:150px;"/>
</el-form-item>
<el-form-item label="" prop="dataDefinition" v-show="inputParameterForm.dataType == '8'">
1
<el-input v-model="inputParameterForm.boolTrue" placeholder="请输入值" style="width:150px;"/>
</el-form-item>
<el-form-item label="长度" prop="dataDefinition" v-show="inputParameterForm.dataType == '10'">
<el-input-number v-model="inputParameterForm.dataDefinition" placeholder="请输入最大长度" :max="1000" style="width:150px;"/>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitInputParameterForm"> </el-button>
<el-button @click="cancelParameter"> </el-button>
</div>
</el-dialog>
</div> </div>
</template> </template>
<script> <script>
import { listDeviceModeFunction, getDeviceModeFunction, delDeviceModeFunction, addDeviceModeFunction, updateDeviceModeFunction } from "@/api/business/deviceModeFunction"; import {
addDeviceModeFunction,
updateDeviceModeFunction,
getDeviceModeParameters,
delDeviceModeFunction
} from "@/api/business/deviceModeFunction";
export default { export default {
name: "DeviceModeFunction", name: 'eventsDataEdit',
dicts: ['hw_mode_function_event_type', 'hw_mode_function_data_type'],
props: {
eventsData: {
type: Array,
default: []
},
deviceModeId: {
type: String,
default: ''
}
},
data() { data() {
return { return {
//
loading: true,
//
ids: [],
//
single: true,
//
multiple: true,
//
showSearch: true,
//
total: 0,
//
deviceModeFunctionList: [],
// //
title: "", title: "",
//
modeFunctionForm: {},
// //
open: false, open: false,
//
queryParams: { deviceModeId: '',
pageNum: 1, eventsData: [],
pageSize: 10,
deviceModeId: null, inputParametersData: [],
functionMode: null, inputParameterTitle: "",
coordinate: null, inputParameterOpen: false,
functionName: null, inputParameterForm: {},
functionIdentifier: null,
functionType: null, outputParametersData: [],
dataType: null,
dataDefinition: null, modeFunctionRules: {
functionFormula: null, functionType: [
propertyUnit: null, {required: true, message: "请选择功能类型", trigger: "blur"},
displayFlag: null,
rwFlag: null,
invokeMethod: null,
eventType: null,
acquisitionFormula: null,
orderFlag: null,
deviceRegister: null,
propertyStep: null,
propertyField: null
},
//
form: {},
//
rules: {
deviceModeId: [
{ required: true, message: "设备模型ID关联表hw_device_mode的device_mode_id不能为空", trigger: "blur" }
],
functionMode: [
{ required: true, message: "功能模式不能为空", trigger: "blur" }
], ],
functionName: [ functionName: [
{ required: true, message: "功能名称不能为空", trigger: "blur" } {required: true, message: "请输入功能名称", trigger: "blur"}
], ],
functionIdentifier: [ functionIdentifier: [
{ required: true, message: "标识符不能为空", trigger: "blur" } {required: true, message: "请输入标识符", trigger: "blur"},
{
pattern: /^[a-z][a-z0-9_]+$/,
message: "2-20个字符由小写字母、数字或下划线组成开头必须为小写字母",
trigger: "blur"
}
], ],
}
},
inputParameterRules: {
parameterName: [
{required: true, message: "请输入功能名称", trigger: "blur"}
],
parameterIdentifier: [
{required: true, message: "请输入标识符", trigger: "blur"},
{
pattern: /^[a-z][a-z0-9_]+$/,
message: "2-20个字符由小写字母、数字或下划线组成开头必须为小写字母",
trigger: "blur"
}
],
eventType: [
{required: true, message: "请选择事件类型", trigger: "blur"},
],
},
}; };
}, },
created() { created() {
this.getList();
}, },
methods: { methods: {
/** 查询设备模型功能列表 */ /** 新增按钮操作 */
getList() { handleAdd() {
this.loading = true; this.reset();
listDeviceModeFunction(this.queryParams).then(response => { this.open = true;
this.deviceModeFunctionList = response.rows; this.title = "添加设备模型事件";
this.total = response.total;
this.loading = false;
});
}, },
//
reset() {
this.modeFunctionForm = {
functionMode: '3',
functionName: null,
functionIdentifier: null,
outputParameters: [],
eventType: '1',
remark: null,
};
//this.resetForm("modeFunctionForm");
},
handleUpdateEvent(row) {
// this.reset();
this.modeFunctionForm = row;
if (row.modeFunctionId !== undefined) {
getDeviceModeParameters(row.modeFunctionId).then(res => {
if (res.data !== undefined) {
this.modeFunctionForm.outputParameters = (res.data)["2"];
}
if (this.modeFunctionForm.outputParameters === undefined) {
this.modeFunctionForm.outputParameters = [];
}
// alert(JSON.stringify(this.modeFunctionForm))
});
}
this.open = true;
this.title = "添加设备模型事件";
},
handleDeleteEvent(row) {
if (row.modeFunctionId !== undefined) {
delDeviceModeFunction(row.modeFunctionId).then(res => {
this.$modal.msgSuccess(res.msg);
if (res.code === 200) {
this.eventsData = this.eventsData.splice(this.eventsData.indexOf(row), 1);
}
});
} else {
this.eventsData = this.eventsData.splice(this.eventsData.indexOf(row), 1);
}
},
submitDeviceModeEventForm() {
this.$refs['modeFunctionForm'].validate(valid => {
if (valid) {
/** 设备模型添加后在list中添加 */
if (this.deviceModeId && this.deviceModeId !== '') {
let modeFunctionId = this.modeFunctionForm.modeFunctionId;
this.modeFunctionForm.deviceModeId = this.deviceModeId;
if (modeFunctionId !== undefined) {
updateDeviceModeFunction(this.modeFunctionForm).then(res => {
this.$modal.msgSuccess(res.msg);
if (res.code === 200) {
this.open = false;
}
});
} else {
addDeviceModeFunction(this.modeFunctionForm).then(res => {
this.$modal.msgSuccess(res.msg);
if (res.code === 200) {
this.open = false;
this.modeFunctionForm.modeFunctionId = res.data;
this.pushData();
}
});
}
} else {
this.open = false;
this.pushData();
}
}
})
},
pushData() {
let index = this.eventsData.indexOf(this.modeFunctionForm)
if (index < 0) {
this.eventsData.push(this.modeFunctionForm)
}
},
// //
cancel() { cancel() {
this.open = false; this.open = false;
this.reset(); this.reset();
}, },
//
reset() { //
this.form = { cancelParameter() {
modeFunctionId: null, this.inputParameterOpen = false;
deviceModeId: null, this.resetInputParameter();
functionMode: null, },
coordinate: null,
functionName: null, //
functionIdentifier: null, resetInputParameter(parameterType) {
functionType: null, this.inputParameterForm = {
parameterType: parameterType,
parameterName: null,
parameterIdentifier: null,
dataType: null, dataType: null,
dataDefinition: null, dataDefinition: null,
functionFormula: null, minvalue: '',
propertyUnit: null, maxValue: '',
displayFlag: null, boolFalse: '',
rwFlag: null, boolTrue: ''
invokeMethod: null,
eventType: null,
remark: null,
acquisitionFormula: null,
orderFlag: null,
deviceRegister: null,
propertyStep: null,
propertyField: null
}; };
this.resetForm("form"); //this.resetForm("inputParameterForm");
}, },
/** 搜索按钮操作 */
handleQuery() { handleAddOutputParameter() {
this.queryParams.pageNum = 1; this.resetInputParameter(2);
this.getList(); this.inputParameterOpen = true;
this.inputParameterTitle = "添加设备模型事件输出参数";
}, },
/** 重置按钮操作 */
resetQuery() { handleUpdateOutputParameter(row) {
this.resetForm("queryForm"); this.convertParameterDefinition(row)
this.handleQuery(); this.inputParameterForm = row;
this.inputParameterOpen = true;
this.inputParameterTitle = "添加设备模型事件输出参数";
}, },
//
handleSelectionChange(selection) { convertParameterDefinition(row) {
this.ids = selection.map(item => item.modeFunctionId) if (parseInt(row.dataType) === 8) {
this.single = selection.length!==1 let dataDefinitionJson = JSON.parse(row.dataDefinition)
this.multiple = !selection.length row.boolFalse = dataDefinitionJson["0"];
row.boolTrue = dataDefinitionJson["1"];
}
}, },
/** 新增按钮操作 */
handleAdd() { handleDeleteOutputParameter(row) {
this.reset(); this.modeFunctionForm.outputParameters.splice(this.modeFunctionForm.outputParameters.indexOf(row), 1);
this.open = true;
this.title = "添加设备模型功能";
}, },
/** 修改按钮操作 */
handleUpdate(row) { submitInputParameterForm() {
this.reset(); this.$refs['inputParameterForm'].validate(valid => {
const modeFunctionId = row.modeFunctionId || this.ids
getDeviceModeFunction(modeFunctionId).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改设备模型功能";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) { if (valid) {
if (this.form.modeFunctionId != null) { /** 设备模型添加后在list中添加 */
updateDeviceModeFunction(this.form).then(response => { //alert(this.minValue+"--"+this.maxValue)
this.$modal.msgSuccess("修改成功"); if (this.inputParameterForm.dataType === "8") {
this.open = false; let boolFalse = this.inputParameterForm.boolFalse;
this.getList(); let boolTrue = this.inputParameterForm.boolTrue;
}); if (boolFalse === '' || boolTrue === '') {
this.$modal.msgError("请输入布尔值");
return;
} else {
this.inputParameterForm.dataDefinition = '{"0":"' + boolFalse + '","1":"' + boolTrue + '"}';
}
}
this.inputParameterOpen = false;
let inputParameters = this.inputParameterForm;
if (this.inputParameterForm.parameterType === 1) {
let index = this.modeFunctionForm.inputParameters.indexOf(inputParameters)
if (index < 0) {
this.modeFunctionForm.inputParameters.push(inputParameters);
}
} else { } else {
addDeviceModeFunction(this.form).then(response => { let index = this.modeFunctionForm.outputParameters.indexOf(inputParameters)
this.$modal.msgSuccess("新增成功"); if (index < 0) {
this.open = false; this.modeFunctionForm.outputParameters.push(inputParameters);
this.getList(); }
});
} }
} }
}); })
},
/** 删除按钮操作 */
handleDelete(row) {
const modeFunctionIds = row.modeFunctionId || this.ids;
this.$modal.confirm('是否确认删除设备模型功能编号为"' + modeFunctionIds + '"的数据项?').then(function() {
return delDeviceModeFunction(modeFunctionIds);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
this.download('business/deviceModeFunction/export', {
...this.queryParams
}, `deviceModeFunction_${new Date().getTime()}.xlsx`)
} }
} }
}; };

@ -1,128 +1,643 @@
<template> <template>
<el-card>
<el-tabs v-model="activeName">
<el-tab-pane label="基本信息" name="basic">
<basic-info-form ref="basicInfo" :info="info" />
</el-tab-pane>
<el-tab-pane label="字段信息" name="columnInfo">
<el-table ref="dragTable" :data="columns" row-key="columnId" :max-height="tableHeight">
<el-table-column label="序号" type="index" min-width="5%" class-name="allowDrag" />
<el-table-column
label="字段列名"
prop="columnName"
min-width="10%"
:show-overflow-tooltip="true"
/>
<el-table-column label="字段描述" min-width="10%">
<template slot-scope="scope">
<el-input v-model="scope.row.columnComment"></el-input>
</template>
</el-table-column>
<el-table-column
label="物理类型"
prop="columnType"
min-width="10%"
:show-overflow-tooltip="true"
/>
<el-table-column label="Java类型" min-width="11%">
<template slot-scope="scope">
<el-select v-model="scope.row.javaType">
<el-option label="Long" value="Long" />
<el-option label="String" value="String" />
<el-option label="Integer" value="Integer" />
<el-option label="Double" value="Double" />
<el-option label="BigDecimal" value="BigDecimal" />
<el-option label="Date" value="Date" />
<el-option label="Boolean" value="Boolean" />
</el-select>
</template>
</el-table-column>
<el-table-column label="java属性" min-width="10%">
<template slot-scope="scope">
<el-input v-model="scope.row.javaField"></el-input>
</template>
</el-table-column>
<el-table-column label="插入" min-width="5%"> <div class="app-container">
<template slot-scope="scope"> <el-form ref="basicInfoForm" :model="info" :rules="rules" label-width="150px">
<el-checkbox true-label="1" false-label="0" v-model="scope.row.isInsert"></el-checkbox> <el-form-item label="通用标识" prop="commonFlag" v-if="false">
</template> <el-input placeholder="请选择通用标识" v-model="info.commonFlag"/>
</el-table-column>
<el-table-column label="编辑" min-width="5%">
<template slot-scope="scope">
<el-checkbox true-label="1" false-label="0" v-model="scope.row.isEdit"></el-checkbox>
</template>
</el-table-column>
<el-table-column label="列表" min-width="5%">
<template slot-scope="scope">
<el-checkbox true-label="1" false-label="0" v-model="scope.row.isList"></el-checkbox>
</template>
</el-table-column>
<el-table-column label="查询" min-width="5%">
<template slot-scope="scope">
<el-checkbox true-label="1" false-label="0" v-model="scope.row.isQuery"></el-checkbox>
</template>
</el-table-column>
<el-table-column label="查询方式" min-width="10%">
<template slot-scope="scope">
<el-select v-model="scope.row.queryType">
<el-option label="=" value="EQ" />
<el-option label="!=" value="NE" />
<el-option label=">" value="GT" />
<el-option label=">=" value="GTE" />
<el-option label="<" value="LT" />
<el-option label="<=" value="LTE" />
<el-option label="LIKE" value="LIKE" />
<el-option label="BETWEEN" value="BETWEEN" />
</el-select>
</template>
</el-table-column>
<el-table-column label="必填" min-width="5%">
<template slot-scope="scope">
<el-checkbox true-label="1" false-label="0" v-model="scope.row.isRequired"></el-checkbox>
</template>
</el-table-column>
<el-table-column label="显示类型" min-width="12%">
<template slot-scope="scope">
<el-select v-model="scope.row.htmlType">
<el-option label="文本框" value="input" />
<el-option label="文本域" value="textarea" />
<el-option label="下拉框" value="select" />
<el-option label="单选框" value="radio" />
<el-option label="复选框" value="checkbox" />
<el-option label="日期控件" value="datetime" />
<el-option label="图片上传" value="imageUpload" />
<el-option label="文件上传" value="fileUpload" />
<el-option label="富文本控件" value="editor" />
</el-select>
</template>
</el-table-column>
<el-table-column label="字典类型" min-width="12%">
<template slot-scope="scope">
<el-select v-model="scope.row.dictType" clearable filterable placeholder="请选择">
<el-option
v-for="dict in dictOptions"
:key="dict.dictType"
:label="dict.dictName"
:value="dict.dictType">
<span style="float: left">{{ dict.dictName }}</span>
<span style="float: right; color: #8492a6; font-size: 13px">{{ dict.dictType }}</span>
</el-option>
</el-select>
</template>
</el-table-column>
</el-table>
</el-tab-pane>
<el-tab-pane label="生成信息" name="genInfo">
<gen-info-form ref="genInfo" :info="info" :tables="tables" :menus="menus"/>
</el-tab-pane>
</el-tabs>
<el-form label-width="100px">
<el-form-item style="text-align: center;margin-left:-100px;margin-top:10px;">
<el-button type="primary" @click="submitForm()"></el-button>
<el-button @click="close()"></el-button>
</el-form-item> </el-form-item>
<el-row>
<el-col :span="12">
<el-form-item label="模型名称" prop="deviceModeName">
<el-input placeholder="请输入模型名称" v-model="info.deviceModeName"/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="所属场景" prop="sceneId">
<el-select v-model="info.sceneId" placeholder="请选择" :disabled="disabled">
<el-option
v-for="(scene, index) in scenes"
:key="index"
:label="scene.sceneName"
:value="scene.sceneId"
></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="定位标识" prop="gpsFlag">
<el-radio-group v-model="info.gpsFlag" @input="gpsFlagRadioChange" :disabled="disabled">
<el-radio
v-for="dict in dict.type.hw_device_mode_gps_flag"
:key="dict.value"
:label="dict.value"
v-model="gps_flag"
>{{ dict.label }}
</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="模型分类" prop="modeClassfication">
<el-select v-model="info.modeClassfication" placeholder="请选择数据类型">
<el-option
v-for="dict in dict.type.hw_mode_function_mode_classfication"
:key="dict.value"
:label="dict.label"
:value="dict.value"
></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="语言" prop="language_code" v-if="false">
<el-select v-model="info.languageCode" placeholder="请选择">
<el-option
v-for="(language, index) in languages"
:key="index"
:label="language.languageName"
:value="language.languageCode"
></el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
</el-form> </el-form>
</el-card>
<el-card>
<el-tabs v-model="activeName">
<el-tab-pane label="属性" name="attributesInfo">
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
>新增
</el-button>
</el-col>
</el-row>
<el-table ref="attributesTable" :data="attributesData" row-key="columnId">
<el-table-column label="序号" type="index" min-width="5%" class-name="allowDrag"/>
<el-table-column
label="功能模式"
prop="functionMode"
v-if="false"
/>
<el-table-column
label="定位坐标标识"
prop="coordinate"
v-if="false"
/>
<el-table-column
label="描述"
prop="remark"
v-if="false"
/>
<el-table-column
label="功能类型"
prop="functionType"
min-width="10%">
<template slot-scope="scope">
<dict-tag :options="dict.type.hw_mode_function_function_type" :value="scope.row.functionType"/>
</template>
</el-table-column>
<el-table-column
label="功能名称"
prop="functionName"
min-width="10%"
:show-overflow-tooltip="true"
/>
<el-table-column
label="标识符"
prop="functionIdentifier"
min-width="10%"
:show-overflow-tooltip="true"
/>
<el-table-column prop="dataType" label="数据类型" min-width="10%">
<template slot-scope="scope">
<dict-tag :options="dict.type.hw_mode_function_data_type" :value="scope.row.dataType"/>
</template>
</el-table-column>
<el-table-column
label="数据定义"
prop="dataDefinition"
min-width="10%"
:show-overflow-tooltip="true"
/>
<el-table-column
label="单位"
prop="propertyUnit"
min-width="10%"
:show-overflow-tooltip="true"
/>
<el-table-column
label="读写权限"
prop="rwFlag"
min-width="10%"
:show-overflow-tooltip="true"
>
<template slot-scope="scope">
<dict-tag :options="dict.type.hw_mode_function_rw_flag" :value="scope.row.rwFlag"/>
</template>
</el-table-column>
<el-table-column
label="显示"
prop="displayFlag"
min-width="10%"
:show-overflow-tooltip="true"
>
<template slot-scope="scope">
<dict-tag :options="dict.type.hw_mode_function_display_flag" :value="scope.row.displayFlag"/>
</template>
</el-table-column>
<el-table-column label="操作" align="center" min-width="10%">
<template slot-scope="scope" v-if="scope.row.roleId !== 1">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
v-if="scope.row.coordinate==null"
@click="handleUpdateAttribute(scope.row)"
>修改
</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
v-if="scope.row.coordinate==null"
@click="handleDeleteAttribute(scope.row)"
>删除
</el-button>
</template>
</el-table-column>
</el-table>
<!-- 添加或修改设备模型功能对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="modeFunctionForm" :model="form" :rules="modeFunctionRules" label-width="80px">
<el-form-item label="功能模式" prop="functionMode" v-show="false">
<el-input v-model="form.functionMode" placeholder="请输入功能模式"/>
</el-form-item>
<el-form-item label="功能类型" prop="functionType">
<el-select v-model="form.functionType" placeholder="请选择功能类型">
<el-option
v-for="dict in dict.type.hw_mode_function_function_type"
:key="dict.value"
:label="dict.label"
:value="dict.value"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="功能名称" prop="functionName">
<el-input v-model="form.functionName" placeholder="请输入功能名称"/>
</el-form-item>
<el-form-item label="标识符" prop="functionIdentifier">
<el-input v-model="form.functionIdentifier" placeholder="请输入标识符" maxlength="20"/>
</el-form-item>
<el-form-item label="数据类型" prop="dataType">
<el-select v-model="form.dataType" placeholder="请选择数据类型">
<el-option
v-for="dict in dict.type.hw_mode_function_data_type"
:key="dict.value"
:label="dict.label"
:value="dict.value"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="取值范围" prop="dataDefinition" v-show="false">
<el-input v-model="form.minValue" placeholder="请输入最小值" style="width:150px;"/>
<el-input v-model="form.maxValue" placeholder="请输入最大值" style="width:150px;"/>
</el-form-item>
<el-form-item label="布尔值" prop="dataDefinition" v-show="form.dataType == '8'">
0
<el-input v-model="form.boolFalse" placeholder="请输入值" style="width:150px;"/>
</el-form-item>
<el-form-item label="" prop="dataDefinition" v-show="form.dataType == '8'">
1
<el-input v-model="form.boolTrue" placeholder="请输入值" style="width:150px;"/>
</el-form-item>
<el-form-item label="长度" prop="dataDefinition" v-show="form.dataType == '10'">
<el-input-number v-model="form.dataDefinition" placeholder="请输入最大长度" :max="1000"
style="width:150px;"/>
</el-form-item>
<el-form-item label="单位" prop="propertyUnit">
<el-input v-model="form.propertyUnit" placeholder="请输入单位"/>
</el-form-item>
<el-form-item label="显示标识" prop="displayFlag">
<el-radio-group v-model="form.displayFlag">
<el-radio
v-for="dict in dict.type.hw_mode_function_display_flag"
:key="dict.value"
:label="dict.value"
>{{ dict.label }}
</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="读写标识" prop="rwFlag">
<el-radio-group v-model="form.rwFlag">
<el-radio
v-for="dict in dict.type.hw_mode_function_rw_flag"
:key="dict.value"
:label="dict.value"
>{{ dict.label }}
</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="描述" prop="remark">
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容"/>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitDeviceModeFunctionForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</el-tab-pane>
<el-tab-pane label="服务" name="servicesInfo">
<device-mode-service ref="servicesTable" :servicesData="servicesData" :deviceModeId="deviceModeId"/>
</el-tab-pane>
<el-tab-pane label="事件" name="eventsInfo">
<device-mode-event ref="eventInfo" :eventsData="eventsData" :deviceModeId="deviceModeId"/>
</el-tab-pane>
</el-tabs>
<el-form label-width="100px">
<el-form-item style="text-align: center;margin-left:-100px;margin-top:10px;">
<el-button type="primary" @click="submitForm()"></el-button>
<el-button @click="close()"></el-button>
</el-form-item>
</el-form>
</el-card>
</div>
</template> </template>
<script>
import {getLanguages} from "@/api/basic/language";
import {getScenes} from "@/api/business/scene";
import {addDeviceMode, getDeviceMode, updateDeviceMode} from "@/api/business/deviceMode";
import deviceModeService from "./deviceModeService";
import deviceModeEvent from "./deviceModeEvent";
import {
addDeviceModeFunction,
updateDeviceModeFunction,
delDeviceModeFunction
} from "@/api/business/deviceModeFunction";
import {changeUserStatus} from "@/api/system/user";
export default {
dicts: ['hw_device_mode_gps_flag', 'hw_mode_function_mode_classfication', 'hw_mode_function_function_type', 'hw_mode_function_function_type', 'hw_mode_function_data_type', 'hw_mode_function_display_flag', 'hw_mode_function_rw_flag'],
components: {
deviceModeService,
deviceModeEvent
},
props: [],
data() {
return {
info: {},
//
title: "",
//
form: {},
editedForm:{},
gps_flag: '',
//
open: false,
disabled: true,
rules: {
deviceModeName: [{
required: true,
message: '请输入模型名称',
trigger: 'blur'
}],
sceneId: [
{required: true, message: "请选择场景", trigger: "change"}
],
gpsFlag: [
{required: true, message: "请选择定位标识", trigger: "change"}
],
},
modeFunctionRules: {
functionType: [
{required: true, message: "请选择功能类型", trigger: "blur"},
],
functionName: [
{required: true, message: "请输入功能名称", trigger: "blur"}
],
functionIdentifier: [
{required: true, message: "请输入标识符", trigger: "blur"},
{
pattern: /^[a-z][a-z0-9_]+$/,
message: "2-20个字符由小写字母、数字或下划线组成开头必须为小写字母",
trigger: "blur"
}
],
},
// name
activeName: "attributesInfo",
//
scenes: [],
//
languages: [],
//
IDENTIFIER_LONGITUDE: 'longitude',
//
IDENTIFIER_LATITUDE: 'latitude',
//ID
deviceModeId: '',
//
attributesData: [],
//
servicesData: [],
//
eventsData: [],
//
tableHeight: document.documentElement.scrollHeight - 245 + "px",
}
},
created() {
this.getConfigKey("hw.gps.longitude").then(response => {//
this.IDENTIFIER_LONGITUDE = response.msg;
});
this.getConfigKey("hw.gps.latitude").then(response => {//
this.IDENTIFIER_LATITUDE = response.msg;
});
// getLanguages().then(response => {
// this.languages = response.data;
// });
getScenes().then(response => {
this.scenes = response.data;
});
const deviceModeId = this.$route.params && this.$route.params.deviceModeId;
if (deviceModeId) {
//
getDeviceMode(deviceModeId).then(res => {
this.info = res.data.deviceMode;
this.attributesData = (res.data.deviceModeFunctionMap)['1'];
this.servicesData = (res.data.deviceModeFunctionMap)['2'];
this.eventsData = (res.data.deviceModeFunctionMap)['3'];
this.deviceModeId = deviceModeId;
// this.columns = res.data.rows;
});
/** 查询字典下拉列表 */
// getDictOptionselect().then(response => {
// this.dictOptions = response.data;
// });
} else {
//
this.info = {
gpsFlag: "0",
commonFlag: "0"
};
this.gps_flag = "0"
this.disabled = false;
this.eventsData = [];
}
},
computed: {},
watch: {},
mounted() {
},
methods: {
//
gpsFlagRadioChange(value) {
if (parseInt(value) === 1) {//
let attributesData = this.attributesData;
if (attributesData.length > 0) {
this.$modal.confirm('修改定位标识会删除所有属性,确定修改定位标识么?').then(function () {
attributesData.splice(0, attributesData.length);
}).then(() => {
this.addGpsAttribute();
});
} else {
this.addGpsAttribute();
}
} else {
let attributesData = this.attributesData;
if (attributesData.length > 0) {
this.$modal.confirm('修改定位标识会删除所有属性,确定修改定位标识么?').then(function () {
attributesData.splice(0, attributesData.length);
});
}
}
},
addGpsAttribute() {
this.reset();
this.form.coordinate = "1"
this.form.functionIdentifier = this.IDENTIFIER_LONGITUDE;
this.form.functionName = "经度";
this.form.dataType = 5;
this.attributesData.push(this.form);
this.reset();
this.form.coordinate = "2"
this.form.functionIdentifier = this.IDENTIFIER_LATITUDE;
this.form.functionName = "纬度";
this.form.dataType = 5;
this.attributesData.push(this.form);
},
/** 新增属性按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加设备模型属性";
},
//
reset() {
this.form = {
functionMode: '1',
modeFunctionId: null,
deviceModeId: null,
coordinate: null,
functionName: null,
functionIdentifier: null,
functionType: "1",//
dataType: "2",//int
dataDefinition: null,
functionFormula: null,
propertyUnit: null,
displayFlag: "1",//
rwFlag: "2",//
boolFalse: '',
boolTrue: '',
minValue: '',
maxValue: '',
invokeMethod: null,
eventType: null,
remark: null,
};
// this.resetForm("modeFunctionForm");
},
handleUpdateAttribute(row) {
this.convertParameterDefinition(row);
this.form = row;
this.open = true;
this.title = "添加设备模型属性";
},
convertParameterDefinition(row) {
let dataType = row.dataType;
if (parseInt(dataType) === 8) {
let dataDefinitionJson = JSON.parse(row.dataDefinition)
row.boolFalse = dataDefinitionJson["0"];
row.boolTrue = dataDefinitionJson["1"];
}
row.dataType = dataType.toString();
},
handleDeleteAttribute(row) {
if (row.modeFunctionId !== undefined) {
delDeviceModeFunction(row.modeFunctionId).then(res => {
this.$modal.msgSuccess(res.msg);
if (res.code === 200) {
this.attributesData.splice(this.attributesData.indexOf(row), 1);
}
});
} else {
this.attributesData.splice(this.attributesData.indexOf(row), 1);
}
},
/** 关闭按钮 */
close() {
// alert(this.$route.query.pageNum);
const obj = {path: "/device/deviceMode", query: {t: Date.now(), pageNum: this.$route.query.pageNum}};
this.$tab.closeOpenPage(obj);
},
submitDeviceModeFunctionForm() {
this.$refs['modeFunctionForm'].validate(valid => {
if (valid) {
/** 设备模型添加后在list中添加 */
//alert(this.minValue+"--"+this.maxValue)
if (this.form.dataType === "8") {
let boolFalse = this.form.boolFalse;
let boolTrue = this.form.boolTrue;
if (boolFalse === '' || boolTrue === '') {
this.$modal.msgError("请输入布尔值");
return;
} else {
this.form.dataDefinition = '{"0":"' + boolFalse + '","1":"' + boolTrue + '"}';
}
}
if (this.deviceModeId && this.deviceModeId !== '') {
let modeFunctionId = this.form.modeFunctionId;
this.form.deviceModeId = this.deviceModeId;
if (modeFunctionId !== undefined && modeFunctionId != null) {
updateDeviceModeFunction(this.form).then(res => {
this.$modal.msgSuccess(res.msg);
if (res.code === 200) {
this.open = false;
}
});
} else {
addDeviceModeFunction(this.form).then(res => {
this.$modal.msgSuccess(res.msg);
if (res.code === 200) {
this.open = false;
this.form.modeFunctionId = res.data;
this.pushData();
}
});
}
} else {
this.open = false;
this.pushData();
}
}
})
},
pushData() {
let index = this.attributesData.indexOf(this.form)
if (index < 0) {
let editedForm = this.form;
this.attributesData.push(editedForm)
}
},
//
cancel() {
this.open = false;
this.reset();
},
submitForm() {
this.$refs['basicInfoForm'].validate(valid => {
if (valid) {
if (this.info.deviceModeId != undefined) {
updateDeviceMode(this.info).then(res => {
this.$modal.msgSuccess(res.msg);
if (res.code === 200) {
this.close();
}
});
} else {
if (this.attributesData.length <= 0) {
this.$modal.msgError("请添加属性");
return;
}
let functionData = this.servicesData.concat(this.attributesData);
functionData = functionData.concat(this.eventsData)
this.info.hwDeviceModeFunctionList = functionData;
addDeviceMode(this.info).then(res => {
this.$modal.msgSuccess(res.msg);
if (res.code === 200) {
this.close();
}
});
}
}
})
},
},
}
</script>

@ -9,26 +9,26 @@
@keyup.enter.native="handleQuery" @keyup.enter.native="handleQuery"
/> />
</el-form-item> </el-form-item>
<el-form-item label="租户ID关联hw_tenant的tenant_id" prop="tenantId"> <el-form-item label="租户ID" prop="tenantId">
<el-input <el-input
v-model="queryParams.tenantId" v-model="queryParams.tenantId"
placeholder="请输入租户ID关联hw_tenant的tenant_id" placeholder="请输入租户ID"
clearable clearable
@keyup.enter.native="handleQuery" @keyup.enter.native="handleQuery"
/> />
</el-form-item> </el-form-item>
<el-form-item label="所属场景关联hw_scene表的scene_id字段" prop="sceneId"> <el-form-item label="所属场景" prop="sceneId">
<el-input <el-input
v-model="queryParams.sceneId" v-model="queryParams.sceneId"
placeholder="请输入所属场景关联hw_scene表的scene_id字段" placeholder="请输入所属场景"
clearable clearable
@keyup.enter.native="handleQuery" @keyup.enter.native="handleQuery"
/> />
</el-form-item> </el-form-item>
<el-form-item label="语言code,关联表hw_language的language_code字段" prop="languageCode"> <el-form-item label="语言code" prop="languageCode">
<el-input <el-input
v-model="queryParams.languageCode" v-model="queryParams.languageCode"
placeholder="请输入语言code,关联表hw_language的language_code字段" placeholder="请输入语言code"
clearable clearable
@keyup.enter.native="handleQuery" @keyup.enter.native="handleQuery"
/> />
@ -57,30 +57,7 @@
@keyup.enter.native="handleQuery" @keyup.enter.native="handleQuery"
/> />
</el-form-item> </el-form-item>
<el-form-item label="设备模型图片地址" prop="deviceModePic">
<el-input
v-model="queryParams.deviceModePic"
placeholder="请输入设备模型图片地址"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="预留字段,数据校验级别" prop="dataVerifyLevel">
<el-input
v-model="queryParams.dataVerifyLevel"
placeholder="请输入预留字段,数据校验级别"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="预留字段" prop="deviceModeField">
<el-input
v-model="queryParams.deviceModeField"
placeholder="请输入预留字段"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item> <el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery"></el-button> <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery"></el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery"></el-button> <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"></el-button>
@ -137,17 +114,15 @@
<el-table-column type="selection" width="55" align="center" /> <el-table-column type="selection" width="55" align="center" />
<el-table-column label="设备模型ID" align="center" prop="deviceModeId" /> <el-table-column label="设备模型ID" align="center" prop="deviceModeId" />
<el-table-column label="设备模型名称" align="center" prop="deviceModeName" /> <el-table-column label="设备模型名称" align="center" prop="deviceModeName" />
<el-table-column label="租户ID关联hw_tenant的tenant_id" align="center" prop="tenantId" /> <el-table-column label="租户ID" align="center" prop="tenantId" />
<el-table-column label="所属场景关联hw_scene表的scene_id字段" align="center" prop="sceneId" /> <el-table-column label="所属场景" align="center" prop="sceneId" />
<el-table-column label="语言code,关联表hw_language的language_code字段" align="center" prop="languageCode" /> <el-table-column label="语言code" align="center" prop="languageCode" />
<el-table-column label="定位标识" align="center" prop="gpsFlag" /> <el-table-column label="定位标识" align="center" prop="gpsFlag" />
<el-table-column label="设备模型状态" align="center" prop="deviceModeStatus" /> <el-table-column label="设备模型状态" align="center" prop="deviceModeStatus" />
<el-table-column label="是否通用物模型" align="center" prop="commonFlag" /> <el-table-column label="是否通用物模型" align="center" prop="commonFlag" />
<el-table-column label="模型分类" align="center" prop="modeClassfication" /> <el-table-column label="模型分类" align="center" prop="modeClassfication" />
<el-table-column label="设备模型图片地址" align="center" prop="deviceModePic" /> <el-table-column label="设备模型图片地址" align="center" prop="deviceModePic" />
<el-table-column label="预留字段,数据校验级别" align="center" prop="dataVerifyLevel" />
<el-table-column label="场景描述" align="center" prop="remark" /> <el-table-column label="场景描述" align="center" prop="remark" />
<el-table-column label="预留字段" align="center" prop="deviceModeField" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width"> <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button <el-button
@ -482,28 +457,24 @@ export default {
}, },
/** 新增按钮操作 */ /** 新增按钮操作 */
handleAdd() { handleAdd() {
this.reset(); const params = { pageNum: this.queryParams.pageNum };
this.open = true; this.$tab.openPage("添加设备模型", '/deviceMode/mode-add/index', params);
this.title = "添加设备模型";
// const deviceModeId = row.deviceModeId || this.ids[0];
// alert(deviceModeId)
// const deviceModeName = row.deviceModeName || this.tableNames[0];
//const params = { pageNum: this.queryParams.pageNum };
// this.$tab.openPage("[" + deviceModeName + "]", '/deviceMode/mode-edit/index/' + deviceModeId, params);
//this.$tab.openPage("", '/deviceMode/mode-edit/index/1', params);
}, },
/** 修改按钮操作 */ /** 修改按钮操作 */
handleUpdate(row) { handleUpdate(row) {
this.reset(); this.reset();
const deviceModeId = row.deviceModeId || this.ids const deviceModeId = row.deviceModeId || this.ids
const deviceModeName = row.deviceModeName || this.tableNames[0];
const params = { pageNum: this.queryParams.pageNum };
getDeviceMode(deviceModeId).then(response => { getDeviceMode(deviceModeId).then(response => {
this.form = response.data; // this.form = response.data;
this.hwDeviceModeFunctionList = response.data.hwDeviceModeFunctionList; // this.hwDeviceModeFunctionList = response.data.hwDeviceModeFunctionList;
this.open = true; // this.open = true;
this.title = "修改设备模型"; // this.title = "";
this.$tab.openPage("修改[" + deviceModeName + "]", '/deviceMode/mode-edit/index/' + deviceModeId, params);
}); });
}, },
/** 提交按钮 */ /** 提交按钮 */

Loading…
Cancel
Save