diff --git a/modules/equipment/src/main/java/com/thing/eq/eqmanager/service/impl/IotThingsServiceImpl.java b/modules/equipment/src/main/java/com/thing/eq/eqmanager/service/impl/IotThingsServiceImpl.java index 8aceb51..5edce9d 100644 --- a/modules/equipment/src/main/java/com/thing/eq/eqmanager/service/impl/IotThingsServiceImpl.java +++ b/modules/equipment/src/main/java/com/thing/eq/eqmanager/service/impl/IotThingsServiceImpl.java @@ -32,8 +32,8 @@ import com.thing.thing.entity.mapper.IotThingEntityMapper; import com.thing.thing.entity.service.IotThingEntityService; import com.thing.thing.relation.detail.dto.IotThingRelationDetailDTO; import com.thing.thing.relation.detail.dto.RelationDetailBatchSaveDTO; -import com.thing.thing.relation.detail.dto.ThingRelationDTO; import com.thing.thing.relation.detail.entity.IotThingRelationDetailEntity; +import com.thing.thing.relation.detail.param.IotThingRelationDetailParamDTO; import com.thing.thing.relation.detail.service.IotThingRelationDetailService; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; @@ -192,21 +192,26 @@ public class IotThingsServiceImpl implements IotThingsService { baseInfoDTO.setScrapDisposal("0"); iotThingBaseInfoService.saveDto(baseInfoDTO); //保存设备的关系 - ThingRelationDTO relationDTO = new ThingRelationDTO(); + + List relationDetailDTOS = + iotThingRelationDetailService.findRootDetailChildNodeByRootIdAndFromIdAndRootThingId(dto.getRelationTypeId(), parentThing.getId(), dto.getRelationTopId()); + + IotThingRelationDetailParamDTO relationDTO = new IotThingRelationDetailParamDTO(); relationDTO.setRootId(dto.getRelationTypeId()); relationDTO.setRootThingId(dto.getRelationTopId()); relationDTO.setFromId(parentThing.getId()); relationDTO.setFromCode(parentThing.getCode()); relationDTO.setFromName(parentThing.getName()); - List relationList = new ArrayList<>(); - ThingRelationDTO.RelationEntity relation = new ThingRelationDTO.RelationEntity(); - + relationDTO.setId(relationDetailDTOS.get(0).getId()); + List relationList = new ArrayList<>(); + IotThingRelationDetailParamDTO relation = new IotThingRelationDetailParamDTO(); relation.setToId(thingEntity.getId()); relation.setToCode(code); relation.setToName(dto.getName()); relationList.add(relation); relationDTO.setRelationList(relationList); - iotThingRelationDetailService.saveRelationNodes(relationDTO); + + iotThingRelationDetailService.save(relationDTO); //保存附件 eqAttacmentService.saveBatch(ConvertUtils.sourceToTarget(attacmentDTOS, EqAttacmentEntity.class)); }