Search in sources :

Example 1 with EcReptileDynamicBeanDTO

use of com.easy.cloud.core.reptile.dynamicbean.pojo.dto.EcReptileDynamicBeanDTO in project dq-easy-cloud by dq-open-cloud.

the class EcReptileDynamicBeanServiceImpl method buildDynamicBeanDTOs.

/**
 * <p>
 * 根据dynamicBeanEntities列表构建EcReptileDynamicBeanDTO列表
 * </p>
 *
 * <pre>
 *     所需参数示例及其说明
 *     参数名称 : 示例值 : 说明 : 是否必须
 * </pre>
 *
 * @param dynamicBeanEntities
 * @return
 * @author daiqi
 * @创建时间 2018年6月7日 下午8:59:01
 */
private List<EcReptileDynamicBeanDTO> buildDynamicBeanDTOs(List<EcReptileDynamicBeanEntity> dynamicBeanEntities) {
    // 1 entity转换为dto
    List<EcReptileDynamicBeanDTO> dynamicBeanDTOs = EcJSONUtils.parseArray(dynamicBeanEntities, EcReptileDynamicBeanDTO.class);
    // 2 构建dynamicBeanIds
    Set<Integer> dynamicBeanNos = new HashSet<>();
    for (EcReptileDynamicBeanEntity dynamicBean : dynamicBeanEntities) {
        dynamicBeanNos.add(dynamicBean.getDynamicBeanNo());
    }
    // 3 根据dynamicBeanIds获取数据属性数据传输对象列表
    List<EcReptileDataFieldDTO> dataFieldDTOs = reptileDynamicBeanService.findDataFieldsByDynamicBeanNos(dynamicBeanNos);
    EcLogUtils.info("buildDynamicBeanDTOs获取到的属性数据为", dataFieldDTOs, logger);
    EcAssert.verifyListEmpty(dataFieldDTOs, "reptileDataField");
    // 4 将数据属性对象列表放置到对应的dynamicBeanDTO中
    for (EcReptileDynamicBeanDTO dynamicBeanDTO : dynamicBeanDTOs) {
        List<EcReptileDataFieldDTO> dataFieldDTOsTemp = new ArrayList<>();
        for (EcReptileDataFieldDTO dataFieldDTO : dataFieldDTOs) {
            if (EcBaseUtils.equals(dynamicBeanDTO.getDynamicBeanNo(), dataFieldDTO.getDynamicBeanNo())) {
                dataFieldDTOsTemp.add(dataFieldDTO);
            }
        }
        dynamicBeanDTO.setReptileDataFieldDTOs(dataFieldDTOsTemp);
    }
    // 5 返回列表
    return dynamicBeanDTOs;
}
Also used : EcReptileDynamicBeanDTO(com.easy.cloud.core.reptile.dynamicbean.pojo.dto.EcReptileDynamicBeanDTO) EcReptileDynamicBeanEntity(com.easy.cloud.core.reptile.dynamicbean.pojo.entity.EcReptileDynamicBeanEntity) EcReptileDataFieldDTO(com.easy.cloud.core.reptile.datafield.pojo.dto.EcReptileDataFieldDTO)

Example 2 with EcReptileDynamicBeanDTO

use of com.easy.cloud.core.reptile.dynamicbean.pojo.dto.EcReptileDynamicBeanDTO in project dq-easy-cloud by dq-open-cloud.

the class EcReptileDynamicBeanServiceImpl method reptileData.

@Override
public EcBaseServiceResult reptileData(EcReptileDataDTO reptileDataDTO) {
    EcReptileEngineBeanClassDTO reptileEngineBeanClassDTOFromCache = EcReptileConfig.getReptileEngineBeanClassDTO();
    EcAssert.verifyObjNull(reptileEngineBeanClassDTOFromCache, "缓存reptileEngineBeanClassDTOFromCache");
    EcReptileDynamicBeanDTO dynamicBeanDTO = reptileEngineBeanClassDTOFromCache.getReptileDynamicBeanDTO();
    // 获取爬虫引擎
    GeccoEngine geccoEngine = reptileEngineBeanClassDTOFromCache.getGeccoEngine();
    EcAssert.verifyDataNotExistent(geccoEngine, "缓存中geccoEngine");
    EcReptileUtils.intoScheduler(geccoEngine, dynamicBeanDTO, reptileDataDTO);
    return EcBaseServiceResult.newInstanceOfSuccess();
}
Also used : GeccoEngine(com.geccocrawler.gecco.GeccoEngine) EcReptileEngineBeanClassDTO(com.easy.cloud.core.reptile.engine.pojo.dto.EcReptileEngineBeanClassDTO) EcReptileDynamicBeanDTO(com.easy.cloud.core.reptile.dynamicbean.pojo.dto.EcReptileDynamicBeanDTO)

Example 3 with EcReptileDynamicBeanDTO

use of com.easy.cloud.core.reptile.dynamicbean.pojo.dto.EcReptileDynamicBeanDTO in project dq-easy-cloud by dq-open-cloud.

the class EcReptileDynamicBeanServiceImpl method loadReptileEngine.

/**
 * <p>
 * 更新爬虫引擎的规则
 * </p>
 *
 * @return
 * @author daiqi
 * @date 2018/6/12 17:14
 */
private synchronized void loadReptileEngine(List<EcReptileDynamicBeanDTO> dynamicBeanDTOs) {
    // 顶级父动态bean数据传输对象需要加载爬虫引擎
    EcReptileDynamicBeanDTO topParentDynamicBeanDTO = findTopParentDynamicBeanDTO(dynamicBeanDTOs);
    if (topParentDynamicBeanDTO != null) {
        // 获取爬虫引擎
        EcReptileEngineQuery reptileEngineQuery = new EcReptileEngineQuery();
        reptileEngineQuery.setReptileEngineNo(topParentDynamicBeanDTO.getReptileEngineNo());
        reptileEngineQuery.setReptileDynamicBeanDTO(topParentDynamicBeanDTO);
        // 加载爬虫引擎
        reptileEngineService.loadReptileEngineByCore(reptileEngineQuery);
    }
}
Also used : EcReptileEngineQuery(com.easy.cloud.core.reptile.engine.pojo.query.EcReptileEngineQuery) EcReptileDynamicBeanDTO(com.easy.cloud.core.reptile.dynamicbean.pojo.dto.EcReptileDynamicBeanDTO)

Example 4 with EcReptileDynamicBeanDTO

use of com.easy.cloud.core.reptile.dynamicbean.pojo.dto.EcReptileDynamicBeanDTO in project dq-easy-cloud by dq-open-cloud.

the class EcReptileDynamicBeanServiceImpl method findTopParentDynamicBeanDTO.

/**
 * <p>
 * 从爬虫动态bean列表中获取顶级父bean---即dynamicBeanParentNo最小的对象,列表数据为空将抛出异常
 * </p>
 *
 * @param dynamicBeanDTOs
 * @return com.easy.cloud.core.reptile.dynamicbean.pojo.dto.EcReptileDynamicBeanDTO
 * @author daiqi
 * @date 2018/6/13 10:50
 */
private EcReptileDynamicBeanDTO findTopParentDynamicBeanDTO(List<EcReptileDynamicBeanDTO> dynamicBeanDTOs) {
    EcAssert.verifyListEmpty(dynamicBeanDTOs, "dynamicBeanDTOs");
    EcReptileDynamicBeanDTO topParentDynamicBeanDTO = dynamicBeanDTOs.get(0);
    for (EcReptileDynamicBeanDTO reptileDynamicBeanDTO : dynamicBeanDTOs) {
        if (reptileDynamicBeanDTO.getDynamicBeanParentNo() < topParentDynamicBeanDTO.getDynamicBeanParentNo()) {
            topParentDynamicBeanDTO = reptileDynamicBeanDTO;
        }
    }
    return topParentDynamicBeanDTO;
}
Also used : EcReptileDynamicBeanDTO(com.easy.cloud.core.reptile.dynamicbean.pojo.dto.EcReptileDynamicBeanDTO)

Aggregations

EcReptileDynamicBeanDTO (com.easy.cloud.core.reptile.dynamicbean.pojo.dto.EcReptileDynamicBeanDTO)4 EcReptileDataFieldDTO (com.easy.cloud.core.reptile.datafield.pojo.dto.EcReptileDataFieldDTO)1 EcReptileDynamicBeanEntity (com.easy.cloud.core.reptile.dynamicbean.pojo.entity.EcReptileDynamicBeanEntity)1 EcReptileEngineBeanClassDTO (com.easy.cloud.core.reptile.engine.pojo.dto.EcReptileEngineBeanClassDTO)1 EcReptileEngineQuery (com.easy.cloud.core.reptile.engine.pojo.query.EcReptileEngineQuery)1 GeccoEngine (com.geccocrawler.gecco.GeccoEngine)1