Browse Source

fix:对接过程中的问题修复

zhongwei
wangyinsheng 4 months ago
parent
commit
64310cc284
  1. 5
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/DataRecordController.java
  2. 6
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/DataInstructService.java
  3. 38
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/DataRecordService.java
  4. 12
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/vo/DataRecordVO.java

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

@ -5,6 +5,7 @@ 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.gglm.bigmodel.maintenance.vo.DataRecordVO;
import com.hnac.hzinfo.api.annotation.ApiInterface;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -44,8 +45,8 @@ public class DataRecordController {
@GetMapping("/listPage")
@ApiOperation("数据记录列表查询")
@ApiOperationSupport(order = 3)
public R<IPage<DataRecordEntity>> listPage(Query query, DataRecordEntity req) {
return R.data(dataRecordService.page(Condition.getPage(query),Condition.getQueryWrapper(req).lambda()));
public R<IPage<DataRecordVO>> listPage(Query query, DataRecordEntity req) {
return R.data(dataRecordService.page(query, req));
}
@DeleteMapping("/removeByIds")

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

@ -35,7 +35,7 @@ public class DataInstructService extends BaseServiceImpl<DataInstructMapper, Dat
return false;
}
//保存信息
return save(entity);
return super.save(entity);
}
public boolean updateById(DataInstructEntity entity) {
@ -48,13 +48,14 @@ public class DataInstructService extends BaseServiceImpl<DataInstructMapper, Dat
return false;
}
//修改信息
return true;
return super.updateById(entity);
}
public List<DeviceFuncDTO> getDataInstructList() {
List<DataInstructEntity> list = baseMapper.selectList(null);
List<DeviceFuncDTO> deviceFuncDTOS = BeanUtil.copyProperties(list, DeviceFuncDTO.class);
List<DeviceFuncInfoDTO> deviceFuncList = vectorDataService.getDeviceFunc();
if (deviceFuncList != null) {
for (DeviceFuncInfoDTO deviceFunc : deviceFuncList) {
DeviceFuncDTO deviceFuncDTO = new DeviceFuncDTO();
deviceFuncDTO.setDeviceId(deviceFunc.getDeviceId());
@ -65,6 +66,7 @@ public class DataInstructService extends BaseServiceImpl<DataInstructMapper, Dat
deviceFuncDTO.setStationId(deviceFunc.getProjectId());
deviceFuncDTOS.add(deviceFuncDTO);
}
}
return deviceFuncDTOS;
}
}

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

@ -1,19 +1,27 @@
package com.hnac.gglm.bigmodel.maintenance.service;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
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.entity.TableInfoEntity;
import com.hnac.gglm.bigmodel.maintenance.mapper.DataRecordMapper;
import com.hnac.gglm.bigmodel.maintenance.vo.DataRecordVO;
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.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.utils.BeanUtil;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service
@Slf4j
@ -23,14 +31,38 @@ public class DataRecordService extends BaseServiceImpl<DataRecordMapper, DataRec
private final VectorDataService vectorDataService;
private final TableInfoService tableInfoService;
public boolean save(DataRecordEntity entity) {
splicing(entity);
return save(entity);
return super.save(entity);
}
public boolean updateById(DataRecordEntity entity) {
splicing(entity);
return updateById(entity);
return super.updateById(entity);
}
public IPage<DataRecordVO> page(Query query, DataRecordEntity req) {
IPage<DataRecordEntity> page = super.page(Condition.getPage(query), Condition.getQueryWrapper(req).lambda());
if (page.getSize() == 0) {
return new Page<>();
}
//获取itemId集合
List<String> itemIds = page.getRecords().stream().map(DataRecordEntity::getItemId).distinct().collect(Collectors.toList());
//查询出itemId对应的表信息
List<TableInfoEntity> tableInfos = tableInfoService.listByIds(itemIds);
Map<Long, String> itemIdMap = tableInfos.stream().collect(Collectors.toMap(TableInfoEntity::getId, TableInfoEntity::getTableDesc));
List<DataRecordEntity> dataRecordList = page.getRecords();
List<DataRecordVO> dataRecordVOS = BeanUtil.copyProperties(dataRecordList, DataRecordVO.class);
for (int i = 0; i < dataRecordVOS.size(); i++) {
DataRecordEntity dataRecord = page.getRecords().get(i);
String tableDesc = itemIdMap.get(Long.valueOf(dataRecord.getItemId()));
dataRecordVOS.get(i).setTableDesc(tableDesc);
}
Page<DataRecordVO> result = new Page<>(page.getCurrent(), page.getSize(), page.getTotal());
result.setRecords(dataRecordVOS);
return result;
}
/**
@ -50,6 +82,7 @@ public class DataRecordService extends BaseServiceImpl<DataRecordMapper, DataRec
List<DataRecordEntity> list = baseMapper.selectList(null);
List<DeviceAttrDTO> deviceAttrDTOS = BeanUtil.copyProperties(list, DeviceAttrDTO.class);
List<DeviceAttrInfoDTO> deviceAttrList = vectorDataService.getDeviceAttr();
if (deviceAttrList != null) {
for (DeviceAttrInfoDTO deviceAttr : deviceAttrList) {
DeviceAttrDTO deviceAttrDTO = new DeviceAttrDTO();
deviceAttrDTO.setDeviceId(deviceAttr.getDeviceId());
@ -62,6 +95,7 @@ public class DataRecordService extends BaseServiceImpl<DataRecordMapper, DataRec
deviceAttrDTO.setItemName(deviceAttr.getItemName());
deviceAttrDTOS.add(deviceAttrDTO);
}
}
return deviceAttrDTOS;
}
}

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

@ -0,0 +1,12 @@
package com.hnac.gglm.bigmodel.maintenance.vo;
import com.hnac.gglm.bigmodel.maintenance.entity.DataRecordEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class DataRecordVO extends DataRecordEntity {
@ApiModelProperty("itemId对应的表描述信息")
private String tableDesc;
}
Loading…
Cancel
Save