parent
8b54538f4b
commit
e3af90c13d
@ -0,0 +1,147 @@
|
||||
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.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;
|
||||
|
||||
/**
|
||||
* 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("/linkDataProcess")
|
||||
public AjaxResult linkDataProcess() throws JsonProcessingException {
|
||||
return AjaxResult.success(plcDeviceService.linkDataProcess());
|
||||
}
|
||||
@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,77 @@
|
||||
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.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 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 linkDataProcess();
|
||||
}
|
@ -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,551 @@
|
||||
package com.ruoyi.business.service.impl;
|
||||
|
||||
import HslCommunication.Core.Transfer.DataFormat;
|
||||
import HslCommunication.Core.Types.OperateResultExOne;
|
||||
import HslCommunication.ModBus.ModbusTcpNet;
|
||||
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.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;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
//link数据读取
|
||||
@Override
|
||||
public String linkDataProcess() {
|
||||
// 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);
|
||||
// MelsecA1ENet net = new MelsecA1ENet(plcDevice.getIp(),plcDevice.getPort1());
|
||||
// MelsecFxSerialOverTcp melsecFxSerialOverTcp = new MelsecFxSerialOverTcp();
|
||||
// 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")){
|
||||
// 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);
|
||||
// }
|
||||
// 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>
|
||||
|
Loading…
Reference in New Issue