Compare commits
5 Commits
master
...
breach-zhy
Author | SHA1 | Date |
---|---|---|
maxw@mesnac.com | 66dd765033 | 2 weeks ago |
maxw@mesnac.com | 9bce8c0df2 | 2 weeks ago |
maxw@mesnac.com | b817d4b51b | 2 weeks ago |
maxw@mesnac.com | d08e7012ff | 3 weeks ago |
maxw@mesnac.com | eb7844ffc0 | 3 weeks ago |
@ -0,0 +1,149 @@
|
||||
package com.ruoyi.business.controller;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.ruoyi.business.domain.HwDevice;
|
||||
import com.ruoyi.business.domain.HwDeviceMode;
|
||||
import com.ruoyi.business.domain.PlcDevice;
|
||||
import com.ruoyi.business.domain.PlcDeviceMode;
|
||||
import com.ruoyi.business.service.PlcDeviceService;
|
||||
import com.ruoyi.common.core.web.controller.BaseController;
|
||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.web.page.TableDataInfo;
|
||||
import com.ruoyi.common.security.utils.SecurityUtils;
|
||||
import org.apache.plc4x.java.api.exceptions.PlcConnectionException;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
/**
|
||||
* plc设备信息(PlcDevice)表控制层
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2024-12-19 16:22:43
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("plcDevice")
|
||||
public class PlcDeviceController extends BaseController {
|
||||
/**
|
||||
* 服务对象
|
||||
*/
|
||||
@Resource
|
||||
private PlcDeviceService plcDeviceService;
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param plcDevice 筛选条件
|
||||
* @param pageRequest 分页对象
|
||||
* @return 查询结果
|
||||
*/
|
||||
@GetMapping
|
||||
public ResponseEntity<Page<PlcDevice>> queryByPage(PlcDevice plcDevice, PageRequest pageRequest) {
|
||||
return ResponseEntity.ok(this.plcDeviceService.queryByPage(plcDevice, pageRequest));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过主键查询单条数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 单条数据
|
||||
*/
|
||||
@GetMapping("{deviceId}")
|
||||
public AjaxResult queryById(@PathVariable("deviceId") Long id) throws JsonProcessingException {
|
||||
return AjaxResult.success(this.plcDeviceService.queryById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param plcDevice 实体
|
||||
* @return 新增结果
|
||||
*/
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody PlcDevice plcDevice) {
|
||||
return toAjax(this.plcDeviceService.insert(plcDevice));
|
||||
}
|
||||
|
||||
@PutMapping("/changeDeviceStatus")
|
||||
public AjaxResult changeDeviceStatus(@RequestBody PlcDevice device) {
|
||||
return toAjax(plcDeviceService.changeDeviceStatus(device));
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑数据
|
||||
*
|
||||
* @param plcDevice 实体
|
||||
* @return 编辑结果
|
||||
*/
|
||||
// @PutMapping
|
||||
// public AjaxResult edit(PlcDevice plcDevice) {
|
||||
// return AjaxResult.success(plcDeviceService.update(plcDevice));
|
||||
// }
|
||||
@GetMapping("getProtocols")
|
||||
public AjaxResult getProtocols(){
|
||||
HashMap<String, String> map = new HashMap<>();
|
||||
map.put("protocolName","mc");
|
||||
map.put("protocolValue","1");
|
||||
HashMap<String, String> map1 = new HashMap<>();
|
||||
map1.put("protocolName","modbus");
|
||||
map1.put("protocolValue","2");
|
||||
ArrayList<HashMap> objects = new ArrayList<>();
|
||||
objects.add(map);
|
||||
objects.add(map1);
|
||||
return AjaxResult.success(objects);
|
||||
}
|
||||
/**
|
||||
* 删除数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 删除是否成功
|
||||
*/
|
||||
@DeleteMapping("{deviceId}")
|
||||
public AjaxResult deleteById(@PathVariable("deviceId") Long deviceId) {
|
||||
return AjaxResult.success(this.plcDeviceService.deleteById(deviceId));
|
||||
}
|
||||
@GetMapping("/modbusDataProcess")
|
||||
public AjaxResult modbusDataProcess() throws JsonProcessingException {
|
||||
return AjaxResult.success(plcDeviceService.modbusDataProcess());
|
||||
}
|
||||
|
||||
@GetMapping("/mcDataProcess")
|
||||
public AjaxResult mcDataProcess() throws JsonProcessingException {
|
||||
return AjaxResult.success(plcDeviceService.mcDataProcess());
|
||||
}
|
||||
@GetMapping("/aeDataProcess")
|
||||
public AjaxResult aeDataProcess() throws JsonProcessingException {
|
||||
return AjaxResult.success(plcDeviceService.aeDataProcess());
|
||||
}
|
||||
@GetMapping("/ehternetDataProcess")
|
||||
public AjaxResult ehternetDataProcess() throws JsonProcessingException{
|
||||
return AjaxResult.success(plcDeviceService.ehternetDataProcess());
|
||||
}
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(PlcDevice hwDevice) {
|
||||
startPage();
|
||||
List<PlcDevice> list = plcDeviceService.selectHwDeviceJoinList(hwDevice);
|
||||
return getDataTable(list);
|
||||
}
|
||||
@GetMapping(value = {"/getDeviceModes/", "/getDeviceModes/{sceneId}"})
|
||||
public AjaxResult getDeviceModes(@PathVariable(value = "sceneId", required = false) Long sceneId) {
|
||||
PlcDeviceMode queryDeviceMode = new PlcDeviceMode();
|
||||
queryDeviceMode.setSceneId(sceneId);
|
||||
return success(plcDeviceService.selectHwDeviceModeList(queryDeviceMode));
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody PlcDevice hwDevice) {
|
||||
hwDevice.setUpdateBy(SecurityUtils.getUsername());
|
||||
return toAjax(plcDeviceService.updateDevice(hwDevice));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,111 @@
|
||||
package com.ruoyi.business.controller;
|
||||
|
||||
import com.ruoyi.business.domain.HwDeviceMode;
|
||||
import com.ruoyi.business.domain.HwDeviceModeFunction;
|
||||
import com.ruoyi.business.domain.PlcDeviceMode;
|
||||
import com.ruoyi.business.domain.PlcDeviceModeFunction;
|
||||
import com.ruoyi.business.service.PlcDeviceModeService;
|
||||
import com.ruoyi.common.core.constant.HwDictConstants;
|
||||
import com.ruoyi.common.core.web.controller.BaseController;
|
||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.web.page.TableDataInfo;
|
||||
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* plc设备模型(PlcDeviceMode)表控制层
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2024-12-19 16:23:27
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("plcDeviceMode")
|
||||
public class PlcDeviceModeController extends BaseController {
|
||||
/**
|
||||
* 服务对象
|
||||
*/
|
||||
@Resource
|
||||
private PlcDeviceModeService plcDeviceModeService;
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param plcDeviceMode 筛选条件
|
||||
* @param pageRequest 分页对象
|
||||
* @return 查询结果
|
||||
*/
|
||||
@GetMapping
|
||||
public ResponseEntity<Page<PlcDeviceMode>> queryByPage(PlcDeviceMode plcDeviceMode, PageRequest pageRequest) {
|
||||
return ResponseEntity.ok(this.plcDeviceModeService.queryByPage(plcDeviceMode, pageRequest));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过主键查询单条数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 单条数据
|
||||
*/
|
||||
@GetMapping("{deviceModeId}")
|
||||
public AjaxResult queryById(@PathVariable("deviceModeId") Long deviceModeId) {
|
||||
PlcDeviceMode hwDeviceMode = plcDeviceModeService.selectHwDeviceModeByDeviceModeId(deviceModeId);
|
||||
List<PlcDeviceModeFunction> hwDeviceModeFunctions = plcDeviceModeService.selectFunctionList(deviceModeId);
|
||||
hwDeviceMode.setFunctionList(null);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("deviceMode", hwDeviceMode);
|
||||
map.put("deviceModeFunctionMap", hwDeviceModeFunctions);
|
||||
return success(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param plcDeviceMode 实体
|
||||
* @return 新增结果
|
||||
*/
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody PlcDeviceMode plcDeviceMode) {
|
||||
return toAjax(this.plcDeviceModeService.insert(plcDeviceMode));
|
||||
}
|
||||
|
||||
@RequiresPermissions("business:deviceMode:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(PlcDeviceMode hwDeviceMode) {
|
||||
startPage();
|
||||
hwDeviceMode.setDeviceModeStatus(HwDictConstants.DEVICE_MODE_STATUS_NORMAL);
|
||||
List<PlcDeviceMode> list = plcDeviceModeService.selectList(hwDeviceMode);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑数据
|
||||
*
|
||||
* @param plcDeviceMode 实体
|
||||
* @return 编辑结果
|
||||
*/
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody PlcDeviceMode plcDeviceMode) {
|
||||
return toAjax(this.plcDeviceModeService.update(plcDeviceMode));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 删除是否成功
|
||||
*/
|
||||
@DeleteMapping("/{deviceModeIds}")
|
||||
public ResponseEntity<Integer> deleteById(@PathVariable Long[] deviceModeIds) {
|
||||
return ResponseEntity.ok(this.plcDeviceModeService.deleteHwDeviceModeByDeviceModeIds(deviceModeIds));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,87 @@
|
||||
package com.ruoyi.business.controller;
|
||||
|
||||
|
||||
import com.ruoyi.business.domain.PlcDeviceModeFunction;
|
||||
import com.ruoyi.business.service.PlcDeviceModeFunctionService;
|
||||
import com.ruoyi.common.core.web.controller.BaseController;
|
||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* plc设备模型功能(PlcDeviceModeFunction)表控制层
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2024-12-19 16:23:52
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("plcDeviceModeFunction")
|
||||
public class PlcDeviceModeFunctionController extends BaseController {
|
||||
/**
|
||||
* 服务对象
|
||||
*/
|
||||
@Resource
|
||||
private PlcDeviceModeFunctionService plcDeviceModeFunctionService;
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param plcDeviceModeFunction 筛选条件
|
||||
* @param pageRequest 分页对象
|
||||
* @return 查询结果
|
||||
*/
|
||||
@GetMapping
|
||||
public ResponseEntity<Page<PlcDeviceModeFunction>> queryByPage(PlcDeviceModeFunction plcDeviceModeFunction, PageRequest pageRequest) {
|
||||
return ResponseEntity.ok(this.plcDeviceModeFunctionService.queryByPage(plcDeviceModeFunction, pageRequest));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过主键查询单条数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 单条数据
|
||||
*/
|
||||
@GetMapping("{id}")
|
||||
public ResponseEntity<PlcDeviceModeFunction> queryById(@PathVariable("id") Long id) {
|
||||
return ResponseEntity.ok(this.plcDeviceModeFunctionService.queryById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param plcDeviceModeFunction 实体
|
||||
* @return 新增结果
|
||||
*/
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody PlcDeviceModeFunction plcDeviceModeFunction) {
|
||||
return toAjax(this.plcDeviceModeFunctionService.insert(plcDeviceModeFunction));
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑数据
|
||||
*
|
||||
* @param plcDeviceModeFunction 实体
|
||||
* @return 编辑结果
|
||||
*/
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody PlcDeviceModeFunction plcDeviceModeFunction) {
|
||||
return toAjax(this.plcDeviceModeFunctionService.update(plcDeviceModeFunction));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 删除是否成功
|
||||
*/
|
||||
@DeleteMapping("/{modeFunctionId}")
|
||||
public AjaxResult deleteById(@PathVariable("modeFunctionId") Long modeFunctionId) {
|
||||
return toAjax(this.plcDeviceModeFunctionService.deleteById(modeFunctionId));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,55 @@
|
||||
package com.ruoyi.business.service;
|
||||
import com.ruoyi.business.domain.PlcDeviceModeFunction;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
|
||||
/**
|
||||
* plc设备模型功能(PlcDeviceModeFunction)表服务接口
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2024-12-19 16:23:52
|
||||
*/
|
||||
public interface PlcDeviceModeFunctionService {
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
*
|
||||
* @param modeFunctionId 主键
|
||||
* @return 实例对象
|
||||
*/
|
||||
PlcDeviceModeFunction queryById(Long modeFunctionId);
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param plcDeviceModeFunction 筛选条件
|
||||
* @param pageRequest 分页对象
|
||||
* @return 查询结果
|
||||
*/
|
||||
Page<PlcDeviceModeFunction> queryByPage(PlcDeviceModeFunction plcDeviceModeFunction, PageRequest pageRequest);
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param plcDeviceModeFunction 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
int insert(PlcDeviceModeFunction plcDeviceModeFunction);
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param plcDeviceModeFunction 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
int update(PlcDeviceModeFunction plcDeviceModeFunction);
|
||||
|
||||
/**
|
||||
* 通过主键删除数据
|
||||
*
|
||||
* @param modeFunctionId 主键
|
||||
* @return 是否成功
|
||||
*/
|
||||
int deleteById(Long modeFunctionId);
|
||||
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
package com.ruoyi.business.service;
|
||||
import com.ruoyi.business.domain.HwDeviceMode;
|
||||
import com.ruoyi.business.domain.PlcDeviceMode;
|
||||
import com.ruoyi.business.domain.PlcDeviceModeFunction;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* plc设备模型(PlcDeviceMode)表服务接口
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2024-12-19 16:23:27
|
||||
*/
|
||||
public interface PlcDeviceModeService {
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
*
|
||||
* @param deviceModeId 主键
|
||||
* @return 实例对象
|
||||
*/
|
||||
PlcDeviceMode queryById(Long deviceModeId);
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param plcDeviceMode 筛选条件
|
||||
* @param pageRequest 分页对象
|
||||
* @return 查询结果
|
||||
*/
|
||||
Page<PlcDeviceMode> queryByPage(PlcDeviceMode plcDeviceMode, PageRequest pageRequest);
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param plcDeviceMode 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
int insert(PlcDeviceMode plcDeviceMode);
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param plcDeviceMode 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
int update(PlcDeviceMode plcDeviceMode);
|
||||
|
||||
/**
|
||||
* 通过主键删除数据
|
||||
*
|
||||
* @param deviceModeId 主键
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean deleteById(Long deviceModeId);
|
||||
|
||||
List<PlcDeviceMode> selectList(PlcDeviceMode hwDeviceMode);
|
||||
|
||||
PlcDeviceMode selectHwDeviceModeByDeviceModeId(Long deviceModeId);
|
||||
|
||||
List<PlcDeviceModeFunction> selectFunctionList(Long deviceModeId);
|
||||
|
||||
int deleteHwDeviceModeByDeviceModeIds(Long[] deviceModeIds);
|
||||
}
|
@ -0,0 +1,79 @@
|
||||
package com.ruoyi.business.service;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.ruoyi.business.domain.HwDeviceMode;
|
||||
import com.ruoyi.business.domain.PlcDevice;
|
||||
import com.ruoyi.business.domain.PlcDeviceMode;
|
||||
import org.apache.plc4x.java.api.exceptions.PlcConnectionException;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
/**
|
||||
* plc设备信息(PlcDevice)表服务接口
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2024-12-19 16:22:51
|
||||
*/
|
||||
public interface PlcDeviceService {
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
*
|
||||
* @param deviceId 主键
|
||||
* @return 实例对象
|
||||
*/
|
||||
PlcDevice queryById(Long deviceId) throws JsonProcessingException;
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param plcDevice 筛选条件
|
||||
* @param pageRequest 分页对象
|
||||
* @return 查询结果
|
||||
*/
|
||||
Page<PlcDevice> queryByPage(PlcDevice plcDevice, PageRequest pageRequest);
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param plcDevice 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
int insert(PlcDevice plcDevice);
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param plcDevice 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
PlcDevice update(PlcDevice plcDevice) throws JsonProcessingException;
|
||||
|
||||
/**
|
||||
* 通过主键删除数据
|
||||
*
|
||||
* @param deviceId 主键
|
||||
* @return 是否成功
|
||||
*/
|
||||
int deleteById(Long deviceId);
|
||||
|
||||
String modbusDataProcess() throws JsonProcessingException;
|
||||
|
||||
String mcDataProcess() throws JsonProcessingException;
|
||||
|
||||
List<PlcDevice> selectHwDeviceJoinList(PlcDevice hwDevice);
|
||||
|
||||
List<PlcDeviceMode> selectHwDeviceModeList(PlcDeviceMode queryDeviceMode);
|
||||
|
||||
int changeDeviceStatus(PlcDevice device);
|
||||
|
||||
int updateDevice(PlcDevice hwDevice);
|
||||
|
||||
String aeDataProcess() throws JsonProcessingException;
|
||||
|
||||
String ehternetDataProcess() throws JsonProcessingException;
|
||||
}
|
@ -0,0 +1,189 @@
|
||||
package com.ruoyi.business.service.impl;
|
||||
|
||||
import com.ruoyi.business.domain.HwDeviceMode;
|
||||
import com.ruoyi.business.domain.HwDeviceModeFunction;
|
||||
import com.ruoyi.business.domain.PlcDeviceMode;
|
||||
import com.ruoyi.business.domain.PlcDeviceModeFunction;
|
||||
import com.ruoyi.business.mapper.PlcDeviceModeDao;
|
||||
import com.ruoyi.business.mapper.PlcDeviceModeFunctionDao;
|
||||
import com.ruoyi.business.service.PlcDeviceModeService;
|
||||
import com.ruoyi.common.core.constant.Constants;
|
||||
import com.ruoyi.common.core.constant.HwDictConstants;
|
||||
import com.ruoyi.common.core.constant.SecurityConstants;
|
||||
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.security.utils.SecurityUtils;
|
||||
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.stereotype.Service;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageImpl;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* plc设备模型(PlcDeviceMode)表服务实现类
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2024-12-19 16:23:27
|
||||
*/
|
||||
@Service("plcDeviceModeService")
|
||||
public class PlcDeviceModeServiceImpl implements PlcDeviceModeService {
|
||||
@Autowired
|
||||
private PlcDeviceModeDao plcDeviceModeDao;
|
||||
@Autowired
|
||||
private PlcDeviceModeFunctionDao plcDeviceModeFunctionDao;
|
||||
@Autowired
|
||||
private RemoteTdEngineService remoteTdEngineService;
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
*
|
||||
* @param deviceModeId 主键
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public PlcDeviceMode queryById(Long deviceModeId) {
|
||||
return this.plcDeviceModeDao.queryById(deviceModeId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param plcDeviceMode 筛选条件
|
||||
* @param pageRequest 分页对象
|
||||
* @return 查询结果
|
||||
*/
|
||||
@Override
|
||||
public Page<PlcDeviceMode> queryByPage(PlcDeviceMode plcDeviceMode, PageRequest pageRequest) {
|
||||
long total = this.plcDeviceModeDao.count(plcDeviceMode);
|
||||
return new PageImpl<>(this.plcDeviceModeDao.queryAllByLimit(plcDeviceMode, pageRequest), pageRequest, total);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param plcDeviceMode 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public int insert(PlcDeviceMode plcDeviceMode) {
|
||||
Long tenantId = SecurityUtils.getTenantId();
|
||||
plcDeviceMode.setTenantId(tenantId);
|
||||
plcDeviceMode.setDeviceModeStatus("1");
|
||||
int rows = plcDeviceModeDao.insert(plcDeviceMode);
|
||||
List<PlcDeviceModeFunction> functionList = plcDeviceMode.getFunctionList();
|
||||
for (PlcDeviceModeFunction function : functionList) {
|
||||
function.setDeviceModeId(plcDeviceMode.getDeviceModeId());
|
||||
}
|
||||
int i = plcDeviceModeFunctionDao.insertBatch(functionList);
|
||||
this.createTdSuperTable(plcDeviceMode);
|
||||
return rows;
|
||||
}
|
||||
private void createTdSuperTable(PlcDeviceMode plcDeviceMode) {
|
||||
TdSuperTableVo tdSuperTableVo = new TdSuperTableVo();
|
||||
String dbName = TdEngineConstants.getDatabaseName();
|
||||
String superTableName = TdEngineConstants.PLC_SUPER_TABLE_NAME_PREFIX + plcDeviceMode.getDeviceModeId();
|
||||
|
||||
List<TdField> tagFields = new ArrayList<TdField>();
|
||||
TdField tagField = new TdField();
|
||||
tagField.setFieldName(TdEngineConstants.PLC_TAG_IP);
|
||||
tagField.setDataTypeCode(TdEngineConstants.PLC_TAG_IP_TYPE);
|
||||
tagField.setSize(TdEngineConstants.PLC_TAG_IP_SIZE);
|
||||
tagFields.add(tagField);
|
||||
|
||||
tagField = new TdField();
|
||||
tagField.setFieldName(TdEngineConstants.PLC_TAG_PORT);
|
||||
tagField.setDataTypeCode(TdEngineConstants.PLC_TAG_PORT_TYPE);
|
||||
// tagField.setSize(TdEngineConstants.ST_TAG_DEVICENAME_SIZE);
|
||||
tagFields.add(tagField);
|
||||
|
||||
tagField = new TdField();
|
||||
tagField.setFieldName(TdEngineConstants.PLC_TAG_LOCATION);
|
||||
tagField.setDataTypeCode(TdEngineConstants.PLC_TAG_LOCATION_TYPE);
|
||||
tagField.setSize(TdEngineConstants.PLC_TAG_LOCATION_SIZE);
|
||||
tagFields.add(tagField);
|
||||
|
||||
|
||||
List<TdField> schemaFields = new ArrayList<TdField>();
|
||||
List<PlcDeviceModeFunction> hwDeviceModeFunctions = plcDeviceMode.getFunctionList();
|
||||
TdField schemaField;
|
||||
for (PlcDeviceModeFunction hwDeviceModeFunction : hwDeviceModeFunctions) {
|
||||
String functionMode = hwDeviceModeFunction.getFunctionMode();
|
||||
if (functionMode.equalsIgnoreCase(HwDictConstants.FUNCTION_MODE_ATTRIBUTE)) {
|
||||
schemaField = new TdField();
|
||||
// String functionIdentifierTransfer = TdEngineConstants.TDENGINE_KEY_TRANSFER_MAP.get(hwDeviceModeFunction.getFunctionIdentifier());
|
||||
// String functionIdentifier = functionIdentifierTransfer == null ? hwDeviceModeFunction.getFunctionIdentifier() : functionIdentifierTransfer;
|
||||
String functionIdentifier = hwDeviceModeFunction.getFunctionIdentifier();
|
||||
schemaField.setFieldName(functionIdentifier);
|
||||
Integer dataType = hwDeviceModeFunction.getDataType();
|
||||
schemaField.setDataTypeCode(dataType);
|
||||
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);
|
||||
|
||||
R<?> tdReturnMsg = this.remoteTdEngineService.createSuperTable(tdSuperTableVo, SecurityConstants.INNER);
|
||||
if (tdReturnMsg.getCode() != Constants.SUCCESS) {//抛出异常,回滚事务
|
||||
throw new RuntimeException(tdReturnMsg.getMsg());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param plcDeviceMode 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public int update(PlcDeviceMode plcDeviceMode) {
|
||||
|
||||
return this.plcDeviceModeDao.update(plcDeviceMode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteHwDeviceModeByDeviceModeIds(Long[] deviceModeIds) {
|
||||
plcDeviceModeFunctionDao.deleteHwDeviceModeFunctionByDeviceModeIds(deviceModeIds);
|
||||
return plcDeviceModeDao.deleteHwDeviceModeByDeviceModeIds(deviceModeIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PlcDeviceModeFunction> selectFunctionList(Long deviceModeId) {
|
||||
return plcDeviceModeFunctionDao.selectFunctionList(deviceModeId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlcDeviceMode selectHwDeviceModeByDeviceModeId(Long deviceModeId) {
|
||||
return plcDeviceModeDao.queryById(deviceModeId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PlcDeviceMode> selectList(PlcDeviceMode hwDeviceMode) {
|
||||
return plcDeviceModeDao.selectList(hwDeviceMode);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过主键删除数据
|
||||
*
|
||||
* @param deviceModeId 主键
|
||||
* @return 是否成功
|
||||
*/
|
||||
@Override
|
||||
public boolean deleteById(Long deviceModeId) {
|
||||
return this.plcDeviceModeDao.deleteById(deviceModeId) > 0;
|
||||
}
|
||||
}
|
@ -0,0 +1,571 @@
|
||||
package com.ruoyi.business.service.impl;
|
||||
|
||||
import HslCommunication.Core.Transfer.DataFormat;
|
||||
import HslCommunication.Core.Types.OperateResult;
|
||||
import HslCommunication.Core.Types.OperateResultExOne;
|
||||
import HslCommunication.ModBus.ModbusTcpNet;
|
||||
import HslCommunication.Profinet.AllenBradley.AllenBradleyNet;
|
||||
import HslCommunication.Profinet.Melsec.MelsecA1ENet;
|
||||
import HslCommunication.Profinet.Melsec.MelsecFxSerialOverTcp;
|
||||
import HslCommunication.Profinet.Melsec.MelsecHelper;
|
||||
import HslCommunication.Profinet.Melsec.MelsecMcNet;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.ruoyi.business.domain.*;
|
||||
import com.ruoyi.business.mapper.PlcDeviceDao;
|
||||
import com.ruoyi.business.mapper.PlcDeviceModeFunctionDao;
|
||||
import com.ruoyi.business.service.PlcDeviceService;
|
||||
import com.ruoyi.common.core.constant.Constants;
|
||||
import com.ruoyi.common.core.constant.HwDictConstants;
|
||||
import com.ruoyi.common.core.constant.SecurityConstants;
|
||||
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.security.utils.SecurityUtils;
|
||||
import com.ruoyi.system.api.domain.SysUser;
|
||||
import com.ruoyi.system.api.model.LoginUser;
|
||||
import com.ruoyi.tdengine.api.RemoteTdEngineService;
|
||||
import com.ruoyi.tdengine.api.domain.AlterTagVo;
|
||||
import com.ruoyi.tdengine.api.domain.TdField;
|
||||
import com.ruoyi.tdengine.api.domain.TdTableVo;
|
||||
import org.apache.plc4x.java.PlcDriverManager;
|
||||
import org.apache.plc4x.java.api.PlcConnection;
|
||||
import org.apache.plc4x.java.api.exceptions.PlcConnectionException;
|
||||
import org.apache.plc4x.java.api.messages.PlcReadRequest;
|
||||
import org.apache.plc4x.java.api.messages.PlcReadResponse;
|
||||
import org.apache.plc4x.java.api.metadata.PlcConnectionMetadata;
|
||||
import org.apache.plc4x.java.ethernetip.EtherNetIpPlcDriver;
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageImpl;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
/**
|
||||
* plc设备信息(PlcDevice)表服务实现类
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2024-12-19 16:22:51
|
||||
*/
|
||||
@Service("plcDeviceService")
|
||||
public class PlcDeviceServiceImpl implements PlcDeviceService {
|
||||
@Resource
|
||||
private PlcDeviceDao plcDeviceDao;
|
||||
@Autowired
|
||||
private RemoteTdEngineService remoteTdEngineService;
|
||||
@Autowired
|
||||
private PlcDeviceModeFunctionDao plcDeviceModeFunctionDao;
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
*
|
||||
* @param deviceId 主键
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public PlcDevice queryById(Long deviceId) throws JsonProcessingException {
|
||||
// List<PlcDevice> plcDevices = this.plcDeviceDao.queryPlcDevices(1);
|
||||
// for (PlcDevice plcDevice : plcDevices) {
|
||||
// int station = plcDevice.getStation();
|
||||
// byte a = (byte)station;
|
||||
// int length = plcDevice.getLength();
|
||||
// short b = (short)length;
|
||||
// ModbusTcpNet tcpNet = new ModbusTcpNet(plcDevice.getIp(),plcDevice.getPort1(), a);
|
||||
// tcpNet.getByteTransform().setDataFormat(DataFormat.CDAB);
|
||||
// TdTableVo tdTableVo = new TdTableVo();
|
||||
// List<TdField> schemaFields = new ArrayList<>();
|
||||
// TdField firstTdField = new TdField();
|
||||
// firstTdField.setFieldName(TdEngineConstants.DEFAULT_FIRST_FIELD_NAME);
|
||||
// long currentTimeMillis = System.currentTimeMillis();
|
||||
// firstTdField.setFieldValue(currentTimeMillis);
|
||||
// String databaseName = TdEngineConstants.getDatabaseName();
|
||||
// String tableName = TdEngineConstants.PLC_TABLE_NAME_PREFIX + plcDevice.getDeviceId();
|
||||
// // firstTdField.setFieldValue(ts);
|
||||
// schemaFields.add(firstTdField);
|
||||
// List<PlcDeviceModeFunction> list = plcDeviceModeFunctionDao.selectFunctions(plcDevice.getDeviceModeId());
|
||||
// if (plcDevice.getDataType().equals("10")){
|
||||
// OperateResultExOne<String> resultExOne = tcpNet.ReadString(plcDevice.getDLocation(),b, StandardCharsets.UTF_8);
|
||||
// String content = resultExOne.Content;
|
||||
// ObjectMapper objectMapper = new ObjectMapper();
|
||||
// Map map = objectMapper.readValue(content, Map.class);
|
||||
// for (PlcDeviceModeFunction function : list) {
|
||||
// Object value = map.get(function.getFunctionIdentifier());
|
||||
// TdField tdField = new TdField();
|
||||
// tdField.setFieldName(function.getFunctionIdentifier());
|
||||
// tdField.setFieldValue(value);
|
||||
// schemaFields.add(tdField);
|
||||
// }
|
||||
// }else if (plcDevice.getDataType().equals("2")){
|
||||
// OperateResultExOne<Integer> exOne = tcpNet.ReadInt32(plcDevice.getDLocation());
|
||||
// TdField tdField = new TdField();
|
||||
// tdField.setFieldName(list.get(0).getFunctionIdentifier());
|
||||
// tdField.setFieldValue(exOne.Content);
|
||||
// schemaFields.add(tdField);
|
||||
// }else if (plcDevice.getDataType().equals("4")){
|
||||
// OperateResultExOne<Float> floatOperateResultExOne = tcpNet.ReadFloat(plcDevice.getDLocation());
|
||||
// TdField tdField = new TdField();
|
||||
// tdField.setFieldName(list.get(0).getFunctionIdentifier());
|
||||
// tdField.setFieldValue(floatOperateResultExOne.Content);
|
||||
// schemaFields.add(tdField);
|
||||
// }
|
||||
// tdTableVo.setDatabaseName(databaseName);
|
||||
// tdTableVo.setTableName(tableName);
|
||||
// tdTableVo.setSchemaFields(schemaFields);
|
||||
// final R<?> insertResult = this.remoteTdEngineService.insertTable(tdTableVo , SecurityConstants.INNER);
|
||||
// }
|
||||
|
||||
// OperateResultExOne<Float> exOne = tcpNet.ReadFloat("100");
|
||||
// System.out.println(exOne.Content);
|
||||
return this.plcDeviceDao.selectHwDeviceByDeviceId(deviceId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateDevice(PlcDevice hwDevice) {
|
||||
PlcDevice dbDevice = plcDeviceDao.selectHwDeviceByDeviceId(hwDevice.getDeviceId());
|
||||
if (dbDevice.getDeviceStatus().equals(HwDictConstants.DEVICE_STATUS_PUBLISH)) {
|
||||
throw new ServiceException("已发布状态不能修改");
|
||||
}
|
||||
hwDevice.setUpdateTime(DateUtils.getNowDate());
|
||||
int rows = plcDeviceDao.update(hwDevice);
|
||||
this.updateTdEngine(hwDevice, dbDevice);
|
||||
return rows;
|
||||
}
|
||||
public void updateTdEngine(PlcDevice hwDevice, PlcDevice dbDevice) {
|
||||
|
||||
String databaseName = TdEngineConstants.getDatabaseName();
|
||||
String tableName = TdEngineConstants.PLC_TABLE_NAME_PREFIX + hwDevice.getDeviceId();
|
||||
AlterTagVo alterTagVo = new AlterTagVo();
|
||||
alterTagVo.setDatabaseName(databaseName);
|
||||
alterTagVo.setTableName(tableName);
|
||||
R<?> tdReturnMsg;
|
||||
if (!hwDevice.getIp().equals(dbDevice.getIp())) {
|
||||
alterTagVo.setTagName(TdEngineConstants.PLC_TAG_IP);
|
||||
alterTagVo.setTagValue("'" + hwDevice.getIp() + "'");
|
||||
|
||||
tdReturnMsg = this.remoteTdEngineService.alterTableTag(alterTagVo, SecurityConstants.INNER);
|
||||
if (tdReturnMsg.getCode() != Constants.SUCCESS) {//抛出异常,回滚事务
|
||||
throw new RuntimeException(tdReturnMsg.getMsg());
|
||||
}
|
||||
}
|
||||
if (!hwDevice.getPort1().equals(dbDevice.getPort1())) {
|
||||
alterTagVo.setTagName(TdEngineConstants.PLC_TAG_PORT);
|
||||
alterTagVo.setTagValue(hwDevice.getPort1());
|
||||
tdReturnMsg = this.remoteTdEngineService.alterTableTag(alterTagVo, SecurityConstants.INNER);
|
||||
if (tdReturnMsg.getCode() != Constants.SUCCESS) {//抛出异常,回滚事务
|
||||
throw new RuntimeException(tdReturnMsg.getMsg());
|
||||
}
|
||||
}
|
||||
|
||||
if (!hwDevice.getLocation().equals(dbDevice.getLocation())) {
|
||||
alterTagVo.setTagName(TdEngineConstants.PLC_TAG_LOCATION);
|
||||
alterTagVo.setTagValue("'" + hwDevice.getLocation() + "'");
|
||||
tdReturnMsg = this.remoteTdEngineService.alterTableTag(alterTagVo, SecurityConstants.INNER);
|
||||
if (tdReturnMsg.getCode() != Constants.SUCCESS) {//抛出异常,回滚事务
|
||||
throw new RuntimeException(tdReturnMsg.getMsg());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int changeDeviceStatus(PlcDevice device) {
|
||||
PlcDevice dbDevice = plcDeviceDao.selectHwDeviceByDeviceId(device.getDeviceId());
|
||||
if (dbDevice.getDeviceStatus().equals(HwDictConstants.DEVICE_STATUS_PUBLISH) && !device.getDeviceStatus().equals("0")) {
|
||||
throw new ServiceException("已发布状态不能修改");
|
||||
}
|
||||
device.setUpdateBy(SecurityUtils.getUsername());
|
||||
Date currentDate = new Date();
|
||||
device.setUpdateTime(currentDate);
|
||||
device.setPublishTime(currentDate);
|
||||
return plcDeviceDao.update(device);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PlcDeviceMode> selectHwDeviceModeList(PlcDeviceMode queryDeviceMode) {
|
||||
return plcDeviceDao.selectPlcDeviceMode(queryDeviceMode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PlcDevice> selectHwDeviceJoinList(PlcDevice hwDevice) {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
SysUser sysUser = loginUser.getSysUser();
|
||||
Long tenantId = sysUser.getTenantId();
|
||||
hwDevice.setTenantId(tenantId);
|
||||
return plcDeviceDao.selectHwDeviceJoinList(hwDevice);
|
||||
}
|
||||
|
||||
// mc协议获取处理plc数据
|
||||
@Override
|
||||
public String mcDataProcess() throws JsonProcessingException {
|
||||
List<PlcDevice> plcDevices = this.plcDeviceDao.queryPlcDevices(1);
|
||||
for (PlcDevice plcDevice : plcDevices) {
|
||||
int station = plcDevice.getStation();
|
||||
byte a = (byte)station;
|
||||
int length = plcDevice.getLength();
|
||||
short b = (short)length;
|
||||
MelsecMcNet melsecMcNet = new MelsecMcNet(plcDevice.getIp(),plcDevice.getPort1());
|
||||
// ModbusTcpNet tcpNet = new ModbusTcpNet(plcDevice.getIp(),plcDevice.getPort1(), a);
|
||||
// tcpNet.getByteTransform().setDataFormat(DataFormat.CDAB);
|
||||
TdTableVo tdTableVo = new TdTableVo();
|
||||
List<TdField> schemaFields = new ArrayList<>();
|
||||
TdField firstTdField = new TdField();
|
||||
firstTdField.setFieldName(TdEngineConstants.DEFAULT_FIRST_FIELD_NAME);
|
||||
long currentTimeMillis = System.currentTimeMillis();
|
||||
firstTdField.setFieldValue(currentTimeMillis);
|
||||
String databaseName = TdEngineConstants.getDatabaseName();
|
||||
String tableName = TdEngineConstants.PLC_TABLE_NAME_PREFIX + plcDevice.getDeviceId();
|
||||
// firstTdField.setFieldValue(ts);
|
||||
schemaFields.add(firstTdField);
|
||||
List<PlcDeviceModeFunction> list = plcDeviceModeFunctionDao.selectFunctions(plcDevice.getDeviceModeId());
|
||||
if (plcDevice.getDataType().equals("10")){
|
||||
OperateResultExOne<String> resultExOne = melsecMcNet.ReadString(plcDevice.getLocation(),b, StandardCharsets.UTF_8);
|
||||
String content = resultExOne.Content;
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
Map map = objectMapper.readValue(content, Map.class);
|
||||
for (PlcDeviceModeFunction function : list) {
|
||||
Object value = map.get(function.getFunctionIdentifier());
|
||||
TdField tdField = new TdField();
|
||||
tdField.setFieldName(function.getFunctionIdentifier());
|
||||
tdField.setFieldValue(value);
|
||||
schemaFields.add(tdField);
|
||||
}
|
||||
}else if (plcDevice.getDataType().equals("2")||plcDevice.getDataType().equals("9")){
|
||||
OperateResultExOne<Integer> exOne = melsecMcNet.ReadInt32(plcDevice.getLocation());
|
||||
TdField tdField = new TdField();
|
||||
tdField.setFieldName(list.get(0).getFunctionIdentifier());
|
||||
tdField.setFieldValue(exOne.Content);
|
||||
schemaFields.add(tdField);
|
||||
}else if (plcDevice.getDataType().equals("4")){
|
||||
OperateResultExOne<Float> floatOperateResultExOne = melsecMcNet.ReadFloat(plcDevice.getLocation());
|
||||
TdField tdField = new TdField();
|
||||
tdField.setFieldName(list.get(0).getFunctionIdentifier());
|
||||
tdField.setFieldValue(floatOperateResultExOne.Content);
|
||||
schemaFields.add(tdField);
|
||||
}else if (plcDevice.getDataType().equals("5")){
|
||||
OperateResultExOne<Double> doubleOperateResultExOne = melsecMcNet.ReadDouble(plcDevice.getLocation());
|
||||
TdField tdField = new TdField();
|
||||
tdField.setFieldName(list.get(0).getFunctionIdentifier());
|
||||
tdField.setFieldValue(doubleOperateResultExOne.Content);
|
||||
schemaFields.add(tdField);
|
||||
}
|
||||
tdTableVo.setDatabaseName(databaseName);
|
||||
tdTableVo.setTableName(tableName);
|
||||
tdTableVo.setSchemaFields(schemaFields);
|
||||
final R<?> insertResult = this.remoteTdEngineService.insertTable(tdTableVo , SecurityConstants.INNER);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
// modbus协议获取处理plc数据
|
||||
@Override
|
||||
public String modbusDataProcess() throws JsonProcessingException {
|
||||
List<PlcDevice> plcDevices = this.plcDeviceDao.queryPlcDevices(2);
|
||||
for (PlcDevice plcDevice : plcDevices) {
|
||||
int station = plcDevice.getStation();
|
||||
byte a = (byte)station;
|
||||
int length = plcDevice.getLength();
|
||||
short b = (short)length;
|
||||
ModbusTcpNet tcpNet = new ModbusTcpNet(plcDevice.getIp(),plcDevice.getPort1(), a);
|
||||
tcpNet.getByteTransform().setDataFormat(DataFormat.CDAB);
|
||||
TdTableVo tdTableVo = new TdTableVo();
|
||||
List<TdField> schemaFields = new ArrayList<>();
|
||||
TdField firstTdField = new TdField();
|
||||
firstTdField.setFieldName(TdEngineConstants.DEFAULT_FIRST_FIELD_NAME);
|
||||
long currentTimeMillis = System.currentTimeMillis();
|
||||
firstTdField.setFieldValue(currentTimeMillis);
|
||||
String databaseName = TdEngineConstants.getDatabaseName();
|
||||
String tableName = TdEngineConstants.PLC_TABLE_NAME_PREFIX + plcDevice.getDeviceId();
|
||||
// firstTdField.setFieldValue(ts);
|
||||
schemaFields.add(firstTdField);
|
||||
List<PlcDeviceModeFunction> list = plcDeviceModeFunctionDao.selectFunctions(plcDevice.getDeviceModeId());
|
||||
if (plcDevice.getDataType().equals("10")){
|
||||
OperateResultExOne<String> resultExOne = tcpNet.ReadString(plcDevice.getLocation(),b, StandardCharsets.UTF_8);
|
||||
String content = resultExOne.Content;
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
Map map = objectMapper.readValue(content, Map.class);
|
||||
for (PlcDeviceModeFunction function : list) {
|
||||
Object value = map.get(function.getFunctionIdentifier());
|
||||
TdField tdField = new TdField();
|
||||
tdField.setFieldName(function.getFunctionIdentifier());
|
||||
tdField.setFieldValue(value);
|
||||
schemaFields.add(tdField);
|
||||
}
|
||||
}else if (plcDevice.getDataType().equals("2")||plcDevice.getDataType().equals("9")){
|
||||
OperateResultExOne<Integer> exOne = tcpNet.ReadInt32(plcDevice.getLocation());
|
||||
TdField tdField = new TdField();
|
||||
tdField.setFieldName(list.get(0).getFunctionIdentifier());
|
||||
tdField.setFieldValue(exOne.Content);
|
||||
schemaFields.add(tdField);
|
||||
}else if (plcDevice.getDataType().equals("4")){
|
||||
OperateResultExOne<Float> floatOperateResultExOne = tcpNet.ReadFloat(plcDevice.getLocation());
|
||||
TdField tdField = new TdField();
|
||||
tdField.setFieldName(list.get(0).getFunctionIdentifier());
|
||||
tdField.setFieldValue(floatOperateResultExOne.Content);
|
||||
schemaFields.add(tdField);
|
||||
}else if (plcDevice.getDataType().equals("5")){
|
||||
OperateResultExOne<Double> doubleOperateResultExOne = tcpNet.ReadDouble(plcDevice.getLocation());
|
||||
TdField tdField = new TdField();
|
||||
tdField.setFieldName(list.get(0).getFunctionIdentifier());
|
||||
tdField.setFieldValue(doubleOperateResultExOne.Content);
|
||||
schemaFields.add(tdField);
|
||||
}
|
||||
tdTableVo.setDatabaseName(databaseName);
|
||||
tdTableVo.setTableName(tableName);
|
||||
tdTableVo.setSchemaFields(schemaFields);
|
||||
final R<?> insertResult = this.remoteTdEngineService.insertTable(tdTableVo , SecurityConstants.INNER);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
//EtherNet协议数据读取
|
||||
@Override
|
||||
public String ehternetDataProcess() throws JsonProcessingException {
|
||||
// AllenBradleyNet plc = new AllenBradleyNet("127.0.0.1",44818);
|
||||
// OperateResult operateResult = plc.ConnectServer();
|
||||
// OperateResultExOne<String> f = plc.ReadString("F");
|
||||
// String content = f.Content;
|
||||
// return null;
|
||||
List<PlcDevice> plcDevices = this.plcDeviceDao.queryPlcDevices(4);
|
||||
for (PlcDevice plcDevice : plcDevices) {
|
||||
int station = plcDevice.getStation();
|
||||
byte a = (byte)station;
|
||||
int length = plcDevice.getLength();
|
||||
short b = (short)length;
|
||||
// ModbusTcpNet tcpNet = new ModbusTcpNet(plcDevice.getIp(),plcDevice.getPort1(), a);
|
||||
// tcpNet.getByteTransform().setDataFormat(DataFormat.CDAB);
|
||||
AllenBradleyNet ethernet = new AllenBradleyNet(plcDevice.getIp(),plcDevice.getPort1());
|
||||
TdTableVo tdTableVo = new TdTableVo();
|
||||
List<TdField> schemaFields = new ArrayList<>();
|
||||
TdField firstTdField = new TdField();
|
||||
firstTdField.setFieldName(TdEngineConstants.DEFAULT_FIRST_FIELD_NAME);
|
||||
long currentTimeMillis = System.currentTimeMillis();
|
||||
firstTdField.setFieldValue(currentTimeMillis);
|
||||
String databaseName = TdEngineConstants.getDatabaseName();
|
||||
String tableName = TdEngineConstants.PLC_TABLE_NAME_PREFIX + plcDevice.getDeviceId();
|
||||
// firstTdField.setFieldValue(ts);
|
||||
schemaFields.add(firstTdField);
|
||||
List<PlcDeviceModeFunction> list = plcDeviceModeFunctionDao.selectFunctions(plcDevice.getDeviceModeId());
|
||||
if (plcDevice.getDataType().equals("10")){
|
||||
OperateResultExOne<String> resultExOne = ethernet.ReadString(plcDevice.getLocation(),b, StandardCharsets.UTF_8);
|
||||
String content = resultExOne.Content;
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
Map map = objectMapper.readValue(content, Map.class);
|
||||
for (PlcDeviceModeFunction function : list) {
|
||||
Object value = map.get(function.getFunctionIdentifier());
|
||||
TdField tdField = new TdField();
|
||||
tdField.setFieldName(function.getFunctionIdentifier());
|
||||
tdField.setFieldValue(value);
|
||||
schemaFields.add(tdField);
|
||||
}
|
||||
}else if (plcDevice.getDataType().equals("2")||plcDevice.getDataType().equals("9")){
|
||||
OperateResultExOne<Integer> exOne = ethernet.ReadInt32(plcDevice.getLocation());
|
||||
TdField tdField = new TdField();
|
||||
tdField.setFieldName(list.get(0).getFunctionIdentifier());
|
||||
tdField.setFieldValue(exOne.Content);
|
||||
schemaFields.add(tdField);
|
||||
}else if (plcDevice.getDataType().equals("4")){
|
||||
OperateResultExOne<Float> floatOperateResultExOne = ethernet.ReadFloat(plcDevice.getLocation());
|
||||
TdField tdField = new TdField();
|
||||
tdField.setFieldName(list.get(0).getFunctionIdentifier());
|
||||
tdField.setFieldValue(floatOperateResultExOne.Content);
|
||||
schemaFields.add(tdField);
|
||||
}else if (plcDevice.getDataType().equals("5")){
|
||||
OperateResultExOne<Double> doubleOperateResultExOne = ethernet.ReadDouble(plcDevice.getLocation());
|
||||
TdField tdField = new TdField();
|
||||
tdField.setFieldName(list.get(0).getFunctionIdentifier());
|
||||
tdField.setFieldValue(doubleOperateResultExOne.Content);
|
||||
schemaFields.add(tdField);
|
||||
}
|
||||
tdTableVo.setDatabaseName(databaseName);
|
||||
tdTableVo.setTableName(tableName);
|
||||
tdTableVo.setSchemaFields(schemaFields);
|
||||
final R<?> insertResult = this.remoteTdEngineService.insertTable(tdTableVo , SecurityConstants.INNER);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// A1E协议
|
||||
public String aeDataProcess() throws JsonProcessingException {
|
||||
List<PlcDevice> plcDevices = this.plcDeviceDao.queryPlcDevices(3);
|
||||
for (PlcDevice plcDevice : plcDevices) {
|
||||
int station = plcDevice.getStation();
|
||||
byte a = (byte)station;
|
||||
int length = plcDevice.getLength();
|
||||
short b = (short)length;
|
||||
// ModbusTcpNet tcpNet = new ModbusTcpNet(plcDevice.getIp(),plcDevice.getPort1(), a);
|
||||
// tcpNet.getByteTransform().setDataFormat(DataFormat.CDAB);
|
||||
MelsecA1ENet net = new MelsecA1ENet(plcDevice.getIp(),plcDevice.getPort1());
|
||||
TdTableVo tdTableVo = new TdTableVo();
|
||||
List<TdField> schemaFields = new ArrayList<>();
|
||||
TdField firstTdField = new TdField();
|
||||
firstTdField.setFieldName(TdEngineConstants.DEFAULT_FIRST_FIELD_NAME);
|
||||
long currentTimeMillis = System.currentTimeMillis();
|
||||
firstTdField.setFieldValue(currentTimeMillis);
|
||||
String databaseName = TdEngineConstants.getDatabaseName();
|
||||
String tableName = TdEngineConstants.PLC_TABLE_NAME_PREFIX + plcDevice.getDeviceId();
|
||||
// firstTdField.setFieldValue(ts);
|
||||
schemaFields.add(firstTdField);
|
||||
List<PlcDeviceModeFunction> list = plcDeviceModeFunctionDao.selectFunctions(plcDevice.getDeviceModeId());
|
||||
if (plcDevice.getDataType().equals("10")){
|
||||
OperateResultExOne<String> resultExOne = net.ReadString(plcDevice.getLocation(),b, StandardCharsets.UTF_8);
|
||||
String content = resultExOne.Content;
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
Map map = objectMapper.readValue(content, Map.class);
|
||||
for (PlcDeviceModeFunction function : list) {
|
||||
Object value = map.get(function.getFunctionIdentifier());
|
||||
TdField tdField = new TdField();
|
||||
tdField.setFieldName(function.getFunctionIdentifier());
|
||||
tdField.setFieldValue(value);
|
||||
schemaFields.add(tdField);
|
||||
}
|
||||
}else if (plcDevice.getDataType().equals("2")||plcDevice.getDataType().equals("9")){
|
||||
OperateResultExOne<Integer> exOne = net.ReadInt32(plcDevice.getLocation());
|
||||
TdField tdField = new TdField();
|
||||
tdField.setFieldName(list.get(0).getFunctionIdentifier());
|
||||
tdField.setFieldValue(exOne.Content);
|
||||
schemaFields.add(tdField);
|
||||
}else if (plcDevice.getDataType().equals("4")){
|
||||
OperateResultExOne<Float> floatOperateResultExOne = net.ReadFloat(plcDevice.getLocation());
|
||||
TdField tdField = new TdField();
|
||||
tdField.setFieldName(list.get(0).getFunctionIdentifier());
|
||||
tdField.setFieldValue(floatOperateResultExOne.Content);
|
||||
schemaFields.add(tdField);
|
||||
}else if (plcDevice.getDataType().equals("5")){
|
||||
OperateResultExOne<Double> doubleOperateResultExOne = net.ReadDouble(plcDevice.getLocation());
|
||||
TdField tdField = new TdField();
|
||||
tdField.setFieldName(list.get(0).getFunctionIdentifier());
|
||||
tdField.setFieldValue(doubleOperateResultExOne.Content);
|
||||
schemaFields.add(tdField);
|
||||
}
|
||||
tdTableVo.setDatabaseName(databaseName);
|
||||
tdTableVo.setTableName(tableName);
|
||||
tdTableVo.setSchemaFields(schemaFields);
|
||||
final R<?> insertResult = this.remoteTdEngineService.insertTable(tdTableVo , SecurityConstants.INNER);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param plcDevice 筛选条件
|
||||
* @param pageRequest 分页对象
|
||||
* @return 查询结果
|
||||
*/
|
||||
@Override
|
||||
public Page<PlcDevice> queryByPage(PlcDevice plcDevice, PageRequest pageRequest) {
|
||||
long total = this.plcDeviceDao.count(plcDevice);
|
||||
return new PageImpl<>(this.plcDeviceDao.queryAllByLimit(plcDevice, pageRequest), pageRequest, total);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param plcDevice 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public int insert(PlcDevice plcDevice) {
|
||||
String username = SecurityUtils.getUsername();
|
||||
plcDevice.setCreateBy(username);
|
||||
plcDevice.setCreateTime(new Date());
|
||||
Long tenantId = SecurityUtils.getTenantId();
|
||||
plcDevice.setTenantId(tenantId);
|
||||
plcDevice.setDeviceStatus("0");
|
||||
int deviceId = this.plcDeviceDao.insert(plcDevice);
|
||||
this.createTdTable(plcDevice);
|
||||
return deviceId;
|
||||
}
|
||||
|
||||
// public void createTdDeviceStatusTable(HwDevice hwDevice) {
|
||||
// TdTableVo tdTableVo = new TdTableVo();
|
||||
// tdTableVo.setDatabaseName(TdEngineConstants.PLATFORM_DB_NAME);
|
||||
// tdTableVo.setSuperTableName(TdEngineConstants.DEFAULT_DEVICE_STATUS_SUPER_TABLE_NAME);
|
||||
// tdTableVo.setTableName(TdEngineConstants.getDeviceStatusTableName(hwDevice.getDeviceId()));
|
||||
//
|
||||
// List<TdField> tagsFields = getTdTagsFields(hwDevice);
|
||||
//
|
||||
// TdField sceneIdTag = new TdField();
|
||||
// sceneIdTag.setFieldName(TdEngineConstants.ST_TAG_SCENEID);
|
||||
// sceneIdTag.setFieldValue(hwDevice.getSceneId());
|
||||
// tagsFields.add(sceneIdTag);
|
||||
//
|
||||
// tdTableVo.setTagsFieldValues(tagsFields);
|
||||
//
|
||||
// R<?> tdReturnMsg = this.remoteTdEngineService.createTable(tdTableVo, SecurityConstants.INNER);
|
||||
// if (tdReturnMsg.getCode() != Constants.SUCCESS) {//抛出异常,回滚事务
|
||||
// throw new RuntimeException(tdReturnMsg.getMsg());
|
||||
// }
|
||||
// }
|
||||
public void createTdTable(PlcDevice hwDevice) {
|
||||
TdTableVo tdTableVo = new TdTableVo();
|
||||
String databaseName = TdEngineConstants.getDatabaseName();
|
||||
String superTableName = TdEngineConstants.PLC_SUPER_TABLE_NAME_PREFIX+hwDevice.getDeviceModeId();
|
||||
String tableName = TdEngineConstants.PLC_TABLE_NAME_PREFIX+hwDevice.getDeviceId();
|
||||
|
||||
List<TdField> tagsFields = getTdTagsFields(hwDevice);
|
||||
|
||||
tdTableVo.setDatabaseName(databaseName);
|
||||
tdTableVo.setSuperTableName(superTableName);
|
||||
tdTableVo.setTableName(tableName);
|
||||
tdTableVo.setTagsFieldValues(tagsFields);
|
||||
|
||||
R<?> tdReturnMsg = this.remoteTdEngineService.createTable(tdTableVo, SecurityConstants.INNER);
|
||||
if (tdReturnMsg.getCode() != Constants.SUCCESS) {//抛出异常,回滚事务
|
||||
throw new RuntimeException(tdReturnMsg.getMsg());
|
||||
}
|
||||
}
|
||||
|
||||
private List<TdField> getTdTagsFields(PlcDevice hwDevice) {
|
||||
List<TdField> tagFields = new ArrayList<TdField>();
|
||||
TdField ipTag = new TdField();
|
||||
ipTag.setFieldName(TdEngineConstants.PLC_TAG_IP);
|
||||
ipTag.setFieldValue(hwDevice.getIp());
|
||||
ipTag.setDataTypeCode(DataTypeEnums.NCHAR.getDataCode());
|
||||
tagFields.add(ipTag);
|
||||
|
||||
TdField portTag = new TdField();
|
||||
portTag.setFieldName(TdEngineConstants.PLC_TAG_PORT);
|
||||
portTag.setFieldValue(hwDevice.getPort1());
|
||||
tagFields.add(portTag);
|
||||
|
||||
TdField locationTag = new TdField();
|
||||
locationTag.setFieldName(TdEngineConstants.PLC_TAG_LOCATION);
|
||||
locationTag.setDataTypeCode(DataTypeEnums.NCHAR.getDataCode());
|
||||
locationTag.setFieldValue(hwDevice.getLocation());
|
||||
tagFields.add(locationTag);
|
||||
return tagFields;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param plcDevice 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public PlcDevice update(PlcDevice plcDevice) throws JsonProcessingException {
|
||||
this.plcDeviceDao.update(plcDevice);
|
||||
return this.queryById(plcDevice.getDeviceId());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 通过主键删除数据
|
||||
*
|
||||
* @param deviceId 主键
|
||||
* @return 是否成功
|
||||
*/
|
||||
@Override
|
||||
public int deleteById(Long deviceId) {
|
||||
return this.plcDeviceDao.deleteById(deviceId);
|
||||
}
|
||||
}
|
@ -0,0 +1,280 @@
|
||||
<?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.PlcDeviceDao">
|
||||
|
||||
<resultMap type="com.ruoyi.business.domain.PlcDevice" id="PlcDeviceMap">
|
||||
<result property="deviceId" column="device_id" jdbcType="INTEGER"/>
|
||||
<result property="deviceCode" column="device_code" jdbcType="VARCHAR"/>
|
||||
<result property="deviceName" column="device_name" jdbcType="VARCHAR"/>
|
||||
<result property="tenantId" column="tenant_id" jdbcType="INTEGER"/>
|
||||
<result property="sceneId" column="scene_id" jdbcType="INTEGER"/>
|
||||
<result property="ip" column="ip" jdbcType="VARCHAR"/>
|
||||
<result property="port1" column="port1" jdbcType="INTEGER"/>
|
||||
<result property="location" column="location" jdbcType="VARCHAR"/>
|
||||
<result property="accessProtocol" column="access_protocol" jdbcType="INTEGER"/>
|
||||
<result property="length" column="length" jdbcType="INTEGER"/>
|
||||
<result property="deviceStatus" column="device_status" jdbcType="VARCHAR"/>
|
||||
<result property="createBy" column="create_by" jdbcType="VARCHAR"/>
|
||||
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
|
||||
<result property="updateBy" column="update_by" jdbcType="VARCHAR"/>
|
||||
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
|
||||
</resultMap>
|
||||
|
||||
<!--查询单个-->
|
||||
<select id="queryById" resultMap="PlcDeviceMap">
|
||||
select
|
||||
device_id, device_code, device_name, tenant_id, scene_id, ip, port1, location, access_protocol, length, device_status, create_by, create_time, update_by, update_time,data_type,station,device_mode_id,station
|
||||
from plc_device
|
||||
-- where device_id = #{deviceId}
|
||||
</select>
|
||||
|
||||
<!--查询指定行数据-->
|
||||
<select id="queryAllByLimit" resultMap="PlcDeviceMap">
|
||||
select
|
||||
device_id, device_code, device_name, tenant_id, scene_id, ip, port1, location, access_protocol, length, device_status, create_by, create_time, update_by, update_time
|
||||
from plc_device
|
||||
<where>
|
||||
<if test="deviceId != null">
|
||||
and device_id = #{deviceId}
|
||||
</if>
|
||||
<if test="deviceCode != null and deviceCode != ''">
|
||||
and device_code = #{deviceCode}
|
||||
</if>
|
||||
<if test="deviceName != null and deviceName != ''">
|
||||
and device_name = #{deviceName}
|
||||
</if>
|
||||
<if test="tenantId != null">
|
||||
and tenant_id = #{tenantId}
|
||||
</if>
|
||||
<if test="sceneId != null">
|
||||
and scene_id = #{sceneId}
|
||||
</if>
|
||||
<if test="ip != null and ip != ''">
|
||||
and ip = #{ip}
|
||||
</if>
|
||||
<if test="port1 != null">
|
||||
and port1 = #{port1}
|
||||
</if>
|
||||
<if test="location != null and location != ''">
|
||||
and location = #{location}
|
||||
</if>
|
||||
<if test="accessProtocol != null">
|
||||
and access_protocol = #{accessProtocol}
|
||||
</if>
|
||||
<if test="length != null">
|
||||
and length = #{length}
|
||||
</if>
|
||||
<if test="deviceStatus != null and deviceStatus != ''">
|
||||
and device_status = #{deviceStatus}
|
||||
</if>
|
||||
<if test="createBy != null and createBy != ''">
|
||||
and create_by = #{createBy}
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
and create_time = #{createTime}
|
||||
</if>
|
||||
<if test="updateBy != null and updateBy != ''">
|
||||
and update_by = #{updateBy}
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
and update_time = #{updateTime}
|
||||
</if>
|
||||
</where>
|
||||
limit #{pageable.offset}, #{pageable.pageSize}
|
||||
</select>
|
||||
|
||||
<!--统计总行数-->
|
||||
<select id="count" resultType="java.lang.Long">
|
||||
select count(1)
|
||||
from plc_device
|
||||
<where>
|
||||
<if test="deviceId != null">
|
||||
and device_id = #{deviceId}
|
||||
</if>
|
||||
<if test="deviceCode != null and deviceCode != ''">
|
||||
and device_code = #{deviceCode}
|
||||
</if>
|
||||
<if test="deviceName != null and deviceName != ''">
|
||||
and device_name = #{deviceName}
|
||||
</if>
|
||||
<if test="tenantId != null">
|
||||
and tenant_id = #{tenantId}
|
||||
</if>
|
||||
<if test="sceneId != null">
|
||||
and scene_id = #{sceneId}
|
||||
</if>
|
||||
<if test="ip != null and ip != ''">
|
||||
and ip = #{ip}
|
||||
</if>
|
||||
<if test="port1 != null">
|
||||
and port1 = #{port1}
|
||||
</if>
|
||||
<if test="location != null and location != ''">
|
||||
and location = #{location}
|
||||
</if>
|
||||
<if test="accessProtocol != null">
|
||||
and access_protocol = #{accessProtocol}
|
||||
</if>
|
||||
<if test="length != null">
|
||||
and length = #{length}
|
||||
</if>
|
||||
<if test="deviceStatus != null and deviceStatus != ''">
|
||||
and device_status = #{deviceStatus}
|
||||
</if>
|
||||
<if test="createBy != null and createBy != ''">
|
||||
and create_by = #{createBy}
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
and create_time = #{createTime}
|
||||
</if>
|
||||
<if test="updateBy != null and updateBy != ''">
|
||||
and update_by = #{updateBy}
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
and update_time = #{updateTime}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
<select id="queryPlcDevices" resultType="com.ruoyi.business.domain.PlcDevice">
|
||||
select
|
||||
device_id, device_code, device_name, tenant_id, scene_id, ip, port1, location, access_protocol, length, device_status, create_by, create_time, update_by, update_time,data_type,station,device_mode_id,station
|
||||
from plc_device where access_protocol = #{accessProtocol}
|
||||
</select>
|
||||
<select id="selectHwDeviceJoinList" resultType="com.ruoyi.business.domain.PlcDevice"
|
||||
parameterType="com.ruoyi.business.domain.PlcDevice">
|
||||
select hd.device_id,hd.device_name,
|
||||
hd.tenant_id,hd.scene_id,hd.device_mode_id,hd.ip,hd.port1,hd.location,hd.data_type,hd.length,
|
||||
hd.device_status,
|
||||
hd.access_protocol,hd.station,
|
||||
hs.scene_name,hdmf.device_mode_name,ht.tenant_name
|
||||
from plc_device hd
|
||||
left join hw_scene hs on hd.scene_id = hs.scene_id
|
||||
left join plc_device_mode hdmf on hd.device_mode_id = hdmf.device_mode_id
|
||||
left join hw_tenant ht on hd.tenant_id=ht.tenant_id
|
||||
<where>
|
||||
and hd.device_status != '9'
|
||||
<if test="deviceCode != null and deviceCode != ''"> and hd.device_code like concat('%', #{deviceCode}, '%')</if>
|
||||
<if test="deviceName != null and deviceName != ''"> and hd.device_name like concat('%', #{deviceName}, '%')</if>
|
||||
<if test="sceneId != null "> and hd.scene_id = #{sceneId}</if>
|
||||
<if test="deviceModeId != null "> and hd.device_mode_id = #{deviceModeId}</if>
|
||||
<if test="deviceStatus != null and deviceStatus != ''"> and hd.device_status = #{deviceStatus}</if>
|
||||
<if test="tenantId != null "> and hd.tenant_id = #{tenantId}</if>
|
||||
</where>
|
||||
order by hd.device_id desc
|
||||
</select>
|
||||
<select id="selectPlcDeviceMode" resultType="com.ruoyi.business.domain.PlcDeviceMode"
|
||||
parameterType="com.ruoyi.business.domain.PlcDeviceMode">
|
||||
select * from plc_device_mode
|
||||
<where>
|
||||
<if test="sceneId != null "> and scene_id = #{sceneId}</if>
|
||||
</where>
|
||||
order by device_mode_id desc
|
||||
</select>
|
||||
<select id="selectHwDeviceByDeviceId" resultType="com.ruoyi.business.domain.PlcDevice"
|
||||
parameterType="java.lang.Long">
|
||||
select
|
||||
device_id, device_code, device_name, tenant_id, scene_id, ip, port1, location , access_protocol, length, device_status, create_by, create_time, update_by, update_time,data_type,station,device_mode_id,station
|
||||
from plc_device
|
||||
where device_id = #{deviceId}
|
||||
</select>
|
||||
|
||||
<!--新增所有列-->
|
||||
<insert id="insert" keyProperty="deviceId" useGeneratedKeys="true">
|
||||
insert into plc_device(device_code, device_name, tenant_id, scene_id, ip, port1, location, access_protocol, length, device_status, create_by, create_time, update_by, update_time,station,data_type,device_mode_id)
|
||||
values (#{deviceCode}, #{deviceName}, #{tenantId}, #{sceneId}, #{ip}, #{port1}, #{location}, #{accessProtocol}, #{length}, #{deviceStatus}, #{createBy}, #{createTime}, #{updateBy}, #{updateTime},#{station},#{dataType},#{deviceModeId})
|
||||
</insert>
|
||||
|
||||
<insert id="insertBatch" keyProperty="deviceId" useGeneratedKeys="true">
|
||||
insert into plc_device(device_code, device_name, tenant_id, scene_id, ip, port1, location, access_protocol, length, device_status, create_by, create_time, update_by, update_time)
|
||||
values
|
||||
<foreach collection="entities" item="entity" separator=",">
|
||||
(#{entity.deviceCode}, #{entity.deviceName}, #{entity.tenantId}, #{entity.sceneId}, #{entity.ip}, #{entity.port1}, #{entity.location}, #{entity.accessProtocol}, #{entity.length}, #{entity.deviceStatus}, #{entity.createBy}, #{entity.createTime}, #{entity.updateBy}, #{entity.updateTime})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<insert id="insertOrUpdateBatch" keyProperty="deviceId" useGeneratedKeys="true">
|
||||
insert into plc_device(device_code, device_name, tenant_id, scene_id, ip, port1, location, access_protocol, length, device_status, create_by, create_time, update_by, update_time)
|
||||
values
|
||||
<foreach collection="entities" item="entity" separator=",">
|
||||
(#{entity.deviceCode}, #{entity.deviceName}, #{entity.tenantId}, #{entity.sceneId}, #{entity.ip}, #{entity.port1}, #{entity.location}, #{entity.accessProtocol}, #{entity.length}, #{entity.deviceStatus}, #{entity.createBy}, #{entity.createTime}, #{entity.updateBy}, #{entity.updateTime})
|
||||
</foreach>
|
||||
on duplicate key update
|
||||
device_code = values(device_code),
|
||||
device_name = values(device_name),
|
||||
tenant_id = values(tenant_id),
|
||||
scene_id = values(scene_id),
|
||||
ip = values(ip),
|
||||
port1 = values(port1),
|
||||
location = values(location),
|
||||
access_protocol = values(access_protocol),
|
||||
length = values(length),
|
||||
device_status = values(device_status),
|
||||
create_by = values(create_by),
|
||||
create_time = values(create_time),
|
||||
update_by = values(update_by),
|
||||
update_time = values(update_time)
|
||||
</insert>
|
||||
|
||||
<!--通过主键修改数据-->
|
||||
<update id="update">
|
||||
update plc_device
|
||||
<set>
|
||||
<if test="deviceCode != null and deviceCode != ''">
|
||||
device_code = #{deviceCode},
|
||||
</if>
|
||||
<if test="deviceName != null and deviceName != ''">
|
||||
device_name = #{deviceName},
|
||||
</if>
|
||||
<if test="tenantId != null">
|
||||
tenant_id = #{tenantId},
|
||||
</if>
|
||||
<if test="sceneId != null">
|
||||
scene_id = #{sceneId},
|
||||
</if>
|
||||
<if test="ip != null and ip != ''">
|
||||
ip = #{ip},
|
||||
</if>
|
||||
<if test="port1 != null">
|
||||
port1 = #{port1},
|
||||
</if>
|
||||
<if test="location != null and location != ''">
|
||||
location = #{location},
|
||||
</if>
|
||||
<if test="accessProtocol != null">
|
||||
access_protocol = #{accessProtocol},
|
||||
</if>
|
||||
<if test="length != null">
|
||||
length = #{length},
|
||||
</if>
|
||||
<if test="deviceStatus != null and deviceStatus != ''">
|
||||
device_status = #{deviceStatus},
|
||||
</if>
|
||||
<if test="createBy != null and createBy != ''">
|
||||
create_by = #{createBy},
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
create_time = #{createTime},
|
||||
</if>
|
||||
<if test="updateBy != null and updateBy != ''">
|
||||
update_by = #{updateBy},
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
update_time = #{updateTime},
|
||||
</if>
|
||||
<if test="dataType != null">
|
||||
data_type = #{dataType},
|
||||
</if>
|
||||
<if test="station != null">
|
||||
station = #{station},
|
||||
</if>
|
||||
</set>
|
||||
where device_id = #{deviceId}
|
||||
</update>
|
||||
|
||||
<!--通过主键删除-->
|
||||
<delete id="deleteById">
|
||||
delete from plc_device where device_id = #{deviceId}
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
|
@ -0,0 +1,206 @@
|
||||
<?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.PlcDeviceModeDao">
|
||||
|
||||
<resultMap type="com.ruoyi.business.domain.PlcDeviceMode" id="PlcDeviceModeMap">
|
||||
<result property="deviceModeId" column="device_mode_id" jdbcType="INTEGER"/>
|
||||
<result property="deviceModeName" column="device_mode_name" jdbcType="VARCHAR"/>
|
||||
<result property="tenantId" column="tenant_id" jdbcType="INTEGER"/>
|
||||
<result property="sceneId" column="scene_id" jdbcType="INTEGER"/>
|
||||
<result property="deviceModeStatus" column="device_mode_status" jdbcType="VARCHAR"/>
|
||||
<result property="createBy" column="create_by" jdbcType="VARCHAR"/>
|
||||
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
|
||||
<result property="updateBy" column="update_by" jdbcType="VARCHAR"/>
|
||||
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
|
||||
</resultMap>
|
||||
|
||||
<!--查询单个-->
|
||||
<select id="queryById" resultMap="PlcDeviceModeMap">
|
||||
select
|
||||
device_mode_id, device_mode_name, tenant_id, scene_id, device_mode_status, create_by, create_time, update_by, update_time
|
||||
from plc_device_mode
|
||||
where device_mode_id = #{deviceModeId}
|
||||
</select>
|
||||
|
||||
<!--查询指定行数据-->
|
||||
<select id="queryAllByLimit" resultMap="PlcDeviceModeMap">
|
||||
select
|
||||
device_mode_id, device_mode_name, tenant_id, scene_id, device_mode_status, create_by, create_time, update_by, update_time
|
||||
from plc_device_mode
|
||||
<where>
|
||||
<if test="deviceModeId != null">
|
||||
and device_mode_id = #{deviceModeId}
|
||||
</if>
|
||||
<if test="deviceModeName != null and deviceModeName != ''">
|
||||
and device_mode_name = #{deviceModeName}
|
||||
</if>
|
||||
<if test="tenantId != null">
|
||||
and tenant_id = #{tenantId}
|
||||
</if>
|
||||
<if test="sceneId != null">
|
||||
and scene_id = #{sceneId}
|
||||
</if>
|
||||
<if test="deviceModeStatus != null and deviceModeStatus != ''">
|
||||
and device_mode_status = #{deviceModeStatus}
|
||||
</if>
|
||||
<if test="createBy != null and createBy != ''">
|
||||
and create_by = #{createBy}
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
and create_time = #{createTime}
|
||||
</if>
|
||||
<if test="updateBy != null and updateBy != ''">
|
||||
and update_by = #{updateBy}
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
and update_time = #{updateTime}
|
||||
</if>
|
||||
</where>
|
||||
limit #{pageable.offset}, #{pageable.pageSize}
|
||||
</select>
|
||||
|
||||
<!--统计总行数-->
|
||||
<select id="count" resultType="java.lang.Long">
|
||||
select count(1)
|
||||
from plc_device_mode
|
||||
<where>
|
||||
<if test="deviceModeId != null">
|
||||
and device_mode_id = #{deviceModeId}
|
||||
</if>
|
||||
<if test="deviceModeName != null and deviceModeName != ''">
|
||||
and device_mode_name = #{deviceModeName}
|
||||
</if>
|
||||
<if test="tenantId != null">
|
||||
and tenant_id = #{tenantId}
|
||||
</if>
|
||||
<if test="sceneId != null">
|
||||
and scene_id = #{sceneId}
|
||||
</if>
|
||||
<if test="deviceModeStatus != null and deviceModeStatus != ''">
|
||||
and device_mode_status = #{deviceModeStatus}
|
||||
</if>
|
||||
<if test="createBy != null and createBy != ''">
|
||||
and create_by = #{createBy}
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
and create_time = #{createTime}
|
||||
</if>
|
||||
<if test="updateBy != null and updateBy != ''">
|
||||
and update_by = #{updateBy}
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
and update_time = #{updateTime}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
<select id="selectList" resultType="com.ruoyi.business.domain.PlcDeviceMode">
|
||||
select a.*,ht.tenant_name,hs.scene_name
|
||||
from plc_device_mode a left join hw_scene hs on a.scene_id = hs.scene_id
|
||||
left join hw_tenant ht on a.tenant_id=ht.tenant_id
|
||||
<where>
|
||||
<if test="deviceModeId != null">
|
||||
and a.device_mode_id = #{deviceModeId}
|
||||
</if>
|
||||
<if test="deviceModeName != null and deviceModeName != ''">
|
||||
and a.device_mode_name like concat('%',#{deviceModeName},'%')
|
||||
</if>
|
||||
<if test="tenantId != null">
|
||||
and a.tenant_id = #{tenantId}
|
||||
</if>
|
||||
<if test="sceneId != null">
|
||||
and a.scene_id = #{sceneId}
|
||||
</if>
|
||||
<if test="deviceModeStatus != null and deviceModeStatus != ''">
|
||||
and a.device_mode_status = #{deviceModeStatus}
|
||||
</if>
|
||||
<if test="createBy != null and createBy != ''">
|
||||
and a.create_by = #{createBy}
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
and a.create_time = #{createTime}
|
||||
</if>
|
||||
<if test="updateBy != null and updateBy != ''">
|
||||
and a.update_by = #{updateBy}
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
and a.update_time = #{updateTime}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<!--新增所有列-->
|
||||
<insert id="insert" keyProperty="deviceModeId" useGeneratedKeys="true">
|
||||
insert into plc_device_mode(device_mode_name, tenant_id, scene_id, device_mode_status, create_by, create_time, update_by, update_time)
|
||||
values (#{deviceModeName}, #{tenantId}, #{sceneId}, #{deviceModeStatus}, #{createBy}, #{createTime}, #{updateBy}, #{updateTime})
|
||||
</insert>
|
||||
|
||||
<insert id="insertBatch" keyProperty="deviceModeId" useGeneratedKeys="true">
|
||||
insert into plc_device_mode(device_mode_name, tenant_id, scene_id, device_mode_status, create_by, create_time, update_by, update_time)
|
||||
values
|
||||
<foreach collection="entities" item="entity" separator=",">
|
||||
(#{entity.deviceModeName}, #{entity.tenantId}, #{entity.sceneId}, #{entity.deviceModeStatus}, #{entity.createBy}, #{entity.createTime}, #{entity.updateBy}, #{entity.updateTime})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<insert id="insertOrUpdateBatch" keyProperty="deviceModeId" useGeneratedKeys="true">
|
||||
insert into plc_device_mode(device_mode_name, tenant_id, scene_id, device_mode_status, create_by, create_time, update_by, update_time)
|
||||
values
|
||||
<foreach collection="entities" item="entity" separator=",">
|
||||
(#{entity.deviceModeName}, #{entity.tenantId}, #{entity.sceneId}, #{entity.deviceModeStatus}, #{entity.createBy}, #{entity.createTime}, #{entity.updateBy}, #{entity.updateTime})
|
||||
</foreach>
|
||||
on duplicate key update
|
||||
device_mode_name = values(device_mode_name),
|
||||
tenant_id = values(tenant_id),
|
||||
scene_id = values(scene_id),
|
||||
device_mode_status = values(device_mode_status),
|
||||
create_by = values(create_by),
|
||||
create_time = values(create_time),
|
||||
update_by = values(update_by),
|
||||
update_time = values(update_time)
|
||||
</insert>
|
||||
|
||||
<!--通过主键修改数据-->
|
||||
<update id="update">
|
||||
update plc_device_mode
|
||||
<set>
|
||||
<if test="deviceModeName != null and deviceModeName != ''">
|
||||
device_mode_name = #{deviceModeName},
|
||||
</if>
|
||||
<if test="tenantId != null">
|
||||
tenant_id = #{tenantId},
|
||||
</if>
|
||||
<if test="sceneId != null">
|
||||
scene_id = #{sceneId},
|
||||
</if>
|
||||
<if test="deviceModeStatus != null and deviceModeStatus != ''">
|
||||
device_mode_status = #{deviceModeStatus},
|
||||
</if>
|
||||
<if test="createBy != null and createBy != ''">
|
||||
create_by = #{createBy},
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
create_time = #{createTime},
|
||||
</if>
|
||||
<if test="updateBy != null and updateBy != ''">
|
||||
update_by = #{updateBy},
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
update_time = #{updateTime},
|
||||
</if>
|
||||
</set>
|
||||
where device_mode_id = #{deviceModeId}
|
||||
</update>
|
||||
|
||||
<!--通过主键删除-->
|
||||
<delete id="deleteById">
|
||||
delete from plc_device_mode where device_mode_id = #{deviceModeId}
|
||||
</delete>
|
||||
<delete id="deleteHwDeviceModeByDeviceModeIds">
|
||||
delete from plc_device_mode where device_mode_id in
|
||||
<foreach item="deviceModeId" collection="array" open="(" separator="," close=")">
|
||||
#{deviceModeId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
|
@ -0,0 +1,182 @@
|
||||
<?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.PlcDeviceModeFunctionDao">
|
||||
|
||||
<resultMap type="com.ruoyi.business.domain.PlcDeviceModeFunction" id="PlcDeviceModeFunctionMap">
|
||||
<result property="modeFunctionId" column="mode_function_id" jdbcType="INTEGER"/>
|
||||
<result property="deviceModeId" column="device_mode_id" jdbcType="INTEGER"/>
|
||||
<result property="functionName" column="function_name" jdbcType="VARCHAR"/>
|
||||
<result property="functionIdentifier" column="function_identifier" jdbcType="VARCHAR"/>
|
||||
<result property="dataType" column="data_type" jdbcType="INTEGER"/>
|
||||
<result property="dataDefinition" column="data_definition" jdbcType="VARCHAR"/>
|
||||
<result property="propertyUnit" column="property_unit" jdbcType="VARCHAR"/>
|
||||
<result property="remark" column="remark" jdbcType="VARCHAR"/>
|
||||
<result property="functionMode" column="function_mode" jdbcType="VARCHAR"/>
|
||||
</resultMap>
|
||||
|
||||
<!--查询单个-->
|
||||
<select id="queryById" resultMap="PlcDeviceModeFunctionMap">
|
||||
select
|
||||
mode_function_id, device_mode_id, function_name, function_identifier, data_type, data_definition, property_unit, remark,function_mode
|
||||
from plc_device_mode_function
|
||||
where mode_function_id = #{modeFunctionId}
|
||||
</select>
|
||||
|
||||
<!--查询指定行数据-->
|
||||
<select id="queryAllByLimit" resultMap="PlcDeviceModeFunctionMap">
|
||||
select
|
||||
mode_function_id, device_mode_id, function_name, function_identifier, data_type, data_definition, property_unit, remark
|
||||
from plc_device_mode_function
|
||||
<where>
|
||||
<if test="modeFunctionId != null">
|
||||
and mode_function_id = #{modeFunctionId}
|
||||
</if>
|
||||
<if test="deviceModeId != null">
|
||||
and device_mode_id = #{deviceModeId}
|
||||
</if>
|
||||
<if test="functionName != null and functionName != ''">
|
||||
and function_name = #{functionName}
|
||||
</if>
|
||||
<if test="functionIdentifier != null and functionIdentifier != ''">
|
||||
and function_identifier = #{functionIdentifier}
|
||||
</if>
|
||||
<if test="dataType != null">
|
||||
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="remark != null and remark != ''">
|
||||
and remark = #{remark}
|
||||
</if>
|
||||
</where>
|
||||
limit #{pageable.offset}, #{pageable.pageSize}
|
||||
</select>
|
||||
|
||||
<!--统计总行数-->
|
||||
<select id="count" resultType="java.lang.Long">
|
||||
select count(1)
|
||||
from plc_device_mode_function
|
||||
<where>
|
||||
<if test="modeFunctionId != null">
|
||||
and mode_function_id = #{modeFunctionId}
|
||||
</if>
|
||||
<if test="deviceModeId != null">
|
||||
and device_mode_id = #{deviceModeId}
|
||||
</if>
|
||||
<if test="functionName != null and functionName != ''">
|
||||
and function_name = #{functionName}
|
||||
</if>
|
||||
<if test="functionIdentifier != null and functionIdentifier != ''">
|
||||
and function_identifier = #{functionIdentifier}
|
||||
</if>
|
||||
<if test="dataType != null">
|
||||
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="remark != null and remark != ''">
|
||||
and remark = #{remark}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
<select id="selectFunctions" resultType="com.ruoyi.business.domain.PlcDeviceModeFunction"
|
||||
parameterType="java.lang.Long">
|
||||
SELECT
|
||||
x.*
|
||||
FROM
|
||||
`hwsaas-cloud`.plc_device_mode_function x
|
||||
WHERE
|
||||
x.device_mode_id = #{deviceModeId}
|
||||
</select>
|
||||
<select id="selectFunctionList" resultType="com.ruoyi.business.domain.PlcDeviceModeFunction"
|
||||
parameterType="java.lang.Long">
|
||||
select * from plc_device_mode_function where device_mode_id = #{deviceModeId}
|
||||
</select>
|
||||
<select id="selectHwDeviceModeFunctionList" resultType="com.ruoyi.business.domain.HwDeviceModeFunction"
|
||||
parameterType="com.ruoyi.business.domain.HwDeviceModeFunction">
|
||||
select * from plc_device_mode_function where device_mode_id = #{deviceModeId}
|
||||
</select>
|
||||
|
||||
<!--新增所有列-->
|
||||
<insert id="insert" keyProperty="modeFunctionId" useGeneratedKeys="true">
|
||||
insert into plc_device_mode_function(device_mode_id, function_name, function_identifier, data_type, data_definition, property_unit, remark,function_mode)
|
||||
values (#{deviceModeId}, #{functionName}, #{functionIdentifier}, #{dataType}, #{dataDefinition}, #{propertyUnit}, #{remark},#{functionMode})
|
||||
</insert>
|
||||
|
||||
<insert id="insertBatch" keyProperty="modeFunctionId" useGeneratedKeys="true">
|
||||
insert into plc_device_mode_function(device_mode_id, function_name, function_identifier, data_type, data_definition, property_unit, remark,function_mode)
|
||||
values
|
||||
<foreach collection="entities" item="entity" separator=",">
|
||||
(#{entity.deviceModeId}, #{entity.functionName}, #{entity.functionIdentifier}, #{entity.dataType}, #{entity.dataDefinition}, #{entity.propertyUnit}, #{entity.remark},#{entity.functionMode})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<insert id="insertOrUpdateBatch" keyProperty="modeFunctionId" useGeneratedKeys="true">
|
||||
insert into plc_device_mode_function(device_mode_id, function_name, function_identifier, data_type, data_definition, property_unit, remark)
|
||||
values
|
||||
<foreach collection="entities" item="entity" separator=",">
|
||||
(#{entity.deviceModeId}, #{entity.functionName}, #{entity.functionIdentifier}, #{entity.dataType}, #{entity.dataDefinition}, #{entity.propertyUnit}, #{entity.remark})
|
||||
</foreach>
|
||||
on duplicate key update
|
||||
device_mode_id = values(device_mode_id),
|
||||
function_name = values(function_name),
|
||||
function_identifier = values(function_identifier),
|
||||
data_type = values(data_type),
|
||||
data_definition = values(data_definition),
|
||||
property_unit = values(property_unit),
|
||||
remark = values(remark)
|
||||
</insert>
|
||||
|
||||
<!--通过主键修改数据-->
|
||||
<update id="update">
|
||||
update plc_device_mode_function
|
||||
<set>
|
||||
<if test="deviceModeId != null">
|
||||
device_mode_id = #{deviceModeId},
|
||||
</if>
|
||||
<if test="functionName != null and functionName != ''">
|
||||
function_name = #{functionName},
|
||||
</if>
|
||||
<if test="functionIdentifier != null and functionIdentifier != ''">
|
||||
function_identifier = #{functionIdentifier},
|
||||
</if>
|
||||
<if test="dataType != null">
|
||||
data_type = #{dataType},
|
||||
</if>
|
||||
<if test="dataDefinition != null and dataDefinition != ''">
|
||||
data_definition = #{dataDefinition},
|
||||
</if>
|
||||
<if test="propertyUnit != null and propertyUnit != ''">
|
||||
property_unit = #{propertyUnit},
|
||||
</if>
|
||||
<if test="remark != null and remark != ''">
|
||||
remark = #{remark},
|
||||
</if>
|
||||
</set>
|
||||
where mode_function_id = #{modeFunctionId}
|
||||
</update>
|
||||
|
||||
<!--通过主键删除-->
|
||||
<delete id="deleteById">
|
||||
delete from plc_device_mode_function where mode_function_id = #{modeFunctionId}
|
||||
</delete>
|
||||
<delete id="deleteHwDeviceModeParameterByModeFunctionId" parameterType="java.lang.Long">
|
||||
|
||||
</delete>
|
||||
<delete id="deleteHwDeviceModeFunctionByDeviceModeIds">
|
||||
delete from plc_device_mode_function where device_mode_id in
|
||||
<foreach item="deviceModeId" collection="array" open="(" separator="," close=")">
|
||||
#{deviceModeId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
|
@ -0,0 +1,129 @@
|
||||
import request from '@/utils/request'
|
||||
import {parseStrEmpty} from "@/utils/ruoyi";
|
||||
|
||||
// 查询设备信息列表
|
||||
export function listDevice(query) {
|
||||
return request({
|
||||
url: '/business/plcDevice/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 查询设备信息详细
|
||||
export function getDevice(deviceId) {
|
||||
return request({
|
||||
url: '/business/plcDevice/' + deviceId,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 新增设备信息
|
||||
export function addDevice(data) {
|
||||
return request({
|
||||
url: '/business/plcDevice',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 修改设备信息
|
||||
export function updateDevice(data) {
|
||||
return request({
|
||||
url: '/business/plcDevice',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 删除设备信息
|
||||
export function delDevice(deviceId) {
|
||||
return request({
|
||||
url: '/business/plcDevice/' + deviceId,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// 查询场景信息列表供查询页面选择使用(例如下拉列表)
|
||||
export function getScenes(query) {
|
||||
return request({
|
||||
url: '/business/device/getScenes',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 查询场景信息列表供编辑页面选择使用(例如下拉列表)
|
||||
export function getEditedScenes(query) {
|
||||
return request({
|
||||
url: '/business/device/getEditedScenes',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
export function getProtocols() {
|
||||
return request({
|
||||
url: '/business/plcDevice/getProtocols',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 查询监控单元树
|
||||
export function getMonitorTree(sceneId) {
|
||||
return request({
|
||||
url: '/business/device/monitorUnitTree/' + parseStrEmpty(sceneId),
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// 查询设备模型
|
||||
export function getDeviceModes(sceneId) {
|
||||
return request({
|
||||
url: '/business/plcDevice/getDeviceModes/' + parseStrEmpty(sceneId),
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 查询网关设备
|
||||
export function getGatewayDevices(sceneId) {
|
||||
return request({
|
||||
url: '/business/device/getGatewayDevices/' + parseStrEmpty(sceneId),
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// 设备状态修改
|
||||
export function changeDeviceStatus(deviceId, deviceStatus) {
|
||||
const data = {
|
||||
deviceId,
|
||||
deviceStatus
|
||||
}
|
||||
return request({
|
||||
url: '/business/plcDevice/changeDeviceStatus',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
export function publishControlCommand(deviceId, type) {
|
||||
const data = {
|
||||
deviceId,
|
||||
type
|
||||
}
|
||||
return request({
|
||||
url: '/business/device/publishControlCommand',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 重新生成tdengine所有表
|
||||
export function rebuildTdTables() {
|
||||
return request({
|
||||
url: '/business/device/rebuildTdTables',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
@ -0,0 +1,89 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
// 查询设备模型列表
|
||||
export function listDeviceMode(query) {
|
||||
return request({
|
||||
url: '/business/plcDeviceMode/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
export function addDeviceModeFunction(data) {
|
||||
return request({
|
||||
url: '/business/plcDeviceModeFunction',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
export function updateDeviceModeFunction(data) {
|
||||
return request({
|
||||
url: '/business/plcDeviceModeFunction',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
export function delDeviceModeFunction(modeFunctionId) {
|
||||
return request({
|
||||
url: '/business/plcDeviceModeFunction/' + modeFunctionId,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
// 查询设备模型详细
|
||||
export function getDeviceMode(deviceModeId) {
|
||||
return request({
|
||||
url: '/business/plcDeviceMode/' + deviceModeId,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 新增设备模型
|
||||
export function addDeviceMode(data) {
|
||||
return request({
|
||||
url: '/business/plcDeviceMode',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 修改设备模型
|
||||
export function updateDeviceMode(data) {
|
||||
return request({
|
||||
url: '/business/plcDeviceMode',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 删除设备模型
|
||||
export function delDeviceMode(deviceModeId) {
|
||||
return request({
|
||||
url: '/business/plcDeviceMode/' + deviceModeId,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
|
||||
// 查询场景信息列表供插叙页面选择使用(例如下拉列表)
|
||||
export function getScenes(query) {
|
||||
return request({
|
||||
url: '/business/deviceMode/getScenes',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 查询场景信息列表供编辑页面选择使用(例如下拉列表)
|
||||
export function getEditedScenes(query) {
|
||||
return request({
|
||||
url: '/business/deviceMode/getEditedScenes',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 重新生成tdengine所有超级表
|
||||
export function rebuildTdSuperTables() {
|
||||
return request({
|
||||
url: '/business/deviceMode/rebuildTdSuperTables',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,417 @@
|
||||
<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="模型名称" prop="deviceModeName">
|
||||
<el-input
|
||||
v-model="queryParams.deviceModeName"
|
||||
placeholder="请输入模型名称"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="所属场景" prop="sceneId">
|
||||
<el-select v-model="queryParams.sceneId" placeholder="请选择所属场景">
|
||||
<el-option
|
||||
v-for="(scene, index) in scenes"
|
||||
:key="index"
|
||||
:label="scene.sceneName"
|
||||
:value="scene.sceneId"
|
||||
></el-option>
|
||||
</el-select>
|
||||
|
||||
</el-form-item>
|
||||
<!-- <el-form-item label="定位标识" prop="gpsFlag">-->
|
||||
<!-- <el-select v-model="queryParams.gpsFlag" placeholder="请选择定位标识" clearable>-->
|
||||
<!-- <el-option-->
|
||||
<!-- v-for="dict in dict.type.hw_device_mode_gps_flag"-->
|
||||
<!-- :key="dict.value"-->
|
||||
<!-- :label="dict.label"-->
|
||||
<!-- :value="dict.value"-->
|
||||
<!-- ></el-option>-->
|
||||
<!-- </el-select>-->
|
||||
<!-- </el-form-item>-->
|
||||
<!-- <el-form-item label="模型分类" prop="modeClassfication">-->
|
||||
<!-- <el-select v-model="queryParams.modeClassfication" placeholder="请选择模型分类" clearable>-->
|
||||
<!-- <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-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:deviceMode: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:deviceMode:edit']"-->
|
||||
<!-- >修改-->
|
||||
<!-- </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:deviceMode:export']"-->
|
||||
<!-- >导出-->
|
||||
<!-- </el-button>-->
|
||||
<!-- </el-col>-->
|
||||
<!-- <el-col :span="1.5">-->
|
||||
<!-- <el-button-->
|
||||
<!-- type="primary"-->
|
||||
<!-- plain-->
|
||||
<!-- icon="el-icon-plus"-->
|
||||
<!-- size="mini"-->
|
||||
<!-- @click="handleRebuildTdSuperTables"-->
|
||||
<!-- v-hasPermi="['business:deviceMode:rebuild']"-->
|
||||
<!-- >重建超级表-->
|
||||
<!-- </el-button>-->
|
||||
<!-- </el-col>-->
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table v-loading="loading" :data="deviceModeList" @selection-change="handleSelectionChange">
|
||||
<el-table-column label="模型ID" align="center" prop="deviceModeId"/>
|
||||
<el-table-column label="模型名称" align="center" prop="deviceModeName"/>
|
||||
<el-table-column label="所属租户" align="center" prop="tenantName"/>
|
||||
<el-table-column label="所属场景" align="center" prop="sceneName"/>
|
||||
<!-- <el-table-column label="定位标识" align="center" prop="gpsFlag">-->
|
||||
<!-- <template slot-scope="scope">-->
|
||||
<!-- <dict-tag :options="dict.type.hw_device_mode_gps_flag" :value="scope.row.gpsFlag"/>-->
|
||||
<!-- </template>-->
|
||||
<!-- </el-table-column>-->
|
||||
<!-- <el-table-column label="模型分类" align="center" prop="modeClassfication">-->
|
||||
<!-- <template slot-scope="scope">-->
|
||||
<!-- <dict-tag :options="dict.type.hw_mode_function_mode_classfication" :value="scope.row.modeClassfication"/>-->
|
||||
<!-- </template>-->
|
||||
<!-- </el-table-column>-->
|
||||
<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:deviceMode:edit']"
|
||||
>修改
|
||||
</el-button>
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-delete"
|
||||
@click="handleDelete(scope.row)"
|
||||
v-hasPermi="['business:deviceMode: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"
|
||||
/>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {listDeviceMode, getDeviceMode, delDeviceMode, addDeviceMode, updateDeviceMode,getScenes,rebuildTdSuperTables} from "@/api/plc/plcDeviceMode";
|
||||
import {getLanguages} from "@/api/basic/language";
|
||||
|
||||
export default {
|
||||
dicts: ['hw_device_mode_gps_flag', 'hw_mode_function_mode_classfication'],
|
||||
name: "DeviceMode",
|
||||
data() {
|
||||
return {
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 选中数组
|
||||
ids: [],
|
||||
// 子表选中数据
|
||||
checkedHwDeviceModeFunction: [],
|
||||
// 非单个禁用
|
||||
single: true,
|
||||
// 非多个禁用
|
||||
multiple: true,
|
||||
// 显示搜索条件
|
||||
showSearch: true,
|
||||
// 总条数
|
||||
total: 0,
|
||||
// 设备模型表格数据
|
||||
deviceModeList: [],
|
||||
// 设备模型功能表格数据
|
||||
hwDeviceModeFunctionList: [],
|
||||
// 弹出层标题
|
||||
title: "",
|
||||
// 是否显示弹出层
|
||||
open: false,
|
||||
|
||||
//场景列表
|
||||
scenes: [],
|
||||
//语言列表
|
||||
languages: [],
|
||||
|
||||
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
deviceModeName: null,
|
||||
tenantId: null,
|
||||
sceneId: null,
|
||||
languageCode: null,
|
||||
gpsFlag: null,
|
||||
deviceModeStatus: null,
|
||||
commonFlag: null,
|
||||
modeClassfication: null,
|
||||
deviceModePic: null,
|
||||
dataVerifyLevel: null,
|
||||
deviceModeField: null
|
||||
},
|
||||
// 表单参数
|
||||
form: {},
|
||||
// 表单校验
|
||||
rules: {
|
||||
deviceModeName: [
|
||||
{required: true, message: "设备模型名称不能为空", trigger: "blur"}
|
||||
],
|
||||
gpsFlag: [
|
||||
{required: true, message: "定位标识不能为空", trigger: "blur"}
|
||||
],
|
||||
deviceModeStatus: [
|
||||
{required: true, message: "设备模型状态不能为空", trigger: "change"}
|
||||
],
|
||||
commonFlag: [
|
||||
{required: true, message: "是否通用物模型不能为空", trigger: "blur"}
|
||||
],
|
||||
}
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.getList();
|
||||
getLanguages().then(response => {
|
||||
this.languages = response.data;
|
||||
});
|
||||
|
||||
getScenes().then(response => {
|
||||
this.scenes = response.data;
|
||||
});
|
||||
},
|
||||
computed: {
|
||||
formatRow() {
|
||||
return (row) => {
|
||||
let languages = this.languages;
|
||||
for (let i = 0; i < languages.length; i++) {
|
||||
if (languages[i].languageCode === row.languageCode) {
|
||||
return languages[i].languageName;
|
||||
}
|
||||
}
|
||||
};
|
||||
},
|
||||
},
|
||||
|
||||
activated() {
|
||||
const time = this.$route.query.t;
|
||||
if (time != null && time != this.uniqueId) {
|
||||
this.uniqueId = time;
|
||||
this.queryParams.pageNum = Number(this.$route.query.pageNum);
|
||||
this.getList();
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
/** 查询设备模型列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
listDeviceMode(this.queryParams).then(response => {
|
||||
this.deviceModeList = response.rows;
|
||||
this.total = response.total;
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
// 取消按钮
|
||||
cancel() {
|
||||
this.open = false;
|
||||
this.reset();
|
||||
},
|
||||
// 表单重置
|
||||
reset() {
|
||||
this.form = {
|
||||
deviceModeId: null,
|
||||
deviceModeName: null,
|
||||
tenantId: null,
|
||||
sceneId: null,
|
||||
languageCode: null,
|
||||
gpsFlag: null,
|
||||
deviceModeStatus: null,
|
||||
commonFlag: null,
|
||||
modeClassfication: null,
|
||||
deviceModePic: null,
|
||||
dataVerifyLevel: null,
|
||||
remark: null,
|
||||
createBy: null,
|
||||
createTime: null,
|
||||
updateBy: null,
|
||||
updateTime: null,
|
||||
deviceModeField: null
|
||||
};
|
||||
this.hwDeviceModeFunctionList = [];
|
||||
this.resetForm("form");
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.queryParams.pageNum = 1;
|
||||
this.getList();
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.resetForm("queryForm");
|
||||
this.handleQuery();
|
||||
},
|
||||
// 多选框选中数据
|
||||
handleSelectionChange(selection) {
|
||||
this.ids = selection.map(item => item.deviceModeId)
|
||||
this.single = selection.length !== 1
|
||||
this.multiple = !selection.length
|
||||
},
|
||||
/** 新增按钮操作 */
|
||||
handleAdd() {
|
||||
const params = {pageNum: this.queryParams.pageNum};
|
||||
this.$tab.openPage("添加设备模型", '/plcDeviceMode/mode-add/index', params);
|
||||
},
|
||||
/** 修改按钮操作 */
|
||||
handleUpdate(row) {
|
||||
this.reset();
|
||||
const deviceModeId = row.deviceModeId || this.ids
|
||||
const deviceModeName = row.deviceModeName || this.tableNames[0];
|
||||
const params = {pageNum: this.queryParams.pageNum};
|
||||
this.$tab.openPage("修改设备模型[" + deviceModeName + "]", '/plcDeviceMode/mode-edit/index/' + deviceModeId, params);
|
||||
},
|
||||
/** 提交按钮 */
|
||||
submitForm() {
|
||||
this.$refs["form"].validate(valid => {
|
||||
if (valid) {
|
||||
this.form.hwDeviceModeFunctionList = this.hwDeviceModeFunctionList;
|
||||
if (this.form.deviceModeId != null) {
|
||||
updateDeviceMode(this.form).then(response => {
|
||||
this.$modal.msgSuccess("修改成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
});
|
||||
} else {
|
||||
addDeviceMode(this.form).then(response => {
|
||||
this.$modal.msgSuccess("新增成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const deviceModeIds = row.deviceModeId || this.ids;
|
||||
this.$modal.confirm('是否确认删除设备模型ID为"' + deviceModeIds + '"的数据项?').then(function () {
|
||||
return delDeviceMode(deviceModeIds);
|
||||
}).then(() => {
|
||||
this.getList();
|
||||
this.$modal.msgSuccess("删除成功");
|
||||
}).catch(() => {
|
||||
});
|
||||
},
|
||||
/** 设备模型功能序号 */
|
||||
rowHwDeviceModeFunctionIndex({row, rowIndex}) {
|
||||
row.index = rowIndex + 1;
|
||||
},
|
||||
/** 设备模型功能添加按钮操作 */
|
||||
handleAddHwDeviceModeFunction() {
|
||||
let obj = {};
|
||||
obj.functionMode = "";
|
||||
obj.coordinate = "";
|
||||
obj.functionName = "";
|
||||
obj.functionIdentifier = "";
|
||||
obj.functionType = "";
|
||||
obj.dataType = "";
|
||||
obj.dataDefinition = "";
|
||||
obj.functionFormula = "";
|
||||
obj.propertyUnit = "";
|
||||
obj.displayFlag = "";
|
||||
obj.rwFlag = "";
|
||||
obj.invokeMethod = "";
|
||||
obj.eventType = "";
|
||||
obj.remark = "";
|
||||
obj.acquisitionFormula = "";
|
||||
obj.orderFlag = "";
|
||||
obj.deviceRegister = "";
|
||||
obj.propertyStep = "";
|
||||
obj.propertyField = "";
|
||||
this.hwDeviceModeFunctionList.push(obj);
|
||||
},
|
||||
/** 设备模型功能删除按钮操作 */
|
||||
handleDeleteHwDeviceModeFunction() {
|
||||
if (this.checkedHwDeviceModeFunction.length == 0) {
|
||||
this.$modal.msgError("请先选择要删除的设备模型功能数据");
|
||||
} else {
|
||||
const hwDeviceModeFunctionList = this.hwDeviceModeFunctionList;
|
||||
const checkedHwDeviceModeFunction = this.checkedHwDeviceModeFunction;
|
||||
this.hwDeviceModeFunctionList = hwDeviceModeFunctionList.filter(function (item) {
|
||||
return checkedHwDeviceModeFunction.indexOf(item.index) == -1
|
||||
});
|
||||
}
|
||||
},
|
||||
/** 复选框选中数据 */
|
||||
handleHwDeviceModeFunctionSelectionChange(selection) {
|
||||
this.checkedHwDeviceModeFunction = selection.map(item => item.index)
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
this.download('business/deviceMode/export', {
|
||||
...this.queryParams
|
||||
}, `deviceMode_${new Date().getTime()}.xlsx`)
|
||||
|
||||
this.download('business/deviceMode/exportFunction', {
|
||||
}, `deviceModeFunction_${new Date().getTime()}.xlsx`)
|
||||
},
|
||||
/** 重建超级表按钮操作 */
|
||||
handleRebuildTdSuperTables() {
|
||||
this.$modal.confirm('是否确认重建所有设备监测数据超级表?').then(function () {
|
||||
return rebuildTdSuperTables();
|
||||
}).then(() => {
|
||||
this.$modal.msgSuccess("重建成功");
|
||||
}).catch(() => {
|
||||
});
|
||||
},
|
||||
|
||||
}
|
||||
};
|
||||
</script>
|
Loading…
Reference in New Issue