线上问诊:数仓开发(一)

news2024/11/17 16:41:24

系列文章目录

线上问诊:业务数据采集
线上问诊:数仓数据同步
线上问诊:数仓开发(一)


文章目录

  • 系列文章目录
  • 前言
  • 一、Hive on yarn
  • 二、数仓开发
    • 1.ODS开发
    • 2.DIM开发
    • 3.DWD开发
  • 总结


前言

上次我们已经将MYSQL的数据传送到了HDFS,但是HDFS的数据没法直接进行查看和修改。这次我们将其转入hive仓库,并进行下一步的处理。


一、Hive on yarn

hive更换引擎
更换完成后,创建我们实验需要的数据库。
CREATE database medical;

二、数仓开发

为了实验方便我们现将之前的数据到删掉。
在这里插入图片描述
修改/opt/module/mock-medical/application.yml文件,统一时间。
在这里插入图片描述
修改 /opt/module/maxwell/config.properties
在这里插入图片描述
清空maxwell数据库
在这里插入图片描述
medical也清空

打开之前搭建的采集通道。

myhadoop.sh start
zk.sh start
kf.sh start
medical-f1.sh start
mxw.sh start

生成2023-05-01至2023-05-09的历史数据。

medical_mock.sh 9

增量表同步

medical_mysql_to_kafka_inc_init.sh all

在这里插入图片描述
全量表同步

medical_mysql_to_hdfs_full.sh all 2023-05-09

在这里插入图片描述

1.ODS开发

医生表(全量表)

DROP TABLE IF EXISTS `ods_doctor_full`;
CREATE EXTERNAL TABLE IF NOT EXISTS `ods_doctor_full`
(
    `id`               STRING COMMENT '医生ID',
    `create_time`      STRING COMMENT '创建时间',
    `update_time`      STRING COMMENT '修改时间',
    `birthday`         STRING COMMENT '出生日期',
    `consultation_fee` DECIMAL(19, 2) COMMENT '就诊费用',
    `gender`           STRING COMMENT '性别:101.男 102.女',
    `name`             STRING COMMENT '姓名',
    `specialty`        STRING COMMENT '专业:详情见字典表5xx条目',
    `title`            STRING COMMENT '职称:301. 医士 302. 医师 303. 主治医师 304. 副主任医师 305. 主任医师',
    `hospital_id`      STRING COMMENT '所属医院'
) COMMENT '医生全量表'
    PARTITIONED BY (`dt` STRING)
    ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t'
        NULL DEFINED AS ''
    LOCATION '/warehouse/medical/ods/ods_doctor_full/'
    TBLPROPERTIES ('compression.codec' = 'org.apache.hadoop.io.compress.GzipCodec');

医院表(全量表)

CREATE EXTERNAL TABLE IF NOT EXISTS `ods_hospital_full`
(
    `id`              STRING COMMENT '医院ID',
    `create_time`     STRING COMMENT '创建时间',
    `update_time`     STRING COMMENT '修改时间',
    `address`         STRING COMMENT '地址',
    `alias`           STRING COMMENT '医院别名',
    `bed_num`         BIGINT COMMENT '病床数量',
    `city`            STRING COMMENT '市',
    `department_num`  BIGINT COMMENT '科室数量',
    `district`        STRING COMMENT '区县',
    `establish_time`  STRING COMMENT '建立时间',
    `health_care_num` BIGINT COMMENT '医护人数',
    `insurance`       STRING COMMENT '是否医保',
    `level`           STRING COMMENT '医院级别,一级甲等,二级甲等....',
    `name`            STRING COMMENT '医院名称',
    `province`        STRING COMMENT '省(直辖市)'
) COMMENT '医院表'
    PARTITIONED BY (`dt` STRING)
    ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t'
        NULL DEFINED AS ''
    LOCATION '/warehouse/medical/ods/ods_hospital_full/'
    TBLPROPERTIES ('compression.codec' = 'org.apache.hadoop.io.compress.GzipCodec');

药品表(全量表)

CREATE EXTERNAL TABLE IF NOT EXISTS `ods_medicine_full`
(
    `id`            STRING COMMENT '药品ID',
    `create_time`   STRING COMMENT '创建时间',
    `update_time`   STRING COMMENT '修改时间',
    `approval_code` STRING COMMENT '药物批号',
    `dose_type`     STRING COMMENT '剂量',
    `name`          STRING COMMENT '药品名称',
    `name_en`       STRING COMMENT '英文名称',
    `price`         DECIMAL(19, 2) COMMENT '药品价格',
    `specs`         STRING COMMENT '规格',
    `trade_name`    STRING COMMENT '商品名'
) COMMENT '药品表'
    PARTITIONED BY (`dt` STRING)
    ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t'
        NULL DEFINED AS ''
    LOCATION '/warehouse/medical/ods/ods_medicine_full/'
    TBLPROPERTIES ('compression.codec' = 'org.apache.hadoop.io.compress.GzipCodec');

患者表(全量表)

CREATE EXTERNAL TABLE IF NOT EXISTS `ods_patient_full`
(
    `id`          STRING COMMENT '患者ID',
    `create_time` STRING COMMENT '创建时间',
    `update_time` STRING COMMENT '修改时间',
    `birthday`    STRING COMMENT '出生日期',
    `gender`      STRING COMMENT '性别',
    `name`        STRING COMMENT '姓名',
    `user_id`     STRING COMMENT '所属用户'
) COMMENT '患者表'
    PARTITIONED BY (`dt` STRING)
    ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t'
        NULL DEFINED AS ''
    LOCATION '/warehouse/medical/ods/ods_patient_full/'
    TBLPROPERTIES ('compression.codec' = 'org.apache.hadoop.io.compress.GzipCodec');

字典表(全量表)

CREATE EXTERNAL TABLE IF NOT EXISTS `ods_dict_full`
(
    `id`          STRING COMMENT '编码ID',
    `create_time` STRING COMMENT '创建时间',
    `update_time` STRING COMMENT '修改时间',
    `value`       STRING
) COMMENT '字典表'
    PARTITIONED BY (`dt` STRING)
    ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t'
        NULL DEFINED AS ''
    LOCATION '/warehouse/medical/ods/ods_dict_full/'
    TBLPROPERTIES ('compression.codec' = 'org.apache.hadoop.io.compress.GzipCodec');

用户表(全量表)

CREATE EXTERNAL TABLE IF NOT EXISTS `ods_user_full`
(
    `id`              STRING COMMENT '用户ID',
    `create_time`     STRING COMMENT '创建时间',
    `update_time`     STRING COMMENT '修改时间',
    `email`           STRING COMMENT '电邮',
    `hashed_password` STRING COMMENT '密码',
    `telephone`       STRING COMMENT '电话',
    `username`        STRING COMMENT '用户名'
) COMMENT '用户全量表'
    PARTITIONED BY (`dt` STRING)
    ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t'
        NULL DEFINED AS ''
    LOCATION '/warehouse/medical/ods/ods_user_full/'
    TBLPROPERTIES ('compression.codec' = 'org.apache.hadoop.io.compress.GzipCodec');

就诊表(增量表)

CREATE EXTERNAL TABLE IF NOT EXISTS `ods_consultation_inc`
(
    `type` STRING COMMENT '变动类型',
    `ts`   BIGINT COMMENT '变动时间',
    `data` STRUCT
        <id :STRING,
         create_time :STRING,
         update_time :STRING,
         consultation_fee :DECIMAL(16, 2),
         description :STRING, 
         diagnosis :STRING, 
         rating :STRING, 
         user_id :STRING, 
         review :STRING, 
         patient_id :STRING,
         doctor_id :STRING, 
         status :STRING> COMMENT '变更后数据',
    `old`  MAP<STRING,STRING> COMMENT '旧值'
) COMMENT '就诊表增量表'
    PARTITIONED BY (`dt` STRING)
    ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.JsonSerDe'
    LOCATION '/warehouse/medical/ods/ods_consultation_inc/'
    TBLPROPERTIES ('compression.codec' = 'org.apache.hadoop.io.compress.GzipCodec');

处方开单表(增量表)

CREATE EXTERNAL TABLE IF NOT EXISTS `ods_prescription_inc`
(
    `type` STRING COMMENT '变动类型',
    `ts`   BIGINT COMMENT '变动时间',
    `data` STRUCT
        <id :STRING, 
         create_time :STRING, 
         update_time :STRING, 
         instruction :STRING, 
         status :STRING,
         total_amount :DECIMAL(16, 2), 
         consultation_id :STRING, 
         doctor_id :STRING, 
         patient_id :STRING> COMMENT '变更后数据',
    `old`  MAP<STRING,STRING> COMMENT '旧值'
) COMMENT '处方表增量表'
    PARTITIONED BY (`dt` STRING)
    ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.JsonSerDe'
    LOCATION '/warehouse/medical/ods/ods_prescription_inc/'
    TBLPROPERTIES ('compression.codec' = 'org.apache.hadoop.io.compress.GzipCodec');

处方开单详情表(增量表)

CREATE EXTERNAL TABLE IF NOT EXISTS `ods_prescription_detail_inc`
(
    `type` STRING COMMENT '变动类型',
    `ts`   BIGINT COMMENT '变动时间',
    `data` STRUCT
        <id :STRING, 
         create_time :STRING, 
         update_time :STRING, 
         count :STRING, 
         instruction :STRING, 
         medicine_id :STRING, 
         prescription_id :STRING> COMMENT '变更后数据',
    `old`  MAP<STRING,STRING> COMMENT '旧值'
) COMMENT '处方详情表增量表'
    PARTITIONED BY (`dt` STRING)
    ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.JsonSerDe'
    LOCATION '/warehouse/medical/ods/ods_prescription_detail_inc/'
    TBLPROPERTIES ('compression.codec' = 'org.apache.hadoop.io.compress.GzipCodec');

支付表(增量表)

CREATE EXTERNAL TABLE IF NOT EXISTS `ods_payment_inc`
(
    `type` STRING COMMENT '变动类型',
    `ts`   BIGINT COMMENT '变动时间',
    `data` STRUCT
        <id :STRING, 
         create_time :STRING, 
         update_time :STRING, 
         payment_amount :DECIMAL(16, 2), 
         status :STRING,
         consultation_id :STRING, 
         prescription_id :STRING, 
         user_id :STRING> COMMENT '变更后数据',
    `old`  MAP<STRING,STRING> COMMENT '旧值'
) COMMENT '支付表增量表'
    PARTITIONED BY (`dt` STRING)
    ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.JsonSerDe'
    LOCATION '/warehouse/medical/ods/ods_payment_inc/'
    TBLPROPERTIES ('compression.codec' = 'org.apache.hadoop.io.compress.GzipCodec');

医生表(增量表)

CREATE EXTERNAL TABLE IF NOT EXISTS `ods_doctor_inc`
(
    `type` STRING COMMENT '变动类型',
    `ts`   BIGINT COMMENT '变动时间',
    `data` STRUCT
        <id :STRING, 
         create_time :STRING, 
         update_time :STRING, 
         birthday :STRING, 
         consultation_fee :DECIMAL(16, 2), 
         gender :STRING, 
         name :STRING, 
         specialty :STRING, 
         title :STRING, 
         hospital_id :STRING> COMMENT '变更后数据',
    `old` MAP<STRING,STRING> COMMENT '旧值'
) COMMENT '医生增量表'
    PARTITIONED BY (`dt` STRING)
    ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.JsonSerDe'
    LOCATION '/warehouse/medical/ods/ods_doctor_inc/'
    TBLPROPERTIES ('compression.codec' = 'org.apache.hadoop.io.compress.GzipCodec');

用户表(增量表)

CREATE EXTERNAL TABLE IF NOT EXISTS `ods_user_inc`
(
    `type` STRING COMMENT '变动类型',
    `ts`   BIGINT COMMENT '变动时间',
    `data` STRUCT
        <id :STRING, 
         create_time :STRING, 
         update_time :STRING, 
         email :STRING, 
         hashed_password :STRING,
         telephone :STRING, 
         username :STRING> COMMENT '变更后数据',
    `old`  MAP<STRING,STRING> COMMENT '旧值'
) COMMENT '用户增量表'
    PARTITIONED BY (`dt` STRING)
    ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.JsonSerDe'
    LOCATION '/warehouse/medical/ods/ods_user_inc/'
    TBLPROPERTIES ('compression.codec' = 'org.apache.hadoop.io.compress.GzipCodec');

患者表(增量表)

CREATE EXTERNAL TABLE IF NOT EXISTS `ods_patient_inc`
(
    `type` STRING COMMENT '变动类型',
    `ts`   BIGINT COMMENT '变动时间',
    `data` STRUCT
        <`id` : STRING,
         `create_time` : STRING, 
         `update_time` : STRING, 
         `birthday` : STRING, 
         `gender` : STRING,
         `name` : STRING, 
         `user_id` : STRING> COMMENT '变更后数据',
    `old`  MAP<STRING,STRING> COMMENT '旧值'
) COMMENT '用户增量表'
    PARTITIONED BY (`dt` STRING)
    ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.JsonSerDe'
    LOCATION '/warehouse/medical/ods/ods_patient_inc/'
    TBLPROPERTIES ('compression.codec' = 'org.apache.hadoop.io.compress.GzipCodec');

数据装载脚本
vim ~/bin/medical_hdfs_to_ods.sh

#!/bin/bash

APP=medical

if [ -n "$2" ] ;then
   do_date=$2
else 
   do_date=`date -d '-1 day' +%F`
fi

load_data(){
    sql=""
    for i in $*; do
        #判断路径是否存在
        hadoop fs -test -e /origin_data/$APP/${i:4}/$do_date
        #路径存在方可装载数据
        if [[ $? = 0 ]]; then
            sql=$sql"load data inpath '/origin_data/$APP/${i:4}/$do_date' OVERWRITE into table ${APP}.$i partition(dt='$do_date');"
        fi
    done
    hive -e "$sql"
}

case $1 in
    ods_consultation_inc | ods_dict_full | ods_doctor_full | ods_doctor_inc | ods_hospital_full | ods_medicine_full | ods_patient_full | ods_patient_inc | ods_payment_inc | ods_prescription_detail_inc | ods_prescription_inc | ods_user_full | ods_user_inc)
        load_data "$1"
    ;;
    "all")
        load_data "ods_consultation_inc" "ods_dict_full" "ods_doctor_full" "ods_doctor_inc" "ods_hospital_full" "ods_medicine_full" "ods_patient_full" "ods_patient_inc" "ods_payment_inc" "ods_prescription_detail_inc" "ods_prescription_inc" "ods_user_full" "ods_user_inc" 
    ;;
esac

添加权限
chmod +x ~/bin/medical_hdfs_to_ods.sh
执行脚本
medical_hdfs_to_ods.sh all 2023-05-09

2.DIM开发

医生维度表
建表语句

CREATE EXTERNAL TABLE IF NOT EXISTS dim_doctor_full
(
    `id`               STRING COMMENT '医生ID',
    `birthday`         STRING COMMENT '出生日期',
    `consultation_fee` DECIMAL(19, 2) COMMENT '就诊费用',
    `gender_code`      STRING COMMENT '性别编码:101.男 102.女',
    `gender`           STRING COMMENT '性别',
    `name`             STRING COMMENT '姓名',
    `specialty_code`   STRING COMMENT '专业编码:详情见字典表5xx条目',
    `specialty_name`   STRING COMMENT '专业名称',
    `title_code`       STRING COMMENT '职称编码:301. 医士 302. 医师 303. 主治医师 304. 副主任医师 305. 主任医师',
    `title_name`       STRING COMMENT '职称名称',
    `hospital_id`      STRING COMMENT '所属医院ID'
) COMMENT '医生维度表'
    PARTITIONED BY (`dt` STRING)
    STORED AS ORC
    LOCATION '/warehouse/medical/dim/dim_doctor_full/'
    TBLPROPERTIES ('orc.compress' = 'snappy');

数据装载

insert overwrite table dim_doctor_full
    partition (dt = '2023-05-09')
select doc.id,
       birthday,
       consultation_fee,
       gender              gender_code,
       gender_dic.value    gender,
       name,
       specialty           specialty_code,
       specialty_dic.value specialty_name,
       title               title_code,
       title_dic.value     title_name,
       hospital_id
from (select id,
             birthday,
             consultation_fee,
             gender,
             concat(substr(name,1,1), regexp_replace(substr(name, 2), '.', '*')) name,
             specialty,
             title,
             hospital_id
      from ods_doctor_full
      where dt = '2023-05-09') doc
         left join
     (select id,
             value
      from ods_dict_full
      where dt = '2023-05-09') gender_dic
     on doc.gender = gender_dic.id
         left join
     (select id,
             value
      from ods_dict_full
      where dt = '2023-05-09') specialty_dic
     on doc.specialty = specialty_dic.id
         left join
     (select id,
             value
      from ods_dict_full
      where dt = '2023-05-09') title_dic
     on doc.title = title_dic.id;

医院维度表
建表语句

CREATE EXTERNAL TABLE IF NOT EXISTS dim_hospital_full
(
    `id`              STRING COMMENT '医院ID',
    `address`         STRING COMMENT '地址',
    `alias`           STRING COMMENT '医院别名',
    `bed_num`         BIGINT COMMENT '病床数量',
    `city`            STRING COMMENT '所在城市',
    `department_num`  BIGINT COMMENT '科室数量',
    `district`        STRING COMMENT '所属区县',
    `establish_time`  STRING COMMENT '建立时间',
    `health_care_num` BIGINT COMMENT '医护人数',
    `insurance`       STRING COMMENT '是否医保',
    `level`           STRING COMMENT '医院级别,一级甲等,二级甲等....',
    `name`            STRING COMMENT '医院名称',
    `province`        STRING COMMENT '所属省(直辖市)'
) COMMENT '医院维度表'
    PARTITIONED BY (`dt` STRING)
    STORED AS ORC
    LOCATION '/warehouse/medical/dim/dim_hospital_full/'
    TBLPROPERTIES ('orc.compress' = 'snappy');

数据装载

insert overwrite table dim_hospital_full
    partition (dt = '2023-05-09')
select id,
       address,
       alias,
       bed_num,
       city,
       department_num,
       district,
       establish_time,
       health_care_num,
       insurance,
       level,
       name,
       province
from ods_hospital_full
where dt = '2023-05-09';

药品维度表
建表语句

CREATE EXTERNAL TABLE IF NOT EXISTS dim_medicine_full
(
    `id`            STRING COMMENT '药品ID',
    `approval_code` STRING COMMENT '药物批号',
    `dose_type`     STRING COMMENT '剂量',
    `name`          STRING COMMENT '药品名称',
    `name_en`       STRING COMMENT '英文名称',
    `price`         DECIMAL(19, 2) COMMENT '药品价格',
    `specs`         STRING COMMENT '规格',
    `trade_name`    STRING COMMENT '商品名'
) COMMENT '药品维度表'
    PARTITIONED BY (`dt` STRING)
    STORED AS ORC
    LOCATION '/warehouse/medical/dim/dim_medicine_full/'
    TBLPROPERTIES ('orc.compress' = 'snappy');

数据装载

insert overwrite table dim_medicine_full
    partition (dt = '2023-05-09')
select id,
       approval_code,
       dose_type,
       name,
       name_en,
       price,
       specs,
       trade_name
from ods_medicine_full
where dt = '2023-05-09';

患者维度表
建表语句

CREATE EXTERNAL TABLE IF NOT EXISTS dim_patient_full
(
    `id`          STRING COMMENT '患者ID',
    `birthday`    STRING COMMENT '出生日期',
    `gender_code` STRING COMMENT '性别编码',
    `gender`      STRING COMMENT '性别',
    `name`        STRING COMMENT '姓名',
    `user_id`     STRING COMMENT '所属用户'
) COMMENT '患者维度表'
    PARTITIONED BY (`dt` STRING)
    STORED AS ORC
    LOCATION '/warehouse/medical/dim/dim_patient_full/'
    TBLPROPERTIES ('orc.compress' = 'snappy');

数据装载

insert overwrite table dim_patient_full
    partition (dt = '2023-05-09')
select patient.id,
       birthday,
       gender    gender_code,
       dic.value gender,
       name,
       user_id
from (select id,
             birthday,
             gender,
             concat(substr(name,1,1), regexp_replace(substr(name, 2), '.', '*')) name,
             user_id
      from ods_patient_full
      where dt = '2023-05-09') patient
         left join
     (select id,
             value
      from ods_dict_full
      where dt = '2023-05-09') dic
     on patient.gender = dic.id;

用户维度表
建表语句

CREATE EXTERNAL TABLE IF NOT EXISTS dim_user_full
(
    `id`        STRING COMMENT '用户ID',
    `email`     STRING COMMENT '电邮',
    `telephone` STRING COMMENT '电话',
    `username`  STRING COMMENT '用户名'
) COMMENT '用户维度表'
    PARTITIONED BY (`dt` STRING)
    STORED AS ORC
    LOCATION '/warehouse/medical/dim/dim_user_full/'
    TBLPROPERTIES ('orc.compress' = 'snappy');

数据装载

insert overwrite table dim_user_full
    partition (dt = '2023-05-09')
select id,
       concat('*@', split(email, '@')[1])             email,
       if(telephone regexp '^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\\d{8}$',
          concat(substr(telephone, 1, 3), '*'), null) telephone,
       username
from ods_user_full
where dt = '2023-05-09';

数据装载脚本
vim ~/bin/medical_ods_to_dim.sh

#!/bin/bash

APP=medical

if [ -n $2 ] ;then
   do_date=$2
else 
   echo 请传入日期参数
   exit
fi 

dim_doctor_full="
insert overwrite table ${APP}.dim_doctor_full
    partition (dt = '$do_date')
select doc.id,
       birthday,
       consultation_fee,
       gender              gender_code,
       gender_dic.value    gender,
       name,
       specialty           specialty_code,
       specialty_dic.value specialty_name,
       title               title_code,
       title_dic.value     title_name,
       hospital_id
from (select id,
             birthday,
             consultation_fee,
             gender,
             concat(substr(name,1,1), regexp_replace(substr(name, 2), '.', '*')) name,
             specialty,
             title,
             hospital_id
      from ${APP}.ods_doctor_full
      where dt = '$do_date') doc
         left join
     (select id,
             value
      from ${APP}.ods_dict_full
      where dt = '$do_date') gender_dic
     on doc.gender = gender_dic.id
         left join
     (select id,
             value
      from ${APP}.ods_dict_full
      where dt = '$do_date') specialty_dic
     on doc.specialty = specialty_dic.id
         left join
     (select id,
             value
      from ${APP}.ods_dict_full
      where dt = '$do_date') title_dic
     on doc.title = title_dic.id;
"

dim_hospital_full="
insert overwrite table ${APP}.dim_hospital_full
    partition (dt = '$do_date')
select id,
       address,
       alias,
       bed_num,
       city,
       department_num,
       district,
       establish_time,
       health_care_num,
       insurance,
       level,
       name,
       province
from ${APP}.ods_hospital_full
where dt = '$do_date';
"

dim_medicine_full="
insert overwrite table ${APP}.dim_medicine_full
    partition (dt = '$do_date')
select id,
       approval_code,
       dose_type,
       name,
       name_en,
       price,
       specs,
       trade_name
from ${APP}.ods_medicine_full
where dt = '$do_date';
"

dim_patient_full="
insert overwrite table ${APP}.dim_patient_full
    partition (dt = '$do_date')
select patient.id,
       birthday,
       gender    gender_code,
       dic.value gender,
       name,
       user_id
from (select id,
             birthday,
             gender,
             concat(substr(name,1,1), regexp_replace(substr(name, 2), '.', '*')) name,
             user_id
      from ${APP}.ods_patient_full
      where dt = '$do_date') patient
         left join
     (select id,
             value
      from ${APP}.ods_dict_full
      where dt = '$do_date') dic
     on patient.gender = dic.id;
"

dim_user_full="
insert overwrite table ${APP}.dim_user_full
    partition (dt = '$do_date')
select id,
       concat('*@', split(email, '@')[1])             email,
       if(telephone regexp '^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\\d{8}$',
          concat(substr(telephone, 1, 3), '*'), null) telephone,
       username
from ${APP}.ods_user_full
where dt = '$do_date';
"

case $1 in
    dim_doctor_full | dim_hospital_full | dim_medicine_full | dim_patient_full | dim_user_full)
    hive -e "${!1}"
    ;;
    "all")
    hive -e "$dim_doctor_full$dim_hospital_full$dim_medicine_full$dim_patient_full$dim_user_full"
    ;;
esac

添加权限
chmod +x ~/bin/medical_ods_to_dim.sh

3.DWD开发

开启动态加载
set hive.exec.dynamic.partition.mode=nonstrict;

交易域问诊事务事实表
建表语句

CREATE EXTERNAL TABLE IF NOT EXISTS dwd_trade_consultation_inc
(
    `id`                STRING COMMENT '问诊ID',
    `consultation_time` STRING comment '问诊时间',
    `consultation_fee`  decimal(16, 2) comment '问诊费用',
    `doctor_id`         STRING comment '医生id',
    `patient_id`        STRING comment '患者ID',
    `user_id`           STRING comment '用户id'
) COMMENT '交易域问诊事务事实表'
    PARTITIONED BY (`dt` STRING)
    STORED AS ORC
    LOCATION '/warehouse/medical/dwd/dwd_trade_consultation_inc/'
    TBLPROPERTIES ('orc.compress' = 'snappy');

交易域问诊支付成功事务事实表
建表语句

CREATE EXTERNAL TABLE IF NOT EXISTS dwd_trade_consultation_pay_suc_inc
(
    `id`                        STRING COMMENT '问诊ID',
    `consultation_pay_suc_time` STRING comment '诊金支付成功时间',
    `consultation_fee`          decimal(16, 2) comment '问诊费用',
    `doctor_id`                 STRING comment '医生ID',
    `patient_id`                STRING comment '患者ID',
    `user_id`                   STRING comment '用户ID'
) COMMENT '交易域问诊支付成功事务事实表'
    PARTITIONED BY (`dt` STRING)
    ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t'
    STORED AS ORC
    LOCATION '/warehouse/medical/dwd/dwd_trade_consultation_pay_suc_inc/'
    TBLPROPERTIES ('orc.compress' = 'snappy');

交易域处方开单事务事实表

CREATE EXTERNAL TABLE IF NOT EXISTS dwd_trade_prescription_inc
(
    `id`                STRING COMMENT '处方明细ID',
    `prescription_time` STRING COMMENT '处方开具时间',
    `count`             BIGINT COMMENT '剂量',
    `medicine_id`       STRING COMMENT '药品ID',
    `prescription_id`   STRING COMMENT '处方ID',
    `total_amount`      DECIMAL(16, 2) COMMENT '处方总金额',
    `consultation_id`   STRING COMMENT '问诊ID',
    `doctor_id`         STRING COMMENT '医生ID',
    `patient_id`        STRING COMMENT '患者ID'
) COMMENT '交易域处方开单事务事实表'
    PARTITIONED BY (`dt` STRING)
    STORED AS ORC
    LOCATION '/warehouse/medical/dwd/dwd_trade_prescription_inc/'
    TBLPROPERTIES ('orc.compress' = 'snappy');

交易域处方开单支付成功事务事实表

CREATE EXTERNAL TABLE IF NOT EXISTS dwd_trade_prescription_pay_suc_inc
(
    `id`                        STRING COMMENT '处方明细ID',
    `prescription_pay_suc_time` STRING COMMENT '处方支付成功时间',
    `count`                     BIGINT COMMENT '剂量',
    `medicine_id`               STRING COMMENT '药品ID',
    `prescription_id`           STRING COMMENT '处方ID',
    `total_amount`              DECIMAL(16, 2) COMMENT '处方总金额',
    `consultation_id`           STRING COMMENT '问诊ID',
    `doctor_id`                 STRING COMMENT '医生ID',
    `patient_id`                STRING COMMENT '患者ID'
) COMMENT '交易域处方开单支付成功事务事实表'
    PARTITIONED BY (`dt` STRING)
    STORED AS ORC
    LOCATION '/warehouse/medical/dwd/dwd_trade_prescription_pay_suc_inc/'
    TBLPROPERTIES ('orc.compress' = 'snappy');

医生域医生注册事务事实表

CREATE EXTERNAL TABLE IF NOT EXISTS dwd_doctor_register_inc
(
    `id`               STRING COMMENT '医生ID',
    `register_time`    STRING COMMENT '注册时间',
    `birthday`         STRING COMMENT '出生日期',
    `consultation_fee` DECIMAL(19, 2) COMMENT '就诊费用',
    `gender_code`      STRING COMMENT '性别编码:101.男 102.女',
    `gender`           STRING COMMENT '性别',
    `name`             STRING COMMENT '姓名',
    `specialty_code`   STRING COMMENT '专业编码:详情见字典表5xx条目',
    `specialty_name`   STRING COMMENT '专业名称',
    `title_code`       STRING COMMENT '职称编码:301. 医士 302. 医师 303. 主治医师 304. 副主任医师 305. 主任医师',
    `title_name`       STRING COMMENT '职称名称',
    `hospital_id`      STRING COMMENT '所属医院'
) COMMENT '医生域医生注册事务事实表'
    PARTITIONED BY (`dt` STRING)
    STORED AS ORC
    LOCATION '/warehouse/medical/dwd/dwd_doctor_register_inc/'
    TBLPROPERTIES ("orc.compress" = "snappy");

用户域用户注册事务事实表

CREATE EXTERNAL TABLE IF NOT EXISTS dwd_user_register_inc
(
    `id`            STRING COMMENT '用户ID',
    `register_time` STRING COMMENT '注册日期',
    `email`         STRING COMMENT '邮箱地址',
    `telephone`     STRING COMMENT '手机号',
    `username`      STRING COMMENT '用户名'
) COMMENT '用户域用户注册事务事实表'
    PARTITIONED BY (`dt` STRING)
    STORED AS ORC
    LOCATION '/warehouse/medical/dwd/dwd_user_register_inc/'
    TBLPROPERTIES ("orc.compress" = "snappy");

用户域患者登记事务事实表

CREATE EXTERNAL TABLE IF NOT EXISTS dwd_user_patient_add_inc
(
    `id`          STRING COMMENT '患者ID',
    `add_time`    STRING COMMENT '登记时间',
    `birthday`    STRING COMMENT '生日',
    `gender_code` STRING COMMENT '性别编码',
    `gender`      STRING COMMENT '性别',
    `name`        STRING COMMENT '姓名',
    `user_id`     STRING COMMENT '所属用户ID'
) COMMENT '用户域患者登记事务事实表'
    PARTITIONED BY (`dt` STRING)
    STORED AS ORC
    LOCATION '/warehouse/medical/dwd/dwd_user_patient_add_inc'
    TBLPROPERTIES ('orc.compress' = 'snappy');

互动域用户评价事务事实表

CREATE EXTERNAL TABLE IF NOT EXISTS dwd_interaction_review_inc
(
    `id`          STRING COMMENT '问诊ID',
    `review_time` STRING COMMENT '评价时间',
    `rating`      STRING COMMENT '评分',
    `doctor_id`   STRING COMMENT '医生ID',
    `patient_id`  STRING COMMENT '病人ID',
    `user_id`     STRING COMMENT '用户ID'
) COMMENT '互动域用户评价事务事实表'
    PARTITIONED BY (`dt` STRING)
    STORED AS ORC
    LOCATION '/warehouse/medical/dwd/dwd_interaction_review_inc'
    TBLPROPERTIES ('orc.compress' = 'snappy');

首日装载脚本
vim ~/bin/medical_ods_to_dwd_init.sh

#!/bin/bash

APP=medical

if [ -n $2 ] 
then 
    do_date=$2
else 
    echo "请传入日期参数!!!"
    exit
fi

dwd_trade_consultation_inc="
set hive.exec.dynamic.partition.mode=nonstrict;
insert overwrite table ${APP}.dwd_trade_consultation_inc
    partition (dt)
select data.id,
       data.create_time                            consultation_time,
       data.consultation_fee,
       data.doctor_id,
       data.patient_id,
       data.user_id,
       date_format(data.create_time, 'yyyy-MM-dd') dt
from ${APP}.ods_consultation_inc
where dt = '$do_date'
  and type = 'bootstrap-insert';
"

dwd_trade_consultation_pay_suc_inc="
set hive.exec.dynamic.partition.mode=nonstrict;
insert overwrite table ${APP}.dwd_trade_consultation_pay_suc_inc
    partition (dt)
select data.id,
       data.update_time                            consultation_pay_suc_time,
       data.consultation_fee,
       data.doctor_id,
       data.patient_id,
       data.user_id,
       date_format(data.create_time, 'yyyy-MM-dd') dt
from ${APP}.ods_consultation_inc
where dt = '$do_date'
  and type = 'bootstrap-insert'
  and data.status <> '201'
  and data.status <> '202';
"

dwd_trade_prescription_inc="
set hive.exec.dynamic.partition.mode=nonstrict;
insert overwrite table ${APP}.dwd_trade_prescription_inc
    partition (dt)
select detail.id,
       prescription_time,
       count,
       medicine_id,
       prescription_id,
       total_amount,
       consultation_id,
       doctor_id,
       patient_id,
       date_format(prescription_time, 'yyyy-MM-dd') dt
from (select data.id,
             data.create_time prescription_time,
             data.count,
             data.medicine_id,
             data.prescription_id
      from ${APP}.ods_prescription_detail_inc
      where dt = '$do_date'
        and type = 'bootstrap-insert') detail
         left join
     (select data.id,
             data.total_amount,
             data.consultation_id,
             data.doctor_id,
             data.patient_id
      from ${APP}.ods_prescription_inc
      where dt = '$do_date'
        and type = 'bootstrap-insert') info
     on detail.prescription_id = info.id;
"

dwd_trade_prescription_pay_suc_inc="
set hive.exec.dynamic.partition.mode=nonstrict;
insert overwrite table ${APP}.dwd_trade_prescription_pay_suc_inc
    partition (dt)
select detail.id,
       prescription_pay_suc_time,
       count,
       medicine_id,
       prescription_id,
       total_amount,
       consultation_id,
       doctor_id,
       patient_id,
       date_format(prescription_pay_suc_time, 'yyyy-MM-dd') dt
from (select data.id,
             data.count,
             data.medicine_id,
             data.prescription_id
      from ${APP}.ods_prescription_detail_inc
      where dt = '$do_date'
        and type = 'bootstrap-insert') detail
         join
     (select data.id,
             data.total_amount,
             data.update_time prescription_pay_suc_time,
             data.consultation_id,
             data.doctor_id,
             data.patient_id
      from ${APP}.ods_prescription_inc
      where dt = '$do_date'
        and type = 'bootstrap-insert'
        and data.status = '203') info
     on detail.prescription_id = info.id;
"

dwd_doctor_register_inc="
set hive.exec.dynamic.partition.mode=nonstrict;
insert overwrite table ${APP}.dwd_doctor_register_inc
    partition (dt)
select doc.id,
       register_time,
       birthday,
       consultation_fee,
       gender_code,
       gender_dic.value                         gender,
       name,
       specialty_code,
       specialty_dic.value                      specialty_name,
       title_code,
       title_dic.value                          title_name,
       hospital_id,
       date_format(register_time, 'yyyy-MM-dd') dt
from (select data.id,
             data.create_time                                                                register_time,
             data.birthday,
             data.consultation_fee,
             data.gender                                                                     gender_code,
             concat(substr(data.name, 1, 1), regexp_replace(substr(data.name, 2), '.', '*')) name,
             data.specialty                                                                  specialty_code,
             data.title                                                                      title_code,
             data.hospital_id
      from ${APP}.ods_doctor_inc
      where dt = '$do_date'
        and type = 'bootstrap-insert') doc
         left join (
    select id,
           value
    from ${APP}.ods_dict_full
    where dt = '$do_date'
) gender_dic
                   on doc.gender_code = gender_dic.id
         left join (
    select id,
           value
    from ${APP}.ods_dict_full
    where dt = '$do_date'
) specialty_dic
                   on doc.specialty_code = specialty_dic.id
         left join (
    select id,
           value
    from ${APP}.ods_dict_full
    where dt = '$do_date'
) title_dic
                   on doc.title_code = title_dic.id;
"

dwd_user_register_inc="
set hive.exec.dynamic.partition.mode=nonstrict;
insert overwrite table ${APP}.dwd_user_register_inc
    partition (dt)
select data.id,
       data.create_time                                    register_time,
       concat('*@', split(data.email, '@')[1])             email,
       if(data.telephone regexp '^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\\d{8}$',
          concat(substr(data.telephone, 1, 3), '*'), null) telephone,
       data.username,
       date_format(data.create_time, 'yyyy-MM-dd')         dt
from ${APP}.ods_user_inc
where dt = '$do_date'
  and type = 'bootstrap-insert';
"

dwd_user_patient_add_inc="
set hive.exec.dynamic.partition.mode=nonstrict;
insert overwrite table ${APP}.dwd_user_patient_add_inc
    partition (dt)
select patient.id,
       add_time,
       birthday,
       gender_code,
       dic.value                           gender,
       name,
       user_id,
       date_format(add_time, 'yyyy-MM-dd') dt
from (select data.id,
             data.create_time add_time,
             data.birthday,
             data.gender      gender_code,
             data.name,
             data.user_id
      from ${APP}.ods_patient_inc
      where dt = '$do_date'
        and type = 'bootstrap-insert') patient
         left join (select id,
                           value
                    from ${APP}.ods_dict_full
                    where dt = '$do_date') dic
                   on patient.gender_code = dic.id;
"

dwd_interaction_review_inc="
set hive.exec.dynamic.partition.mode=nonstrict;
insert overwrite table ${APP}.dwd_interaction_review_inc
    partition (dt)
select data.id,
       data.update_time                            review_time,
       data.rating,
       data.doctor_id,
       data.patient_id,
       data.user_id,
       date_format(data.update_time, 'yyyy-MM-dd') dt
from ${APP}.ods_consultation_inc
where dt = '$do_date'
  and type = 'bootstrap-insert'
  and data.status = '207';
"

case $1 in
    dwd_trade_consultation_inc | dwd_trade_consultation_pay_suc_inc | dwd_trade_prescription_inc | dwd_trade_prescription_pay_suc_inc | dwd_doctor_register_inc | dwd_user_register_inc | dwd_user_patient_add_inc | dwd_interaction_review_inc)
    hive -e "${!1}"
    ;;
    "all")
    hive -e "$dwd_trade_consultation_inc$dwd_trade_consultation_pay_suc_inc$dwd_trade_prescription_inc$dwd_trade_prescription_pay_suc_inc$dwd_doctor_register_inc$dwd_user_register_inc$dwd_user_patient_add_inc$dwd_interaction_review_inc"
    ;;
    "*")
    echo "非法参数!!!"
    ;;
esac

添加权限
chmod +x ~/bin/medical_ods_to_dwd_init.sh
装载数据
medical_ods_to_dwd_init.sh all 2023-05-09
在这里插入图片描述
随便找张表,看看最后的日期是不是05-09
每日装载脚本
vim ~/bin/medical_ods_to_dwd.sh

#!/bin/bash

APP=medical

if [ -n $2 ]
then 
    do_date=$2
else
    echo "请传入日期参数!!!"
    exit
fi


dwd_trade_consultation_inc="
insert overwrite table ${APP}.dwd_trade_consultation_inc
    partition (dt = '$do_date')
select data.id,
       data.create_time consultation_time,
       data.consultation_fee,
       data.doctor_id,
       data.patient_id,
       data.user_id
from ${APP}.ods_consultation_inc
where dt = '$do_date'
  and type = 'insert';
"

dwd_trade_consultation_pay_suc_inc="
insert overwrite table ${APP}.dwd_trade_consultation_pay_suc_inc
    partition (dt = '$do_date')
select data.id,
       data.update_time consultation_pay_suc_time,
       data.consultation_fee,
       data.doctor_id,
       data.patient_id,
       data.user_id
from ${APP}.ods_consultation_inc
where dt = '$do_date'
  and type = 'update'
  and data.status = '203';
"

dwd_trade_prescription_inc="
insert overwrite table ${APP}.dwd_trade_prescription_inc
    partition (dt = '$do_date')
select detail.id,
       prescription_time,
       count,
       medicine_id,
       prescription_id,
       total_amount,
       consultation_id,
       doctor_id,
       patient_id
from (select data.id,
             data.create_time prescription_time,
             data.count,
             data.medicine_id,
             data.prescription_id
      from ${APP}.ods_prescription_detail_inc
      where dt = '$do_date'
        and type = 'insert') detail
         left join
     (select data.id,
             data.total_amount,
             data.consultation_id,
             data.doctor_id,
             data.patient_id
      from ${APP}.ods_prescription_inc
      where dt = '$do_date'
        and type = 'insert') info
     on detail.prescription_id = info.id;
"

dwd_trade_prescription_pay_suc_inc="
insert overwrite table ${APP}.dwd_trade_prescription_pay_suc_inc
    partition (dt = '$do_date')
select detail.id,
       prescription_pay_suc_time,
       count,
       medicine_id,
       prescription_id,
       total_amount,
       consultation_id,
       doctor_id,
       patient_id
from (select data.id,
             data.count,
             data.medicine_id,
             data.prescription_id
      from ${APP}.ods_prescription_detail_inc
      where (dt = '$do_date'
          or dt = date_add('$do_date', -1))
        and (type = 'bootstrap-insert' or
             type = 'insert')) detail
         join
     (select data.id,
             data.total_amount,
             data.update_time prescription_pay_suc_time,
             data.consultation_id,
             data.doctor_id,
             data.patient_id
      from ${APP}.ods_prescription_inc
      where dt = '$do_date'
        and type = 'update'
        and data.status = '203') info
     on detail.prescription_id = info.id;
"

dwd_doctor_register_inc="
insert overwrite table ${APP}.dwd_doctor_register_inc
    partition (dt = '$do_date')
select doc.id,
       register_time,
       birthday,
       consultation_fee,
       gender_code,
       gender_dic.value    gender,
       name,
       specialty_code,
       specialty_dic.value specialty_name,
       title_code,
       title_dic.value     title_name,
       hospital_id
from (select data.id,
             data.create_time                                                                register_time,
             data.birthday,
             data.consultation_fee,
             data.gender                                                                     gender_code,
             concat(substr(data.name, 1, 1), regexp_replace(substr(data.name, 2), '.', '*')) name,
             data.specialty                                                                  specialty_code,
             data.title                                                                      title_code,
             data.hospital_id
      from ${APP}.ods_doctor_inc
      where dt = '$do_date'
        and type = 'insert') doc
         left join (
    select id,
           value
    from ${APP}.ods_dict_full
    where dt = '$do_date'
) gender_dic
                   on doc.gender_code = gender_dic.id
         left join (
    select id,
           value
    from ${APP}.ods_dict_full
    where dt = '$do_date'
) specialty_dic
                   on doc.specialty_code = specialty_dic.id
         left join (
    select id,
           value
    from ${APP}.ods_dict_full
    where dt = '$do_date'
) title_dic
                   on doc.title_code = title_dic.id;
"

dwd_user_register_inc="
insert overwrite table ${APP}.dwd_user_register_inc
    partition (dt = '$do_date')
select data.id,
       data.create_time                                    register_time,
       concat('*@', split(data.email, '@')[1])             email,
       if(data.telephone regexp '^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\\d{8}$',
          concat(substr(data.telephone, 1, 3), '*'), null) telephone,
       data.username
from ${APP}.ods_user_inc
where dt = '$do_date'
  and type = 'insert';
"

dwd_user_patient_add_inc="
insert overwrite table ${APP}.dwd_user_patient_add_inc
    partition (dt = '$do_date')
select patient.id,
       add_time,
       birthday,
       gender_code,
       dic.value gender,
       name,
       user_id
from (select data.id,
             data.create_time add_time,
             data.birthday,
             data.gender      gender_code,
             data.name,
             data.user_id
      from ${APP}.ods_patient_inc
      where dt = '$do_date'
        and type = 'insert') patient
         left join (select id,
                           value
                    from ${APP}.ods_dict_full
                    where dt = '$do_date') dic
                   on patient.gender_code = dic.id;
"

dwd_interaction_review_inc="
insert overwrite table ${APP}.dwd_interaction_review_inc
    partition (dt = '$do_date')
select data.id,
       data.update_time review_time,
       data.rating,
       data.doctor_id,
       data.patient_id,
       data.user_id
from ${APP}.ods_consultation_inc
where dt = '$do_date'
  and type = 'update'
  and data.status = '207';
"

case $1 in
    dwd_trade_consultation_inc | dwd_trade_consultation_pay_suc_inc | dwd_trade_prescription_inc | dwd_trade_prescription_pay_suc_inc | dwd_doctor_register_inc | dwd_user_register_inc | dwd_user_patient_add_inc | dwd_interaction_review_inc)
    hive -e "${!1}"
    ;;
    "all")
    hive -e "$dwd_trade_consultation_inc$dwd_trade_consultation_pay_suc_inc$dwd_trade_prescription_inc$dwd_trade_prescription_pay_suc_inc$dwd_doctor_register_inc$dwd_user_register_inc$dwd_user_patient_add_inc$dwd_interaction_review_inc"
    ;;
    "*")
    echo "非法参数!!!"
    ;;
esac

添加权限
chmod +x ~/bin/medical_ods_to_dwd.sh


总结

数仓开发的代码太多了,还是分两次记录吧。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/956712.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

【跟小嘉学 Rust 编程】二十三、Cargo 使用指南

系列文章目录 【跟小嘉学 Rust 编程】一、Rust 编程基础 【跟小嘉学 Rust 编程】二、Rust 包管理工具使用 【跟小嘉学 Rust 编程】三、Rust 的基本程序概念 【跟小嘉学 Rust 编程】四、理解 Rust 的所有权概念 【跟小嘉学 Rust 编程】五、使用结构体关联结构化数据 【跟小嘉学…

四款简洁好看 自适应的APP下载单页源码

分享四款简洁好看 自适应的APP下载单页源码&#xff0c;采用了底部自动获取ICP备案号&#xff0c;还有蓝奏云文件直链解析。不光可以做APP下载引导页&#xff0c;也可以随便改下按钮做网站引导页&#xff0c;自由发挥即可&#xff01; 蓝奏云直链解析的好处&#xff1a;APP放在…

交换机之间用管理vlan互联,并用ACL进行管控的实例

交换机之间用管理vlan互联&#xff0c;用网管机可以对其进行运维&#xff0c; 拓朴描述&#xff1a; 网关起在S2上&#xff0c;管理vlan999&#xff0c;IP&#xff1a;1.1.1.1/30&#xff0c;lookback 0 地址用2.2.2.2/32当做外网接口IP S1上&#xff1a;管理vlan999&#x…

多线程与高并发——并发编程(3)

文章目录 三、锁1 锁的分类1.1 可重入锁、不可重入锁1.2 乐观锁、悲观锁1.3 公平锁、非公平锁1.4 互斥锁、共享锁2 深入synchronized2.1 类锁、对象锁2.2 synchronized的优化2.3 synchronized实现原理2.4 synchronized的锁升级2.5 重量级锁底层 ObjectMonitor3 深入ReentrantLo…

家政保洁行业小程序如何快速搭建

随着互联网的快速发展&#xff0c;家政保洁行业也逐渐向数字化转型。小程序作为一种轻量级应用&#xff0c;越来越成为各行各业进行线上推广的重要工具。那么&#xff0c;如何快速搭建家政保洁行业的小程序呢&#xff1f;本文将为你提供详细的步骤和指导。 一、准备开发环境 在…

合宙Air724UG LuatOS-Air LVGL API控件--容器 (Container)

容器 (Container) 容器是 lvgl 相当重要的一个控件了&#xff0c;可以设置布局&#xff0c;容器的大小也会自动进行调整&#xff0c;利用容器可以创建出自适应成都很高的界面布局。 代码示例 – 创建容器 cont lvgl.cont_create(lvgl.scr_act(), nil) lvgl.obj_set_auto_re…

第 3 章 栈和队列(用递归函数求解迷宫问题(求出所有解))

1. 背景说明&#xff1a; 若迷宫 maze 中存在从入口 start 到出口 end 的通道&#xff0c;则求出所有合理解并求出最优解 迷宫示意图&#xff1a; 输入文本&#xff1a; 10 10181 3 1 7 2 3 2 7 3 5 3 6 4 2 4 3 4 4 5 4 6 2 6 6 7 2 7 3 7 4 7 6 7 7 8 11 18 8 2. 示例代码…

Ae 效果:CC Threads

生成/CC Threads Generate/CC Threads CC Threads&#xff08;CC 编织条&#xff09;效果基于当前图层像素生成编织条图案和纹理。可以用在各种设计中&#xff0c;如背景设计、图形设计、文字设计等。 ◆ ◆ ◆ 效果属性说明 Width 宽度 设置编织的宽度。 默认值为 50。值越大…

【计算机组成 课程笔记】3.1 算数运算和逻辑运算

课程链接&#xff1a; 计算机组成_北京大学_中国大学MOOC(慕课) 3 - 1 - 301-算术运算和逻辑运算&#xff08;13-7--&#xff09;_哔哩哔哩_bilibili 计算机的核心功能就是运算&#xff0c;运算的基本类型包括算数运算和逻辑运算。想要了解计算机是如何实现运算的&#xff0c;我…

linux免密登录报错 Bad owner or permissions on /etc/ssh/ssh_config.d/05-redhat.conf

问题&#xff1a;权限不对的 解决&#xff1a; 1.检查文件的所有者和权限。 确保文件的所有者是正确的。 运行以下命令来确定文件的所有者和权限&#xff1a; ls -l /etc/ssh/ssh_config.d/05-redhat.conf 通常情况下&#xff0c;SSH配置文件应该属于root用户。如果所有者不是…

HDLBits 练习 Always if2

Always if2 一个常见的错误&#xff1a;如何避免产生锁存器。 当设计一的电路的时候&#xff0c;你首先应该从电路的角度去思考。 我想要一个逻辑门我想要一个有着3和输入和3输出的组合逻辑电路。我想要一个后边跟着一个触发器的组合逻辑电路。 你必须不能先写代码&#xf…

VC++6.0下载安装使用教程

一、前言 微软原版的 VC6.0 已经不容易找到&#xff0c;网上提供的都是经过第三方修改的版本&#xff0c;删除了一些使用不到的功能&#xff0c;增强了兼容性。这里我们使用 VC6.0 完整绿色版&#xff0c;它能够支持一般的 C/C 应用程序开发以及计算机二级考试。 二、VC6.0 下…

设计模式大白话——适配器模式

适配器模式 概述示例适配器的种类小结 概述 ​ 适配器其实非常好理解&#xff0c;放到生活中来&#xff0c;我们身边处处都有这样的例子&#xff0c;最常见的是用的比较多的各种转接线&#xff08;如&#xff1a;USB 转 Type-C&#xff09;&#xff0c;有了这个“适配器”&…

基于 kube-vip 部署 kubernetes 高可用集群

kube-vip 简介 kube-vip 是一个开源项目&#xff0c;旨在简化为 Kubernetes 集群提供负载均衡服务。 kube-vip 为 Kubernetes 集群提供虚拟 IP 和负载均衡器&#xff0c;用于控制平面&#xff08;用于构建高可用集群&#xff09;和 Kubernetes 服务类型&#xff0c;而无需依赖…

智己 LS6 用实力和你卷,最强 800v ?

2023 成都车展期间&#xff0c;智己 LS6 正式公布预售价格&#xff0c;新车预售价为 23-30 万元。新车会在 10 月份进行上市&#xff0c;11 月正式交付。 此前我们对智己 LS6 做过非常详细的静态体验&#xff0c;感兴趣的可点击此链接了解。 造型方面&#xff0c;新车前脸相比…

CNN(六):ResNeXt-50实战

&#x1f368; 本文为&#x1f517;365天深度学习训练营中的学习记录博客&#x1f356; 原作者&#xff1a;K同学啊|接辅导、项目定制 ResNeXt是有何凯明团队在2017年CVPR会议上提出来的新型图像分类网络。它是ResNet的升级版&#xff0c;在ResNet的基础上&#xff0c;引入了ca…

【C++】VS配置OpenCV/Libtorch环境

前言 本文是视频https://www.bilibili.com/video/BV1dp4y177L4的笔记。 OpenCV和Libtorch安装包&#xff1a;https://pan.baidu.com/s/1i3DqTcHFSC1rRDsIgYGCsQ?pwd8888 VS版本&#xff1a;2019 Opencv版本&#xff1a;3.4.1 Libtorch版本&#xff1a;2.0.1cu117 配置Open…

CUBLAS库入门教程(从环境配置讲起)

文章目录 前言一、搭建环境二、简单介绍三、 具体例子四、疑问 前言 CUBLAS库是NVIDIA CUDA用于线性代数计算的库。使用CUBLAS库的原因是我不想去直接写核函数。 &#xff08;当然&#xff0c;你还是得学习核函数该怎么写。但是人家写好的肯定比我自己写的更准确&#xff01;&…

利用MarkovJunior方法生成迷宫和图形的MATLAB演示[迷宫生成、贪吃蛇、地图生成、图案生成]

利用MarkovJunior方法生成迷宫和图形的MATLAB演示[迷宫生成、贪吃蛇、地图生成、图案生成] 0 前言1 介绍MarkovJunior2 迷宫生成2.1 深度优先迷宫生成2.2 广度优先迷宫生成 3 其它生成图案3.1 地牢地图3.2 贪吃蛇3.3 植物花 惯例声明&#xff1a;本人没有相关的工程应用经验&am…

Python爬虫抓取经过JS加密的API数据的实现步骤

随着互联网的快速发展&#xff0c;越来越多的网站和应用程序提供了API接口&#xff0c;方便开发者获取数据。然而&#xff0c;为了保护数据的安全性和防止漏洞&#xff0c;一些API接口采用了JS加密技术这种加密技术使得数据在传输过程中更加安全&#xff0c;但也给爬虫开发带来…