|
|
|
@ -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<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; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* //拼接itemName
|
|
|
|
|
* @param entity |
|
|
|
@ -50,17 +82,19 @@ 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(); |
|
|
|
|
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; |
|
|
|
|
} |
|
|
|
|