Merge remote-tracking branch 'origin/master'

master
夜笙歌 6 months ago
commit 55125477fc

@ -0,0 +1,105 @@
package com.ruoyi.business.controller;
import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.business.domain.HwTemplateStyle;
import com.ruoyi.business.service.IHwTemplateStyleService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;
/**
* Controller
*
* @author xins
* @date 2025-01-06
*/
@RestController
@RequestMapping("/templateStyle")
public class HwTemplateStyleController extends BaseController
{
@Autowired
private IHwTemplateStyleService hwTemplateStyleService;
/**
*
*/
// @RequiresPermissions("business:templateStyle:list")
@GetMapping("/list")
public TableDataInfo list(HwTemplateStyle hwTemplateStyle)
{
startPage();
List<HwTemplateStyle> list = hwTemplateStyleService.selectHwTemplateStyleList(hwTemplateStyle);
return getDataTable(list);
}
/**
*
*/
@RequiresPermissions("business:templateStyle:export")
@Log(title = "场景化图风格信息", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, HwTemplateStyle hwTemplateStyle)
{
List<HwTemplateStyle> list = hwTemplateStyleService.selectHwTemplateStyleList(hwTemplateStyle);
ExcelUtil<HwTemplateStyle> util = new ExcelUtil<HwTemplateStyle>(HwTemplateStyle.class);
util.exportExcel(response, list, "场景化图风格信息数据");
}
/**
*
*/
// @RequiresPermissions("business:templateStyle:query")
@GetMapping(value = "/{templateStyleId}")
public AjaxResult getInfo(@PathVariable("templateStyleId") Long templateStyleId)
{
return success(hwTemplateStyleService.selectHwTemplateStyleByTemplateStyleId(templateStyleId));
}
/**
*
*/
// @RequiresPermissions("business:templateStyle:add")
@Log(title = "场景化图风格信息", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody HwTemplateStyle hwTemplateStyle)
{
return toAjax(hwTemplateStyleService.insertHwTemplateStyle(hwTemplateStyle));
}
/**
*
*/
// @RequiresPermissions("business:templateStyle:edit")
@Log(title = "场景化图风格信息", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody HwTemplateStyle hwTemplateStyle)
{
return toAjax(hwTemplateStyleService.updateHwTemplateStyle(hwTemplateStyle));
}
/**
*
*/
@RequiresPermissions("business:templateStyle:remove")
@Log(title = "场景化图风格信息", businessType = BusinessType.DELETE)
@DeleteMapping("/{templateStyleIds}")
public AjaxResult remove(@PathVariable Long[] templateStyleIds)
{
return toAjax(hwTemplateStyleService.deleteHwTemplateStyleByTemplateStyleIds(templateStyleIds));
}
}

@ -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,97 @@
package com.ruoyi.business.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.core.annotation.Excel;
import com.ruoyi.common.core.web.domain.BaseEntity;
/**
* hw_template_style
*
* @author xins
* @date 2025-01-06
*/
public class HwTemplateStyle extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 风格信息ID */
private Long templateStyleId;
/** 风格类型(0自定义1风格1,2风格2,3风格3) */
@Excel(name = "风格类型(0自定义1风格1,2风格2,3风格3)")
private String templateStyleType;
/** 基准颜色 */
@Excel(name = "基准颜色")
private String baseColor;
/** 字体颜色 */
@Excel(name = "字体颜色")
private String fontColor;
/** 颜色库,多个以,隔开 */
@Excel(name = "颜色库,多个以,隔开")
private String colors;
public void setTemplateStyleId(Long templateStyleId)
{
this.templateStyleId = templateStyleId;
}
public Long getTemplateStyleId()
{
return templateStyleId;
}
public void setTemplateStyleType(String templateStyleType)
{
this.templateStyleType = templateStyleType;
}
public String getTemplateStyleType()
{
return templateStyleType;
}
public void setBaseColor(String baseColor)
{
this.baseColor = baseColor;
}
public String getBaseColor()
{
return baseColor;
}
public void setFontColor(String fontColor)
{
this.fontColor = fontColor;
}
public String getFontColor()
{
return fontColor;
}
public void setColors(String colors)
{
this.colors = colors;
}
public String getColors()
{
return colors;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("templateStyleId", getTemplateStyleId())
.append("templateStyleType", getTemplateStyleType())
.append("baseColor", getBaseColor())
.append("fontColor", getFontColor())
.append("colors", getColors())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.toString();
}
}

@ -0,0 +1,247 @@
package com.ruoyi.business.domain;
import com.ruoyi.common.core.annotation.Excel;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* plc(PlcDevice)
*
* @author makejava
* @since 2024-12-19 16:22:47
*/
@Data
public class PlcDevice implements Serializable {
private static final long serialVersionUID = -11771385039084146L;
/**
* ID
*/
private Long deviceId;
/**
*
*/
private String deviceCode;
/**
*
*/
private String deviceName;
/**
* IDhw_tenanttenant_id
*/
private Long tenantId;
/**
* hw_scenescene_id
*/
private Long sceneId;
/**
* ip
*/
private String ip;
/**
*
*/
private Integer port1;
/**
*
*/
private String location;
/**
* 1mc2modbus
*/
private Integer accessProtocol;
private Integer station;
/**
*
*/
private Integer length;
private String dataType;
private String tenantName;
private String sceneName;
private String deviceModeName;
/**
* hw_device_modedevice_mode_id
*/
@Excel(name = "设备模型")
private Long deviceModeId;
/**
* 019
*/
private String deviceStatus;
/**
*
*/
private String createBy;
/**
*
*/
private Date createTime;
private Date publishTime;
/**
*
*/
private String updateBy;
/**
*
*/
private Date updateTime;
public void setDeviceModeId(Long deviceModeId) {
this.deviceModeId = deviceModeId;
}
public Long getDeviceModeId() {
return deviceModeId;
}
public Long getDeviceId() {
return deviceId;
}
public void setDeviceId(Long deviceId) {
this.deviceId = deviceId;
}
public String getDeviceCode() {
return deviceCode;
}
public void setDeviceCode(String deviceCode) {
this.deviceCode = deviceCode;
}
public String getDataType() {
return dataType;
}
public void setDataType(String dataType) {
this.dataType = dataType;
}
public String getDeviceName() {
return deviceName;
}
public void setDeviceName(String deviceName) {
this.deviceName = deviceName;
}
// public String getdLocation() {
// return dLocation;
// }
//
// public void setdLocation(String dLocation) {
// this.dLocation = dLocation;
// }
public Long getTenantId() {
return tenantId;
}
public void setTenantId(Long tenantId) {
this.tenantId = tenantId;
}
public Long getSceneId() {
return sceneId;
}
public void setSceneId(Long sceneId) {
this.sceneId = sceneId;
}
public String getIp() {
return ip;
}
public void setIp(String ip) {
this.ip = ip;
}
public Integer getPort1() {
return port1;
}
public void setPort1(Integer port1) {
this.port1 = port1;
}
public String getLocation() {
return location;
}
public void setLocation(String location) {
this.location = location;
}
public Integer getAccessProtocol() {
return accessProtocol;
}
public void setAccessProtocol(Integer accessProtocol) {
this.accessProtocol = accessProtocol;
}
public Integer getStation() {
return station;
}
public void setStation(Integer station) {
this.station = station;
}
public Integer getLength() {
return length;
}
public void setLength(Integer length) {
this.length = length;
}
public String getDeviceStatus() {
return deviceStatus;
}
public void setDeviceStatus(String deviceStatus) {
this.deviceStatus = deviceStatus;
}
public String getCreateBy() {
return createBy;
}
public void setCreateBy(String createBy) {
this.createBy = createBy;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getPublishTime() {
return publishTime;
}
public void setPublishTime(Date publishTime) {
this.publishTime = publishTime;
}
public String getUpdateBy() {
return updateBy;
}
public void setUpdateBy(String updateBy) {
this.updateBy = updateBy;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
}

@ -0,0 +1,147 @@
package com.ruoyi.business.domain;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* plc(PlcDeviceMode)
*
* @author makejava
* @since 2024-12-19 16:23:27
*/
@Data
public class PlcDeviceMode implements Serializable {
private static final long serialVersionUID = 441335518091339874L;
/**
* ID
*/
private Long deviceModeId;
/**
*
*/
private String deviceModeName;
/**
* IDhw_tenanttenant_id
*/
private Long tenantId;
/**
* hw_scenescene_id
*/
private Long sceneId;
/**
* 19
*/
private String deviceModeStatus;
/**
*
*/
private String createBy;
/**
*
*/
private Date createTime;
/**
*
*/
private String updateBy;
/**
*
*/
private Date updateTime;
private List<PlcDeviceModeFunction> functionList;
private String tenantName;
private String sceneName;
public Long getDeviceModeId() {
return deviceModeId;
}
public void setDeviceModeId(Long deviceModeId) {
this.deviceModeId = deviceModeId;
}
public String getDeviceModeName() {
return deviceModeName;
}
public void setDeviceModeName(String deviceModeName) {
this.deviceModeName = deviceModeName;
}
public String getTenantName() {
return tenantName;
}
public void setTenantName(String tenantName) {
this.tenantName = tenantName;
}
public String getSceneName() {
return sceneName;
}
public void setSceneName(String sceneName) {
this.sceneName = sceneName;
}
public Long getTenantId() {
return tenantId;
}
public void setTenantId(Long tenantId) {
this.tenantId = tenantId;
}
public Long getSceneId() {
return sceneId;
}
public void setSceneId(Long sceneId) {
this.sceneId = sceneId;
}
public String getDeviceModeStatus() {
return deviceModeStatus;
}
public void setDeviceModeStatus(String deviceModeStatus) {
this.deviceModeStatus = deviceModeStatus;
}
public String getCreateBy() {
return createBy;
}
public void setCreateBy(String createBy) {
this.createBy = createBy;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public String getUpdateBy() {
return updateBy;
}
public void setUpdateBy(String updateBy) {
this.updateBy = updateBy;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
}

@ -0,0 +1,134 @@
package com.ruoyi.business.domain;
import com.ruoyi.common.core.annotation.Excel;
import java.io.Serializable;
/**
* plc(PlcDeviceModeFunction)
*
* @author makejava
* @since 2024-12-19 16:23:52
*/
public class PlcDeviceModeFunction implements Serializable {
private static final long serialVersionUID = -19875863077506718L;
/**
* ID
*/
private Long modeFunctionId;
/**
* IDplc_device_modedevice_mode_id
*/
private Long deviceModeId;
/**
*
*/
private String functionName;
/**
* 线50
*/
private String functionIdentifier;
/**
* 2int4float5double6binary(image/base64),9bool10string
*/
private Integer dataType;
/**
* json
1{'minValue':1,'maxValue':100},
2
{'1':'','2','','3','}
3bool
{'0':'关','1','开'}
4Text
{'dataLength'1024}
5String
{'dateFormat':'StringUTC'}
*/
private String dataDefinition;
/**
*
*/
private String propertyUnit;
/**
*
*/
private String remark;
/** 功能模式1、属性2、服务3、事件 */
// @Excel(name = "功能模式", readConverterExp = "1=属性,2=服务,3=事件")
private String functionMode;
public void setFunctionMode(String functionMode)
{
this.functionMode = functionMode;
}
public String getFunctionMode()
{
return functionMode;
}
public Long getModeFunctionId() {
return modeFunctionId;
}
public void setModeFunctionId(Long modeFunctionId) {
this.modeFunctionId = modeFunctionId;
}
public Long getDeviceModeId() {
return deviceModeId;
}
public void setDeviceModeId(Long deviceModeId) {
this.deviceModeId = deviceModeId;
}
public String getFunctionName() {
return functionName;
}
public void setFunctionName(String functionName) {
this.functionName = functionName;
}
public String getFunctionIdentifier() {
return functionIdentifier;
}
public void setFunctionIdentifier(String functionIdentifier) {
this.functionIdentifier = functionIdentifier;
}
public Integer getDataType() {
return dataType;
}
public void setDataType(Integer dataType) {
this.dataType = dataType;
}
public String getDataDefinition() {
return dataDefinition;
}
public void setDataDefinition(String dataDefinition) {
this.dataDefinition = dataDefinition;
}
public String getPropertyUnit() {
return propertyUnit;
}
public void setPropertyUnit(String propertyUnit) {
this.propertyUnit = propertyUnit;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
}

@ -0,0 +1,61 @@
package com.ruoyi.business.mapper;
import java.util.List;
import com.ruoyi.business.domain.HwTemplateStyle;
/**
* Mapper
*
* @author xins
* @date 2025-01-06
*/
public interface HwTemplateStyleMapper
{
/**
*
*
* @param templateStyleId
* @return
*/
public HwTemplateStyle selectHwTemplateStyleByTemplateStyleId(Long templateStyleId);
/**
*
*
* @param hwTemplateStyle
* @return
*/
public List<HwTemplateStyle> selectHwTemplateStyleList(HwTemplateStyle hwTemplateStyle);
/**
*
*
* @param hwTemplateStyle
* @return
*/
public int insertHwTemplateStyle(HwTemplateStyle hwTemplateStyle);
/**
*
*
* @param hwTemplateStyle
* @return
*/
public int updateHwTemplateStyle(HwTemplateStyle hwTemplateStyle);
/**
*
*
* @param templateStyleId
* @return
*/
public int deleteHwTemplateStyleByTemplateStyleId(Long templateStyleId);
/**
*
*
* @param templateStyleIds
* @return
*/
public int deleteHwTemplateStyleByTemplateStyleIds(Long[] templateStyleIds);
}

@ -0,0 +1,61 @@
package com.ruoyi.business.service;
import java.util.List;
import com.ruoyi.business.domain.HwTemplateStyle;
/**
* Service
*
* @author xins
* @date 2025-01-06
*/
public interface IHwTemplateStyleService
{
/**
*
*
* @param templateStyleId
* @return
*/
public HwTemplateStyle selectHwTemplateStyleByTemplateStyleId(Long templateStyleId);
/**
*
*
* @param hwTemplateStyle
* @return
*/
public List<HwTemplateStyle> selectHwTemplateStyleList(HwTemplateStyle hwTemplateStyle);
/**
*
*
* @param hwTemplateStyle
* @return
*/
public int insertHwTemplateStyle(HwTemplateStyle hwTemplateStyle);
/**
*
*
* @param hwTemplateStyle
* @return
*/
public int updateHwTemplateStyle(HwTemplateStyle hwTemplateStyle);
/**
*
*
* @param templateStyleIds
* @return
*/
public int deleteHwTemplateStyleByTemplateStyleIds(Long[] templateStyleIds);
/**
*
*
* @param templateStyleId
* @return
*/
public int deleteHwTemplateStyleByTemplateStyleId(Long templateStyleId);
}

@ -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,99 @@
package com.ruoyi.business.service.impl;
import java.util.List;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.security.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.business.mapper.HwTemplateStyleMapper;
import com.ruoyi.business.domain.HwTemplateStyle;
import com.ruoyi.business.service.IHwTemplateStyleService;
/**
* Service
*
* @author xins
* @date 2025-01-06
*/
@Service
public class HwTemplateStyleServiceImpl implements IHwTemplateStyleService
{
@Autowired
private HwTemplateStyleMapper hwTemplateStyleMapper;
/**
*
*
* @param templateStyleId
* @return
*/
@Override
public HwTemplateStyle selectHwTemplateStyleByTemplateStyleId(Long templateStyleId)
{
return hwTemplateStyleMapper.selectHwTemplateStyleByTemplateStyleId(templateStyleId);
}
/**
*
*
* @param hwTemplateStyle
* @return
*/
@Override
public List<HwTemplateStyle> selectHwTemplateStyleList(HwTemplateStyle hwTemplateStyle)
{
return hwTemplateStyleMapper.selectHwTemplateStyleList(hwTemplateStyle);
}
/**
*
*
* @param hwTemplateStyle
* @return
*/
@Override
public int insertHwTemplateStyle(HwTemplateStyle hwTemplateStyle)
{
hwTemplateStyle.setCreateBy(SecurityUtils.getUsername());
hwTemplateStyle.setCreateTime(DateUtils.getNowDate());
return hwTemplateStyleMapper.insertHwTemplateStyle(hwTemplateStyle);
}
/**
*
*
* @param hwTemplateStyle
* @return
*/
@Override
public int updateHwTemplateStyle(HwTemplateStyle hwTemplateStyle)
{
hwTemplateStyle.setUpdateBy(SecurityUtils.getUsername());
hwTemplateStyle.setUpdateTime(DateUtils.getNowDate());
return hwTemplateStyleMapper.updateHwTemplateStyle(hwTemplateStyle);
}
/**
*
*
* @param templateStyleIds
* @return
*/
@Override
public int deleteHwTemplateStyleByTemplateStyleIds(Long[] templateStyleIds)
{
return hwTemplateStyleMapper.deleteHwTemplateStyleByTemplateStyleIds(templateStyleIds);
}
/**
*
*
* @param templateStyleId
* @return
*/
@Override
public int deleteHwTemplateStyleByTemplateStyleId(Long templateStyleId)
{
return hwTemplateStyleMapper.deleteHwTemplateStyleByTemplateStyleId(templateStyleId);
}
}

@ -0,0 +1,252 @@
package com.ruoyi.business.service.impl;
import com.ruoyi.business.domain.HwDevice;
import com.ruoyi.business.domain.HwDeviceModeFunction;
import com.ruoyi.business.domain.PlcDeviceModeFunction;
import com.ruoyi.business.mapper.PlcDeviceModeFunctionDao;
import com.ruoyi.business.service.PlcDeviceModeFunctionService;
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.StringUtils;
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(PlcDeviceModeFunction)
*
* @author makejava
* @since 2024-12-19 16:23:52
*/
@Service("plcDeviceModeFunctionService")
public class PlcDeviceModeFunctionServiceImpl implements PlcDeviceModeFunctionService {
@Resource
private PlcDeviceModeFunctionDao plcDeviceModeFunctionDao;
@Autowired
private RemoteTdEngineService remoteTdEngineService;
/**
* ID
*
* @param modeFunctionId
* @return
*/
@Override
public PlcDeviceModeFunction queryById(Long modeFunctionId) {
return this.plcDeviceModeFunctionDao.queryById(modeFunctionId);
}
/**
*
*
* @param plcDeviceModeFunction
* @param pageRequest
* @return
*/
@Override
public Page<PlcDeviceModeFunction> queryByPage(PlcDeviceModeFunction plcDeviceModeFunction, PageRequest pageRequest) {
long total = this.plcDeviceModeFunctionDao.count(plcDeviceModeFunction);
return new PageImpl<>(this.plcDeviceModeFunctionDao.queryAllByLimit(plcDeviceModeFunction, pageRequest), pageRequest, total);
}
/**
*
*
* @param plcDeviceModeFunction
* @return
*/
@Override
public int insert(PlcDeviceModeFunction plcDeviceModeFunction) {
checkDuplicateIdentifiers(plcDeviceModeFunction);
int functionId = this.plcDeviceModeFunctionDao.insert(plcDeviceModeFunction);
this.addTdSuperTableColumn(plcDeviceModeFunction);
return functionId;
}
private void addTdSuperTableColumn(PlcDeviceModeFunction hwDeviceModeFunction) {
String functionMode = hwDeviceModeFunction.getFunctionMode();
if (functionMode.equals(HwDictConstants.FUNCTION_MODE_ATTRIBUTE)) {
Long deviceModeId = hwDeviceModeFunction.getDeviceModeId();
String dbName = TdEngineConstants.getDatabaseName();
String superTableName = TdEngineConstants.PLC_SUPER_TABLE_NAME_PREFIX + deviceModeId;
TdSuperTableVo tdSuperTableVo = new TdSuperTableVo();
TdField schemaField = new TdField();
String functionIdentifierTransfer = TdEngineConstants.TDENGINE_KEY_TRANSFER_MAP.get(hwDeviceModeFunction.getFunctionIdentifier());
String functionIdentifier = functionIdentifierTransfer == null ? hwDeviceModeFunction.getFunctionIdentifier() : functionIdentifierTransfer;
schemaField.setFieldName(functionIdentifier);
Integer dataType = hwDeviceModeFunction.getDataType();
schemaField.setDataTypeCode(dataType);
//一个integer类型一个long类型需要转换为string类型比较
if (String.valueOf(dataType).equals(String.valueOf(DataTypeEnums.NCHAR.getDataCode()))) {
schemaField.setSize(Integer.valueOf(hwDeviceModeFunction.getDataDefinition()));
}
tdSuperTableVo.setDatabaseName(dbName);
tdSuperTableVo.setSuperTableName(superTableName);
tdSuperTableVo.setField(schemaField);
R<?> tdReturnMsg = this.remoteTdEngineService.addSuperTableColumn(tdSuperTableVo, SecurityConstants.INNER);
if (tdReturnMsg.getCode() != Constants.SUCCESS) {//抛出异常,回滚事务
throw new RuntimeException(tdReturnMsg.getMsg());
}
}
}
/**
*
*
* @param plcDeviceModeFunction
* @return
*/
@Override
public int update(PlcDeviceModeFunction plcDeviceModeFunction) {
//校验有没有重复标识符
checkDuplicateIdentifiers(plcDeviceModeFunction);
//与数据库中的数据判断标识符有没有修改如果修改则在tdengine超级表删除老的字段增加修改的字段
String functionMode = plcDeviceModeFunction.getFunctionMode();
if (functionMode.equals(HwDictConstants.FUNCTION_MODE_ATTRIBUTE)) {
PlcDeviceModeFunction dbHwDeviceModeFunction = plcDeviceModeFunctionDao
.queryById(plcDeviceModeFunction.getModeFunctionId());
String dbFunctionIdentifier = dbHwDeviceModeFunction.getFunctionIdentifier();
String functionIdentifier = plcDeviceModeFunction.getFunctionIdentifier();
Integer dbDataType = dbHwDeviceModeFunction.getDataType();
Integer dataType = plcDeviceModeFunction.getDataType();
//标识符或数据类型变化时需要先删除超级表column再增加新的column,删除的column数据将会清空(有事务问题,暂时不支持)
if (!dbFunctionIdentifier.equalsIgnoreCase(functionIdentifier)
|| !dbDataType.equals(dataType)) {
// this.dropTdSuperTableColumn(dbHwDeviceModeFunction);
// this.addTdSuperTableColumn(hwDeviceModeFunction);
throw new RuntimeException("标识符和数据类型不支持修改,可删除再新建");
} else {
if (String.valueOf(dataType).equals(String.valueOf(DataTypeEnums.NCHAR.getDataCode()))) {
int dbDataDefinition = Integer.parseInt(dbHwDeviceModeFunction.getDataDefinition());
int dataDefinition = Integer.parseInt(plcDeviceModeFunction.getDataDefinition());
if (dbDataDefinition > dataDefinition) {
throw new ServiceException("数据长度只能改大");
} else if (dbDataDefinition < dataDefinition) {
this.modifyTdSuperTableColumn(plcDeviceModeFunction);
}
}
}
} else {
plcDeviceModeFunctionDao.deleteById(plcDeviceModeFunction.getModeFunctionId());
List<PlcDeviceModeFunction> hwDeviceModeFunctions = new ArrayList<>();
hwDeviceModeFunctions.add(plcDeviceModeFunction);
// batchInsertHwDeviceModeParameters(hwDeviceModeFunctions);
}
return plcDeviceModeFunctionDao.update(plcDeviceModeFunction);
}
private void modifyTdSuperTableColumn(PlcDeviceModeFunction hwDeviceModeFunction) {
String functionMode = hwDeviceModeFunction.getFunctionMode();
if (functionMode.equals(HwDictConstants.FUNCTION_MODE_ATTRIBUTE)) {
Long deviceModeId = hwDeviceModeFunction.getDeviceModeId();
String dbName = TdEngineConstants.getDatabaseName();
String superTableName = TdEngineConstants.PLC_SUPER_TABLE_NAME_PREFIX + deviceModeId;
TdSuperTableVo tdSuperTableVo = new TdSuperTableVo();
TdField schemaField = new TdField();
String functionIdentifierTransfer = TdEngineConstants.TDENGINE_KEY_TRANSFER_MAP.get(hwDeviceModeFunction.getFunctionIdentifier());
String functionIdentifier = functionIdentifierTransfer == null ? hwDeviceModeFunction.getFunctionIdentifier() : functionIdentifierTransfer;
schemaField.setFieldName(functionIdentifier);
Integer dataType = hwDeviceModeFunction.getDataType();
schemaField.setDataTypeCode(dataType.intValue());
//一个integer类型一个long类型需要转换为string类型比较
if (String.valueOf(dataType).equals(String.valueOf(DataTypeEnums.NCHAR.getDataCode()))) {
schemaField.setSize(Integer.valueOf(hwDeviceModeFunction.getDataDefinition()));
}
tdSuperTableVo.setDatabaseName(dbName);
tdSuperTableVo.setSuperTableName(superTableName);
tdSuperTableVo.setField(schemaField);
R<?> tdReturnMsg = this.remoteTdEngineService.modifySuperTableColumn(tdSuperTableVo, SecurityConstants.INNER);
if (tdReturnMsg.getCode() != Constants.SUCCESS) {//抛出异常,回滚事务
throw new RuntimeException(tdReturnMsg.getMsg());
}
}
}
/**
* @param: hwDeviceModeFunction
* @description
* @author xins
* @date 2023-09-13 13:38
*/
private void checkDuplicateIdentifiers(PlcDeviceModeFunction hwDeviceModeFunction) {
String functionIdentifier = hwDeviceModeFunction.getFunctionIdentifier();
if (TdEngineConstants.ABNDON_FUNCTION_IDENTIFIERS.contains(functionIdentifier.toLowerCase())) {
throw new ServiceException("标识符不能等于:" + functionIdentifier);
}
// R<String> keyLongitudeR = remoteConfigService.getConfigKeyStr("hw.gps.longitude");
// R<String> keyLatitudeR = remoteConfigService.getConfigKeyStr("hw.gps.latitude");
// String keyLongitude = keyLongitudeR.getData();
// String keyLatitude = keyLatitudeR.getData();
// if (StringUtils.isEmpty(hwDeviceModeFunction.getCoordinate()) &&
// (hwDeviceModeFunction.getFunctionIdentifier().equalsIgnoreCase(keyLongitude)
// || hwDeviceModeFunction.getFunctionIdentifier().equalsIgnoreCase(keyLatitude))) {
// throw new ServiceException("非定位设备模型标识符不能等于:" + keyLongitude + "或" + keyLatitude);
// }
Long deviceModeId = hwDeviceModeFunction.getDeviceModeId();
HwDeviceModeFunction queryDeviceModeFunction = new HwDeviceModeFunction();
queryDeviceModeFunction.setDeviceModeId(deviceModeId);
List<PlcDeviceModeFunction> hwDeviceModeFunctions = plcDeviceModeFunctionDao.selectFunctionList(deviceModeId);
/**
*
*/
long duplicateCount = hwDeviceModeFunctions.stream().filter(dmf ->
((hwDeviceModeFunction.getModeFunctionId() == null) ||
(hwDeviceModeFunction.getModeFunctionId() != null && !hwDeviceModeFunction.getModeFunctionId().equals(dmf.getModeFunctionId())))
&& dmf.getFunctionIdentifier().equalsIgnoreCase(hwDeviceModeFunction.getFunctionIdentifier())).count();
if (duplicateCount > 0) {
throw new ServiceException("标识符重复");
}
}
/**
*
*
* @param modeFunctionId
* @return
*/
@Override
public int deleteById(Long modeFunctionId) {
PlcDeviceModeFunction hwDeviceModeFunction = plcDeviceModeFunctionDao.queryById(modeFunctionId);
//查询是否有已发布的设备关联此设备模型
int rows = plcDeviceModeFunctionDao.deleteById(modeFunctionId);
this.dropTdSuperTableColumn(hwDeviceModeFunction);
return rows;
}
private void dropTdSuperTableColumn(PlcDeviceModeFunction hwDeviceModeFunction) {
String functionMode = hwDeviceModeFunction.getFunctionMode();
if (functionMode.equals(HwDictConstants.FUNCTION_MODE_ATTRIBUTE)) {
Long deviceModeId = hwDeviceModeFunction.getDeviceModeId();
String dbName = TdEngineConstants.getDatabaseName();
String superTableName = TdEngineConstants.PLC_SUPER_TABLE_NAME_PREFIX + deviceModeId;
TdSuperTableVo tdSuperTableVo = new TdSuperTableVo();
TdField schemaField = new TdField();
schemaField.setFieldName(hwDeviceModeFunction.getFunctionIdentifier());
tdSuperTableVo.setDatabaseName(dbName);
tdSuperTableVo.setSuperTableName(superTableName);
tdSuperTableVo.setField(schemaField);
R<?> tdReturnMsg = this.remoteTdEngineService.dropColumnForSuperTable(tdSuperTableVo, SecurityConstants.INNER);
if (tdReturnMsg.getCode() != Constants.SUCCESS) {//抛出异常,回滚事务
throw new RuntimeException(tdReturnMsg.getMsg());
}
}
}
}

@ -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,87 @@
<?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.HwTemplateStyleMapper">
<resultMap type="HwTemplateStyle" id="HwTemplateStyleResult">
<result property="templateStyleId" column="template_style_id" />
<result property="templateStyleType" column="template_style_type" />
<result property="baseColor" column="base_color" />
<result property="fontColor" column="font_color" />
<result property="colors" column="colors" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectHwTemplateStyleVo">
select template_style_id, template_style_type, base_color, font_color, colors, create_by, create_time, update_by, update_time from hw_template_style
</sql>
<select id="selectHwTemplateStyleList" parameterType="HwTemplateStyle" resultMap="HwTemplateStyleResult">
<include refid="selectHwTemplateStyleVo"/>
<where>
<if test="templateStyleType != null and templateStyleType != ''"> and template_style_type = #{templateStyleType}</if>
<if test="baseColor != null and baseColor != ''"> and base_color = #{baseColor}</if>
<if test="fontColor != null and fontColor != ''"> and font_color = #{fontColor}</if>
<if test="colors != null and colors != ''"> and colors = #{colors}</if>
</where>
</select>
<select id="selectHwTemplateStyleByTemplateStyleId" parameterType="Long" resultMap="HwTemplateStyleResult">
<include refid="selectHwTemplateStyleVo"/>
where template_style_id = #{templateStyleId}
</select>
<insert id="insertHwTemplateStyle" parameterType="HwTemplateStyle" useGeneratedKeys="true" keyProperty="templateStyleId">
insert into hw_template_style
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="templateStyleType != null and templateStyleType != ''">template_style_type,</if>
<if test="baseColor != null and baseColor != ''">base_color,</if>
<if test="fontColor != null and fontColor != ''">font_color,</if>
<if test="colors != null">colors,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="templateStyleType != null and templateStyleType != ''">#{templateStyleType},</if>
<if test="baseColor != null and baseColor != ''">#{baseColor},</if>
<if test="fontColor != null and fontColor != ''">#{fontColor},</if>
<if test="colors != null">#{colors},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updateHwTemplateStyle" parameterType="HwTemplateStyle">
update hw_template_style
<trim prefix="SET" suffixOverrides=",">
<if test="templateStyleType != null and templateStyleType != ''">template_style_type = #{templateStyleType},</if>
<if test="baseColor != null and baseColor != ''">base_color = #{baseColor},</if>
<if test="fontColor != null and fontColor != ''">font_color = #{fontColor},</if>
<if test="colors != null">colors = #{colors},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where template_style_id = #{templateStyleId}
</update>
<delete id="deleteHwTemplateStyleByTemplateStyleId" parameterType="Long">
delete from hw_template_style where template_style_id = #{templateStyleId}
</delete>
<delete id="deleteHwTemplateStyleByTemplateStyleIds" parameterType="String">
delete from hw_template_style where template_style_id in
<foreach item="templateStyleId" collection="array" open="(" separator="," close=")">
#{templateStyleId}
</foreach>
</delete>
</mapper>

@ -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>

@ -1,5 +1,6 @@
package com.ruoyi.portal.controller;
import com.ruoyi.common.core.utils.ip.IpUtils;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
@ -102,6 +103,7 @@ public class HwPortalController extends BaseController
@PostMapping("/addContactUsInfo")
public AjaxResult addContactUsInfo(@RequestBody HwContactUsInfo hwContactUsInfo)
{
hwContactUsInfo.setUserIp(IpUtils.getIpAddr());
return toAjax(hwContactUsInfoService.insertHwContactUsInfo(hwContactUsInfo));
}

@ -54,6 +54,7 @@ public class HwContactUsInfoServiceImpl implements IHwContactUsInfoService
@Override
public int insertHwContactUsInfo(HwContactUsInfo hwContactUsInfo)
{
hwContactUsInfo.setCreateTime(DateUtils.getNowDate());
return hwContactUsInfoMapper.insertHwContactUsInfo(hwContactUsInfo);
}

@ -25,8 +25,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectHwAboutUsInfoDetailVo"/>
<where>
<if test="aboutUsInfoId != null "> and about_us_info_id = #{aboutUsInfoId}</if>
<if test="usInfoDetailTitle != null and usInfoDetailTitle != ''"> and us_info_detail_title = #{usInfoDetailTitle}</if>
<if test="usInfoDetailDesc != null and usInfoDetailDesc != ''"> and us_info_detail_desc = #{usInfoDetailDesc}</if>
<if test="usInfoDetailTitle != null and usInfoDetailTitle != ''"> and us_info_detail_title like concat('%', #{usInfoDetailTitle}, '%')</if>
<if test="usInfoDetailDesc != null and usInfoDetailDesc != ''"> and us_info_detail_desc like concat('%', #{usInfoDetailDesc}, '%')</if>
<if test="usInfoDetailOrder != null "> and us_info_detail_order = #{usInfoDetailOrder}</if>
<if test="usInfoDetailPic != null and usInfoDetailPic != ''"> and us_info_detail_pic = #{usInfoDetailPic}</if>
</where>

@ -27,8 +27,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectHwAboutUsInfoVo"/>
<where>
<if test="aboutUsInfoType != null and aboutUsInfoType != ''"> and about_us_info_type = #{aboutUsInfoType}</if>
<if test="aboutUsInfoTitle != null and aboutUsInfoTitle != ''"> and about_us_info_title = #{aboutUsInfoTitle}</if>
<if test="aboutUsInfoDesc != null and aboutUsInfoDesc != ''"> and about_us_info_desc = #{aboutUsInfoDesc}</if>
<if test="aboutUsInfoTitle != null and aboutUsInfoTitle != ''"> and about_us_info_title like concat('%', #{aboutUsInfoTitle }, '%') </if>
<if test="aboutUsInfoDesc != null and aboutUsInfoDesc != ''"> and about_us_info_desc like concat('%', #{aboutUsInfoDesc}, '%')</if>
<if test="aboutUsInfoOrder != null "> and about_us_info_order = #{aboutUsInfoOrder}</if>
<if test="aboutUsInfoPic != null and aboutUsInfoPic != ''"> and about_us_info_pic = #{aboutUsInfoPic}</if>
</where>

@ -25,9 +25,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectHwContactUsInfoVo"/>
<where>
<if test="userName != null and userName != ''"> and user_name like concat('%', #{userName}, '%')</if>
<if test="userEmail != null and userEmail != ''"> and user_email = #{userEmail}</if>
<if test="userPhone != null and userPhone != ''"> and user_phone = #{userPhone}</if>
<if test="userIp != null and userIp != ''"> and user_ip = #{userIp}</if>
<if test="userEmail != null and userEmail != ''"> and user_email like concat('%', #{userEmail}, '%')</if>
<if test="userPhone != null and userPhone != ''"> and user_phone like concat('%', #{userPhone}, '%')</if>
<if test="userIp != null and userIp != ''"> and user_ip like concat('%', #{userIp}, '%')</if>
</where>
</select>

@ -529,4 +529,43 @@ public class TdEngineController {
return R.fail(message);
}
}
/**
* @param tdGroupSelectDto
* @return R<?>
* @MethodDescription 1s,1m,1d,1w,30d
* SELECT _WSTART as time, _WEND,max(value1) as maxValue,min(value1) as minValue,avg(value1) as avgValue,sum(value1) as sumValue from db_hwsaas.t_device_260
* where ts>=now-10d and ts<now interval(1d) order by time
*/
@InnerAuth
@PostMapping("/getGroupDeviceData")
public R<?> getGroupDeviceData(@Validated @RequestBody TdGroupSelectDto tdGroupSelectDto) {
try {
// if (selectVisualDto.getType() == 0) {//查询历史
// return R.ok(this.tdEngineService.getHistoryData(selectVisualDto));
// }else if(selectVisualDto.getType() == 1) {//查询实时
// return R.ok(this.tdEngineService.getRealtimeData(selectVisualDto));
// }else {//查询聚合
// return R.ok(this.tdEngineService.getAggregateData(selectVisualDto));
// }
TdReturnDataVo returnDataVo = new TdReturnDataVo();
returnDataVo.setDataList(this.tdEngineService.getGroupDeviceData(tdGroupSelectDto));
return R.ok(returnDataVo);
} catch (UncategorizedSQLException e) {
String message = e.getCause().getMessage();
try {
message = message.substring(message.lastIndexOf("invalid operation"));
} catch (Exception ex) {
}
log.error(message);
return R.fail(message);
} catch (Exception e) {
log.error(e.getMessage());
return R.fail(e.getMessage());
}
}
}

@ -165,6 +165,17 @@ public interface TdEngineMapper {
Map<String, Object> getDeviceLocation(TdSelectDto tdSelectDto);
/**
* @return List<Map < Object>>
* @param: tdGroupSelectDto
* @description
* @author xins
* @date 2024-12-31 16:11
*/
List<Map<String, Object>> getGroupDeviceData(TdGroupSelectDto tdGroupSelectDto);
// /**
// * 检查表是否存在
// * @param dataBaseName

@ -142,6 +142,16 @@ public interface ITdEngineService {
*/
public void dropTable(String databaseName, String tableName) throws Exception;
/**
* @return List<Map < Object>>
* @param: tdGroupSelectDto
* @description
* @author xins
* @date 2023-08-29 15:52
*/
public List<Map<String, Object>> getGroupDeviceData(TdGroupSelectDto tdGroupSelectDto);
Map<String,Object> getDeviceLocation(TdSelectDto tdSelectDto);
// void initSTableFrame(String msg) throws Exception;

@ -261,6 +261,28 @@ public class TdEngineServiceImpl implements ITdEngineService {
}
/**
* @return List<Map < Object>>
* @param: tdGroupSelectDto
* @description
* @author xins
* @date 2023-08-29 15:52
*/
@Override
public List<Map<String, Object>> getGroupDeviceData(TdGroupSelectDto tdGroupSelectDto) {
// if (StringUtils.isBlank(tdHistorySelectDto.getOrderByFieldName())) {
// tdHistorySelectDto.setOrderByFieldName(TdEngineConstants.DEFAULT_FIRST_FIELD_NAME);
// }
// if (StringUtils.isBlank(tdHistorySelectDto.getOrderByMode())) {
// tdHistorySelectDto.setOrderByMode(TdEngineConstants.DEFAULT_ORDER_BY_MODE);
// }
List<Map<String, Object>> groupDataMaps = this.tdEngineMapper.getGroupDeviceData(tdGroupSelectDto);
return groupDataMaps;
}
//
// /**
// * 检查数据库表是否存在

@ -319,6 +319,19 @@
drop table #{databaseName}.#{tableName}
</update>
<select id="getGroupDeviceData" parameterType="com.ruoyi.tdengine.api.domain.TdHistorySelectDto" resultType="java.util.Map" >
SELECT _WSTART as time, _WEND,max(${functionIdentifier}) as maxValue,min(${functionIdentifier}) as minValue,avg(${functionIdentifier}) as avgValue,sum(${functionIdentifier}) as sumValue
FROM #{databaseName}.#{tableName}
where ${firstFieldName} &gt;= #{startTime}
and ${firstFieldName} &lt;= #{endTime}
interval(#{interval}) order by time
<if test="offset != null and limit != 0 ">
LIMIT #{offset},#{limit}
</if>
</select>
<!--
<select id="checkTableExists" resultType="java.lang.Integer">
SELECT COUNT(0) FROM #{dataBaseName}.#{tableName}

@ -25,14 +25,6 @@
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="图片地址" prop="aboutUsInfoPic">
<el-input
v-model="queryParams.aboutUsInfoPic"
placeholder="请输入图片地址"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery"></el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery"></el-button>
@ -88,13 +80,25 @@
<el-table v-loading="loading" :data="aboutUsInfoList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="主键标识" align="center" prop="aboutUsInfoId" />
<el-table-column label="类型" align="center" prop="aboutUsInfoType" />
<el-table-column label="类型" align="center" prop="aboutUsInfoType" >
<template slot-scope="scope">
<dict-tag :options="dict.type.hw_about_us_info_type" :value="scope.row.aboutUsInfoType"/>
</template>
</el-table-column>
<el-table-column label="中文标题" align="center" prop="aboutUsInfoTitle" />
<el-table-column label="英文标题" align="center" prop="aboutUsInfoEtitle" />
<el-table-column label="内容" align="center" prop="aboutUsInfoDesc" />
<el-table-column label="顺序" align="center" prop="aboutUsInfoOrder" />
<el-table-column label="显示模式" align="center" prop="displayModal" />
<el-table-column label="图片地址" align="center" prop="aboutUsInfoPic" />
<el-table-column label="显示模式" align="center" prop="displayModal" >
<template slot-scope="scope">
<dict-tag :options="dict.type.hw_about_us_info_display_modal" :value="scope.row.displayModal"/>
</template>
</el-table-column>
<el-table-column label="图片" align="center" prop="aboutUsInfoPic" >
<template slot-scope="scope" v-if="scope.row.aboutUsInfoPic && scope.row.aboutUsInfoPic!=null && scope.row.aboutUsInfoPic!=undefined && scope.row.aboutUsInfoPic!==''">
<img :src="scope.row.aboutUsInfoPic" alt="图片" style="width: 200px;height:150px;">
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
@ -140,19 +144,36 @@
<el-input v-model="form.aboutUsInfoEtitle" placeholder="请输入英文标题" />
</el-form-item>
<el-form-item label="类型" prop="aboutUsInfoType">
<el-input v-model="form.aboutUsInfoType" placeholder="请输入类型" />
</el-form-item>
<el-form-item label="内容" prop="aboutUsInfoDesc">
<el-input v-model="form.aboutUsInfoDesc" placeholder="请输入内容" />
<el-select v-model="form.aboutUsInfoType" placeholder="请选择类型" clearable>
<el-option
v-for="dict in dict.type.hw_about_us_info_type"
:key="dict.value"
:label="dict.label"
:value="dict.value"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="顺序" prop="aboutUsInfoOrder">
<el-input v-model="form.aboutUsInfoOrder" placeholder="请输入顺序" />
</el-form-item>
<el-form-item label="显示模式" prop="displayModal">
<el-input v-model="form.displayModal" placeholder="请输入显示模式" />
<el-select v-model="form.displayModal" placeholder="请选择显示模式" clearable>
<el-option
v-for="dict in dict.type.hw_about_us_info_display_modal"
:key="dict.value"
:label="dict.label"
:value="dict.value"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="内容" prop="aboutUsInfoDesc">
<el-input v-model="form.aboutUsInfoDesc" type="textarea" placeholder="请输入内容" />
</el-form-item>
<el-form-item label="图片" prop="aboutUsInfoPic">
<el-upload
single
@ -211,6 +232,7 @@ import {getToken} from "@/utils/auth";
export default {
name: "AboutUsInfo",
dicts: ['hw_about_us_info_type','hw_about_us_info_display_modal'],
props: {
value: [String, Object, Array],
//
@ -271,6 +293,9 @@ export default {
aboutUsInfoTitle: [
{ required: true, message: "标题不能为空", trigger: "blur" }
],
aboutUsInfoType: [
{ required: true, message: "类型不能为空", trigger: "change" }
],
aboutUsInfoDesc: [
{ required: true, message: "内容不能为空", trigger: "blur" }
],

@ -1,14 +1,6 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="关于我们信息ID" prop="aboutUsInfoId">
<el-input
v-model="queryParams.aboutUsInfoId"
placeholder="请输入关于我们信息ID"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="标题" prop="usInfoDetailTitle">
<el-input
v-model="queryParams.usInfoDetailTitle"
@ -33,14 +25,7 @@
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="图片地址" prop="usInfoDetailPic">
<el-input
v-model="queryParams.usInfoDetailPic"
placeholder="请输入图片地址"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery"></el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery"></el-button>
@ -96,11 +81,14 @@
<el-table v-loading="loading" :data="aboutUsInfoDetailList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="主键标识" align="center" prop="usInfoDetailId" />
<el-table-column label="关于我们信息ID" align="center" prop="aboutUsInfoId" />
<el-table-column label="标题" align="center" prop="usInfoDetailTitle" />
<el-table-column label="内容" align="center" prop="usInfoDetailDesc" />
<el-table-column label="顺序" align="center" prop="usInfoDetailOrder" />
<el-table-column label="图片地址" align="center" prop="usInfoDetailPic" />
<el-table-column label="图片" align="center" prop="usInfoDetailPic" >
<template slot-scope="scope" v-if="scope.row.usInfoDetailPic && scope.row.usInfoDetailPic!=null && scope.row.usInfoDetailPic!=undefined && scope.row.usInfoDetailPic!==''">
<img :src="scope.row.usInfoDetailPic" alt="图片" style="width: 200px;height:150px;">
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
@ -132,9 +120,6 @@
<!-- 添加或修改关于我们信息明细对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="关于我们信息ID" prop="aboutUsInfoId">
<el-input v-model="form.aboutUsInfoId" placeholder="请输入关于我们信息ID" />
</el-form-item>
<el-form-item label="标题" prop="usInfoDetailTitle">
<el-input v-model="form.usInfoDetailTitle" placeholder="请输入标题" />
</el-form-item>

@ -40,16 +40,6 @@
</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="['portal:contactUsInfo:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
@ -111,7 +101,7 @@
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"

Loading…
Cancel
Save