Browse Source

add:控制指令、数据查询指令同步向量数据库接口开发

zhongwei
wangyinsheng 2 months ago
parent
commit
57cbdf8803
  1. 13
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/DataInstructController.java
  2. 12
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/DataRecordController.java
  3. 33
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/dto/DeviceAttrDTO.java
  4. 28
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/dto/DeviceFuncDTO.java
  5. 30
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/DataInstructService.java
  6. 51
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/DataRecordService.java

13
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/DataInstructController.java

@ -2,8 +2,11 @@ package com.hnac.gglm.bigmodel.maintenance.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.gglm.bigmodel.maintenance.dto.DeviceFuncDTO;
import com.hnac.gglm.bigmodel.maintenance.entity.DataInstructEntity;
import com.hnac.gglm.bigmodel.maintenance.service.DataInstructService;
import com.hnac.hzims.operational.station.entity.StationVideoTypeEntity;
import com.hnac.hzinfo.api.annotation.ApiInterface;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@ -15,6 +18,7 @@ import org.springblade.core.tool.utils.Func;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;
@RestController
@RequestMapping("/dataInstruct")
@ -53,4 +57,13 @@ public class DataInstructController {
return R.status(dataInstructService.removeByIds(Func.toLongList(",",ids)));
}
@GetMapping ("/getDataInstructList")
@ApiOperationSupport(order = 210)
@ApiOperation(value = "查询指令记录")
@ApiInterface
public R<List<DeviceFuncDTO>> getDataInstructList() {
return R.data(dataInstructService.getDataInstructList());
}
}

12
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/DataRecordController.java

@ -2,8 +2,10 @@ package com.hnac.gglm.bigmodel.maintenance.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.gglm.bigmodel.maintenance.dto.DeviceAttrDTO;
import com.hnac.gglm.bigmodel.maintenance.entity.DataRecordEntity;
import com.hnac.gglm.bigmodel.maintenance.service.DataRecordService;
import com.hnac.hzinfo.api.annotation.ApiInterface;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@ -15,6 +17,7 @@ import org.springblade.core.tool.utils.Func;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;
@RestController
@RequestMapping("/dataRecord")
@ -51,4 +54,13 @@ public class DataRecordController {
public R removeByIds(@RequestParam @ApiParam("id,按逗号分隔") String ids) {
return R.status(dataRecordService.removeByIds(Func.toLongList(",",ids)));
}
@GetMapping ("/getDataRecordList")
@ApiOperationSupport(order = 200)
@ApiOperation(value = "查询数据记录记录")
@ApiInterface
public R<List<DeviceAttrDTO>> getDataRecordList() {
return R.data(dataRecordService.getDataRecordList());
}
}

33
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/dto/DeviceAttrDTO.java

@ -0,0 +1,33 @@
package com.hnac.gglm.bigmodel.maintenance.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class DeviceAttrDTO {
@ApiModelProperty("item")
private String itemId;
@ApiModelProperty("站点名称")
private String stationName;
@ApiModelProperty("站点ID")
private String stationId;
@ApiModelProperty("遥控的设备名称")
private String deviceName;
@ApiModelProperty("遥控的设备ID")
private String deviceId;
@ApiModelProperty("用于展示和匹配的全称,一般可设为 站点名称-遥控名称")
private String itemName;
@ApiModelProperty("记录名称")
private String recordName;
@ApiModelProperty("取数规则")
private String rule;
}

28
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/dto/DeviceFuncDTO.java

@ -0,0 +1,28 @@
package com.hnac.gglm.bigmodel.maintenance.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class DeviceFuncDTO {
@ApiModelProperty("item")
private String itemId;
@ApiModelProperty("站点名称")
private String stationName;
@ApiModelProperty("站点ID")
private String stationId;
@ApiModelProperty("遥控的设备名称")
private String deviceName;
@ApiModelProperty("遥控的设备ID")
private String deviceId;
@ApiModelProperty("用于展示和匹配的全称,一般可设为 站点名称-遥控名称")
private String itemName;
}

30
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/DataInstructService.java

@ -2,18 +2,28 @@ package com.hnac.gglm.bigmodel.maintenance.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hnac.gglm.bigmodel.business.service.VectorDataService;
import com.hnac.gglm.bigmodel.maintenance.dto.DeviceFuncDTO;
import com.hnac.gglm.bigmodel.maintenance.entity.DataInstructEntity;
import com.hnac.gglm.bigmodel.maintenance.mapper.DataInstructMapper;
import com.hnac.hzinfo.sdk.v5.device.dto.DeviceFuncInfoDTO;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.tool.utils.BeanUtil;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.List;
@Service
@Slf4j
@AllArgsConstructor
public class DataInstructService extends BaseServiceImpl<DataInstructMapper, DataInstructEntity> {
private final VectorDataService vectorDataService;
public boolean save(DataInstructEntity entity) {
//对遥控名称判重
LambdaQueryWrapper<DataInstructEntity> queryWrapper = new QueryWrapper<DataInstructEntity>()
@ -27,6 +37,7 @@ public class DataInstructService extends BaseServiceImpl<DataInstructMapper, Dat
}
public boolean updateById(DataInstructEntity entity) {
//对遥控名称判重
LambdaQueryWrapper<DataInstructEntity> queryWrapper = new QueryWrapper<DataInstructEntity>()
.lambda().eq(DataInstructEntity::getItemName, entity.getItemName())
.ne(DataInstructEntity::getId, entity.getId());
@ -34,7 +45,24 @@ public class DataInstructService extends BaseServiceImpl<DataInstructMapper, Dat
if (count > 0) {
return false;
}
//对遥控名称判重
//修改信息
return true;
}
public List<DeviceFuncDTO> getDataInstructList() {
List<DataInstructEntity> list = baseMapper.selectList(null);
List<DeviceFuncDTO> deviceFuncDTOS = BeanUtil.copyProperties(list, DeviceFuncDTO.class);
List<DeviceFuncInfoDTO> deviceFuncList = vectorDataService.getDeviceFunc();
for (DeviceFuncInfoDTO deviceFunc : deviceFuncList) {
DeviceFuncDTO deviceFuncDTO = new DeviceFuncDTO();
deviceFuncDTO.setDeviceId(deviceFunc.getDeviceId());
deviceFuncDTO.setDeviceName(deviceFunc.getDeviceName());
deviceFuncDTO.setItemId(deviceFunc.getSignage());
deviceFuncDTO.setItemName(deviceFunc.getItemName());
deviceFuncDTO.setStationName(deviceFunc.getProjectName());
deviceFuncDTO.setStationId(deviceFunc.getProjectId());
deviceFuncDTOS.add(deviceFuncDTO);
}
return deviceFuncDTOS;
}
}

51
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/DataRecordService.java

@ -1,14 +1,65 @@
package com.hnac.gglm.bigmodel.maintenance.service;
import com.hnac.gglm.bigmodel.business.service.VectorDataService;
import com.hnac.gglm.bigmodel.maintenance.dto.DeviceAttrDTO;
import com.hnac.gglm.bigmodel.maintenance.dto.DeviceFuncDTO;
import com.hnac.gglm.bigmodel.maintenance.entity.DataRecordEntity;
import com.hnac.gglm.bigmodel.maintenance.mapper.DataRecordMapper;
import com.hnac.hzinfo.sdk.v5.device.dto.DeviceAttrInfoDTO;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.tool.utils.BeanUtil;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
@Slf4j
@AllArgsConstructor
public class DataRecordService extends BaseServiceImpl<DataRecordMapper, DataRecordEntity> {
private final VectorDataService vectorDataService;
public boolean save(DataRecordEntity entity) {
splicing(entity);
return save(entity);
}
public boolean updateById(DataRecordEntity entity) {
splicing(entity);
return updateById(entity);
}
/**
* //拼接itemName
* @param entity
*/
private void splicing(DataRecordEntity entity) {
String stationName = entity.getStationName() == null ? "" : entity.getStationName();
String deviceName = entity.getDeviceName() == null ? "" : entity.getDeviceName();
String recordName = entity.getRecordName() == null ? "" : entity.getRecordName();
entity.setItemName(new StringBuffer(stationName)
.append(" ").append(deviceName)
.append(" ").append(recordName).toString());
}
public List<DeviceAttrDTO> getDataRecordList() {
List<DataRecordEntity> list = baseMapper.selectList(null);
List<DeviceAttrDTO> deviceAttrDTOS = BeanUtil.copyProperties(list, DeviceAttrDTO.class);
List<DeviceAttrInfoDTO> deviceAttrList = vectorDataService.getDeviceAttr();
for (DeviceAttrInfoDTO deviceAttr : deviceAttrList) {
DeviceAttrDTO deviceAttrDTO = new DeviceAttrDTO();
deviceAttrDTO.setDeviceId(deviceAttr.getDeviceId());
deviceAttrDTO.setDeviceName(deviceAttr.getDeviceName());
deviceAttrDTO.setStationName(deviceAttr.getProjectName());
deviceAttrDTO.setStationId(deviceAttr.getProjectId());
deviceAttrDTO.setRecordName(deviceAttr.getName());
deviceAttrDTO.setItemId(deviceAttr.getSignage());
deviceAttrDTO.setRule(deviceAttr.getRule());
deviceAttrDTO.setItemName(deviceAttr.getItemName());
deviceAttrDTOS.add(deviceAttrDTO);
}
return deviceAttrDTOS;
}
}

Loading…
Cancel
Save