diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/DataRecordController.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/DataRecordController.java index d561cf4..a7d5913 100644 --- a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/DataRecordController.java +++ b/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> listPage(Query query, DataRecordEntity req) { - return R.data(dataRecordService.page(Condition.getPage(query),Condition.getQueryWrapper(req).lambda())); + public R> listPage(Query query, DataRecordEntity req) { + return R.data(dataRecordService.page(query, req)); } @DeleteMapping("/removeByIds") diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/DataInstructService.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/DataInstructService.java index 2bc8ea9..e137678 100644 --- a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/DataInstructService.java +++ b/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 getDataInstructList() { List list = baseMapper.selectList(null); List deviceFuncDTOS = BeanUtil.copyProperties(list, DeviceFuncDTO.class); List 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); + if (deviceFuncList != null) { + 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; } diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/DataRecordService.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/DataRecordService.java index 25690fb..f0368eb 100644 --- a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/DataRecordService.java +++ b/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,16 +31,40 @@ public class DataRecordService extends BaseServiceImpl page(Query query, DataRecordEntity req) { + IPage page = super.page(Condition.getPage(query), Condition.getQueryWrapper(req).lambda()); + if (page.getSize() == 0) { + return new Page<>(); + } + //获取itemId集合 + List itemIds = page.getRecords().stream().map(DataRecordEntity::getItemId).distinct().collect(Collectors.toList()); + //查询出itemId对应的表信息 + List tableInfos = tableInfoService.listByIds(itemIds); + Map itemIdMap = tableInfos.stream().collect(Collectors.toMap(TableInfoEntity::getId, TableInfoEntity::getTableDesc)); + List dataRecordList = page.getRecords(); + List 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 result = new Page<>(page.getCurrent(), page.getSize(), page.getTotal()); + result.setRecords(dataRecordVOS); + return result; + } + /** * //拼接itemName * @param entity @@ -50,17 +82,19 @@ public class DataRecordService extends BaseServiceImpl list = baseMapper.selectList(null); List deviceAttrDTOS = BeanUtil.copyProperties(list, DeviceAttrDTO.class); List 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); + if (deviceAttrList != null) { + 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; } diff --git a/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/vo/DataRecordVO.java b/hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/vo/DataRecordVO.java new file mode 100644 index 0000000..b777427 --- /dev/null +++ b/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; +}