当前位置: 首页 > news >正文

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

系列文章目录

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


文章目录

  • 系列文章目录
  • 前言
  • 一、DWS
    • 1.最近1日汇总表
      • 1.交易域医院患者性别年龄段粒度问诊最近1日汇总表
      • 2.交易域医院患者性别年龄段粒度问诊支付成功最近1日汇总表
      • 3.交易域医院患者性别年龄段粒度处方开单最近1日汇总表
      • 4.交易域医院患者性别年龄段粒度处方开单支付成功最近1日汇总表
      • 5.交易域医生粒度问诊最近1日汇总表
      • 6.首日装载脚本
      • 7.每日数据装载
    • 2.最近n日汇总表
      • 1.交易域医院患者性别年龄段粒度问诊最近n日汇总表
      • 2.交易域医院患者性别年龄段粒度问诊支付成功最近n日汇总表
      • 3.交易域医院患者性别年龄段粒度处方开单最近n日汇总表
      • 4.交易域医院患者性别年龄段粒度处方开单支付成功最近n日汇总表
      • 5.交易域医生粒度问诊最近n日汇总表
      • 6.首日装载脚本
    • 3.历史至今汇总表
      • 1.交易域医生粒度问诊历史至今汇总表
      • 2.互动域医院用户粒度用户评价历史至今汇总表
      • 3.互动域医院粒度用户评价历史至今汇总表
      • 4.首日数据装载
      • 5.每日数据装载
  • 总结


前言

我们这次博客继续完成数仓的开发


一、DWS

1.最近1日汇总表

1.交易域医院患者性别年龄段粒度问诊最近1日汇总表

建表语句

CREATE EXTERNAL TABLE IF NOT EXISTS dws_trade_hospital_gender_age_group_consultation_1d
(`hospital_id`         STRING COMMENT '医院ID',`hospital_name`       STRING COMMENT '医院名称',`gender_code`         STRING COMMENT '患者性别编码',`gender`              STRING COMMENT '患者性别',`age_group`           STRING COMMENT '年龄段:[0,2]婴儿期, [3,5]幼儿期, [6,11]小学阶段, [12,17]青少年期(中学阶段), [18-29]青年期, [30-59]中年期, [60-122]老年期',`consultation_amount` DECIMAL(16, 2) COMMENT '问诊金额',`consultation_count`  BIGINT COMMENT '问诊次数'
) COMMENT '交易域医院患者性别年龄段粒度问诊最近1日汇总表'PARTITIONED BY (`dt` STRING)STORED AS ORCLOCATION '/warehouse/medical/dws/dws_trade_hospital_gender_age_group_consultation_1d'TBLPROPERTIES ('orc.compress' = 'snappy');

2.交易域医院患者性别年龄段粒度问诊支付成功最近1日汇总表

建表语句

CREATE EXTERNAL TABLE IF NOT EXISTS dws_trade_hospital_gender_age_group_consultation_pay_suc_1d
(`hospital_id`                 STRING COMMENT '医院ID',`hospital_name`               STRING COMMENT '医院名称',`gender_code`                 STRING COMMENT '患者性别编码',`gender`                      STRING COMMENT '患者性别',`age_group`                   STRING COMMENT '年龄段:[0,2]婴儿期, [3,5]幼儿期, [6,11]小学阶段, [12,17]青少年期(中学阶段), [18-29]青年期, [30-59]中年期, [60-]老年期',`consultation_pay_suc_amount` DECIMAL(16, 2) COMMENT '问诊支付成功金额',`consultation_pay_suc_count`  BIGINT COMMENT '问诊支付成功次数'
) COMMENT '交易域医院患者性别年龄段粒度问诊支付成功最近1日汇总表'PARTITIONED BY (`dt` STRING)STORED AS ORCLOCATION '/warehouse/medical/dws/dws_trade_hospital_gender_age_group_consultation_pay_suc_1d'TBLPROPERTIES ('orc.compress' = 'snappy');

3.交易域医院患者性别年龄段粒度处方开单最近1日汇总表

建表语句

CREATE EXTERNAL TABLE IF NOT EXISTS dws_trade_hospital_gender_age_group_prescription_1d
(`hospital_id`                 STRING COMMENT '医院ID',`hospital_name`               STRING COMMENT '医院名称',`gender_code`                 STRING COMMENT '患者性别编码',`gender`                      STRING COMMENT '患者性别',`age_group`                   STRING COMMENT '年龄段:[0,2]婴儿期, [3,5]幼儿期, [6,11]小学阶段, [12,17]青少年期(中学阶段), [18-29]青年期, [30-59]中年期, [60-]老年期',`prescription_amount` DECIMAL(16, 2) COMMENT '处方开单金额',`prescription_count`  BIGINT COMMENT '处方开单次数'
) COMMENT '交易域医院患者性别年龄段粒度处方开单最近1日汇总表'PARTITIONED BY (`dt` STRING)STORED AS ORCLOCATION '/warehouse/medical/dws/dws_trade_hospital_gender_age_group_prescription_1d'TBLPROPERTIES ('orc.compress' = 'snappy');

4.交易域医院患者性别年龄段粒度处方开单支付成功最近1日汇总表

建表语句

CREATE EXTERNAL TABLE IF NOT EXISTS dws_trade_hospital_gender_age_group_prescription_pay_suc_1d
(`hospital_id`                 STRING COMMENT '医院ID',`hospital_name`               STRING COMMENT '医院名称',`gender_code`                 STRING COMMENT '患者性别编码',`gender`                      STRING COMMENT '患者性别',`age_group`                   STRING COMMENT '年龄段:[0,2]婴儿期, [3,5]幼儿期, [6,11]小学阶段, [12,17]青少年期(中学阶段), [18-29]青年期, [30-59]中年期, [60-]老年期',`prescription_pay_suc_amount` DECIMAL(16, 2) COMMENT '处方开单支付成功金额',`prescription_pay_suc_count`  BIGINT COMMENT '处方开单支付成功次数'
) COMMENT '交易域医院患者性别年龄段粒度处方开单支付成功最近1日汇总表'PARTITIONED BY (`dt` STRING)STORED AS ORCLOCATION '/warehouse/medical/dws/dws_trade_hospital_gender_age_group_prescription_pay_suc_1d'TBLPROPERTIES ('orc.compress' = 'snappy');

5.交易域医生粒度问诊最近1日汇总表

建表语句

CREATE EXTERNAL TABLE IF NOT EXISTS dws_trade_doctor_consultation_1d
(`doctor_id`                 STRING COMMENT '医生ID',`doctor_name`               STRING COMMENT '医生姓名',`consultation_count`  BIGINT COMMENT '接诊次数'
) COMMENT '交易域医生粒度问诊最近1日汇总表'PARTITIONED BY (`dt` STRING)STORED AS ORCLOCATION '/warehouse/medical/dws/dws_trade_doctor_consultation_1d'TBLPROPERTIES ('orc.compress' = 'snappy');

6.首日装载脚本

vim ~/bin/medical_dwd_to_dws_1d_init.sh

#!/bin/bashAPP=medicalif [ -n $2 ]
then do_date=$2
elseecho "请传入日期参数!!!"exit
fidws_trade_hospital_gender_age_group_consultation_1d="
set hive.exec.dynamic.partition.mode=nonstrict;
insert overwrite table ${APP}.dws_trade_hospital_gender_age_group_consultation_1dpartition (dt)
select hospital_id,hospital_name,gender_code,gender,age_group,sum(consultation_fee) consultation_amount,count(*)              consultation_count,dt
from (select hospital_id,hospital_name,gender_code,gender,casewhen age >= 0 and age <= 2 then '婴儿期'when age >= 3 and age <= 5 then '幼儿期'when age >= 6 and age <= 11 then '小学阶段'when age >= 12 and age <= 17 then '青少年期(中学阶段)'when age >= 18 and age <= 29 then '青年期'when age >= 30 and age <= 59 then '中年期'when age >= 60 and age <= 122 then '老年期'else '年龄异常' end age_group,consultation_fee,dtfrom (select doctor_id,patient_id,consultation_fee,dtfrom ${APP}.dwd_trade_consultation_inc) consulleft join(select id,hospital_idfrom ${APP}.dim_doctor_fullwhere dt = '$do_date') docon doctor_id = doc.idleft join (select id,name hospital_namefrom ${APP}.dim_hospital_fullwhere dt = '$do_date') hoson doc.hospital_id = hos.idleft join(select id,gender_code,gender,year('$do_date') - year(birthday) agefrom ${APP}.dim_patient_fullwhere dt = '$do_date') patienton patient_id = patient.id) with_group
group by hospital_id,hospital_name,gender_code,gender,age_group,dt;
"dws_trade_hospital_gender_age_group_consultation_pay_suc_1d="
set hive.exec.dynamic.partition.mode=nonstrict;
insert overwrite table ${APP}.dws_trade_hospital_gender_age_group_consultation_pay_suc_1dpartition (dt)
select hospital_id,hospital_name,gender_code,gender,age_group,sum(consultation_fee) consultation_pay_suc_amount,count(*)              consultation_pay_suc_count,dt
from (select hospital_id,hospital_name,gender_code,gender,casewhen age >= 0 and age <= 2 then '婴儿期'when age >= 3 and age <= 5 then '幼儿期'when age >= 6 and age <= 11 then '小学阶段'when age >= 12 and age <= 17 then '青少年期(中学阶段)'when age >= 18 and age <= 29 then '青年期'when age >= 30 and age <= 59 then '中年期'when age >= 60 and age <= 122 then '老年期'else '年龄异常' end age_group,consultation_fee,dtfrom (select doctor_id,patient_id,consultation_fee,dtfrom ${APP}.dwd_trade_consultation_pay_suc_inc) consulleft join(select id,hospital_idfrom ${APP}.dim_doctor_fullwhere dt = '$do_date') docon doctor_id = doc.idleft join (select id,name hospital_namefrom ${APP}.dim_hospital_fullwhere dt = '$do_date') hoson doc.hospital_id = hos.idleft join(select id,gender_code,gender,year('$do_date') - year(birthday) agefrom ${APP}.dim_patient_fullwhere dt = '$do_date') patienton patient_id = patient.id) with_group
group by hospital_id,hospital_name,gender_code,gender,age_group,dt;
"dws_trade_hospital_gender_age_group_prescription_1d="
set hive.exec.dynamic.partition.mode=nonstrict;
insert overwrite table ${APP}.dws_trade_hospital_gender_age_group_prescription_1dpartition (dt)
select hospital_id,hospital_name,gender_code,gender,age_group,sum(total_amount) prescription_amount,count(*)          prescription_count,dt
from (select hospital_id,hospital_name,gender_code,gender,casewhen age >= 0 and age <= 2 then '婴儿期'when age >= 3 and age <= 5 then '幼儿期'when age >= 6 and age <= 11 then '小学阶段'when age >= 12 and age <= 17 then '青少年期(中学阶段)'when age >= 18 and age <= 29 then '青年期'when age >= 30 and age <= 59 then '中年期'when age >= 60 and age <= 122 then '老年期'else '年龄异常' end age_group,total_amount,dtfrom (select max(doctor_id)    doctor_id,max(patient_id)   patient_id,max(total_amount) total_amount,max(dt)           dtfrom ${APP}.dwd_trade_prescription_incgroup by prescription_id) prescrleft join(select id,hospital_idfrom ${APP}.dim_doctor_fullwhere dt = '$do_date') docon doctor_id = doc.idleft join (select id,name hospital_namefrom ${APP}.dim_hospital_fullwhere dt = '$do_date') hoson doc.hospital_id = hos.idleft join(select id,gender_code,gender,year('$do_date') - year(birthday) agefrom ${APP}.dim_patient_fullwhere dt = '$do_date') patienton patient_id = patient.id) with_group
group by hospital_id,hospital_name,gender_code,gender,age_group,dt;
"dws_trade_hospital_gender_age_group_prescription_pay_suc_1d="
set hive.exec.dynamic.partition.mode=nonstrict;
insert overwrite table ${APP}.dws_trade_hospital_gender_age_group_prescription_pay_suc_1dpartition (dt)
select hospital_id,hospital_name,gender_code,gender,age_group,sum(total_amount) prescription_pay_suc_amount,count(*)          prescription_pay_suc_count,dt
from (select hospital_id,hospital_name,gender_code,gender,casewhen age >= 0 and age <= 2 then '婴儿期'when age >= 3 and age <= 5 then '幼儿期'when age >= 6 and age <= 11 then '小学阶段'when age >= 12 and age <= 17 then '青少年期(中学阶段)'when age >= 18 and age <= 29 then '青年期'when age >= 30 and age <= 59 then '中年期'when age >= 60 and age <= 122 then '老年期'else '年龄异常' end age_group,total_amount,dtfrom (select max(doctor_id)    doctor_id,max(patient_id)   patient_id,max(total_amount) total_amount,max(dt)           dtfrom ${APP}.dwd_trade_prescription_pay_suc_incgroup by prescription_id) prescrleft join(select id,hospital_idfrom ${APP}.dim_doctor_fullwhere dt = '$do_date') docon doctor_id = doc.idleft join (select id,name hospital_namefrom ${APP}.dim_hospital_fullwhere dt = '$do_date') hoson doc.hospital_id = hos.idleft join(select id,gender_code,gender,year('$do_date') - year(birthday) agefrom ${APP}.dim_patient_fullwhere dt = '$do_date') patienton patient_id = patient.id) with_group
group by hospital_id,hospital_name,gender_code,gender,age_group,dt;
"dws_trade_doctor_consultation_1d="
set hive.exec.dynamic.partition.mode=nonstrict;
insert overwrite table ${APP}.dws_trade_doctor_consultation_1dpartition (dt)
select doctor_id,name doctor_name,consultation_count,dt
from (select doctor_id,dt,count(*) consultation_countfrom ${APP}.dwd_trade_consultation_incgroup by doctor_id,dt) avgleft join (select id,namefrom ${APP}.dim_doctor_fullwhere dt = '$do_date') docon avg.doctor_id = doc.id;
"case $1 indws_trade_hospital_gender_age_group_consultation_1d | dws_trade_hospital_gender_age_group_consultation_pay_suc_1d | dws_trade_hospital_gender_age_group_prescription_1d | dws_trade_hospital_gender_age_group_prescription_pay_suc_1d | dws_trade_doctor_consultation_1d)hive -e "${!1}";;"all")hive -e "$dws_trade_hospital_gender_age_group_consultation_1d$dws_trade_hospital_gender_age_group_consultation_pay_suc_1d$dws_trade_hospital_gender_age_group_prescription_1d$dws_trade_hospital_gender_age_group_prescription_pay_suc_1d$dws_trade_doctor_consultation_1d";;
esac

添加权限
chmod +x ~/bin/medical_dwd_to_dws_1d_init.sh
数据载入
medical_dwd_to_dws_1d_init.sh all 2023-05-09
在这里插入图片描述
随便找一个查看一下最后的日期

7.每日数据装载

vim ~/bin/medical_dwd_to_dws_1d.sh

#!/bin/bashAPP=medicalif [ -n $2 ]
then do_date=$2
elseecho "请传入日期参数!!!"exit
fidws_trade_hospital_gender_age_group_consultation_1d="
insert overwrite table ${APP}.dws_trade_hospital_gender_age_group_consultation_1dpartition (dt = '$do_date')
select hospital_id,hospital_name,gender_code,gender,age_group,sum(consultation_fee) consultation_amount,count(*)              consultation_count
from (select hospital_id,hospital_name,gender_code,gender,casewhen age >= 0 and age <= 2 then '婴儿期'when age >= 3 and age <= 5 then '幼儿期'when age >= 6 and age <= 11 then '小学阶段'when age >= 12 and age <= 17 then '青少年期(中学阶段)'when age >= 18 and age <= 29 then '青年期'when age >= 30 and age <= 59 then '中年期'when age >= 60 and age <= 122 then '老年期'else '年龄异常' end age_group,consultation_feefrom (select doctor_id,patient_id,consultation_feefrom ${APP}.dwd_trade_consultation_incwhere dt = '$do_date') consulleft join(select id,hospital_idfrom ${APP}.dim_doctor_fullwhere dt = '$do_date') docon doctor_id = doc.idleft join (select id,name hospital_namefrom ${APP}.dim_hospital_fullwhere dt = '$do_date') hoson doc.hospital_id = hos.idleft join(select id,gender_code,gender,year('$do_date') - year(birthday) agefrom ${APP}.dim_patient_fullwhere dt = '$do_date') patienton patient_id = patient.id) with_group
group by hospital_id,hospital_name,gender_code,gender,age_group;"dws_trade_hospital_gender_age_group_consultation_pay_suc_1d="
insert overwrite table ${APP}.dws_trade_hospital_gender_age_group_consultation_pay_suc_1dpartition (dt = '$do_date')
select hospital_id,hospital_name,gender_code,gender,age_group,sum(consultation_fee) consultation_pay_suc_amount,count(*)              consultation_pay_suc_count
from (select hospital_id,hospital_name,gender_code,gender,casewhen age >= 0 and age <= 2 then '婴儿期'when age >= 3 and age <= 5 then '幼儿期'when age >= 6 and age <= 11 then '小学阶段'when age >= 12 and age <= 17 then '青少年期(中学阶段)'when age >= 18 and age <= 29 then '青年期'when age >= 30 and age <= 59 then '中年期'when age >= 60 and age <= 122 then '老年期'else '年龄异常' end age_group,consultation_feefrom (select doctor_id,patient_id,consultation_feefrom ${APP}.dwd_trade_consultation_pay_suc_incwhere dt = '$do_date') consulleft join(select id,hospital_idfrom ${APP}.dim_doctor_fullwhere dt = '$do_date') docon doctor_id = doc.idleft join (select id,name hospital_namefrom ${APP}.dim_hospital_fullwhere dt = '$do_date') hoson doc.hospital_id = hos.idleft join(select id,gender_code,gender,year('$do_date') - year(birthday) agefrom ${APP}.dim_patient_fullwhere dt = '$do_date') patienton patient_id = patient.id) with_group
group by hospital_id,hospital_name,gender_code,gender,age_group;"dws_trade_hospital_gender_age_group_prescription_1d="
insert overwrite table ${APP}.dws_trade_hospital_gender_age_group_prescription_1dpartition (dt = '$do_date')
select hospital_id,hospital_name,gender_code,gender,age_group,sum(total_amount) prescription_amount,count(*)          prescription_count
from (select hospital_id,hospital_name,gender_code,gender,casewhen age >= 0 and age <= 2 then '婴儿期'when age >= 3 and age <= 5 then '幼儿期'when age >= 6 and age <= 11 then '小学阶段'when age >= 12 and age <= 17 then '青少年期(中学阶段)'when age >= 18 and age <= 29 then '青年期'when age >= 30 and age <= 59 then '中年期'when age >= 60 and age <= 122 then '老年期'else '年龄异常' end age_group,total_amountfrom (select max(doctor_id)    doctor_id,max(patient_id)   patient_id,max(total_amount) total_amountfrom ${APP}.dwd_trade_prescription_incwhere dt = '$do_date'group by prescription_id) prescrleft join(select id,hospital_idfrom ${APP}.dim_doctor_fullwhere dt = '$do_date') docon doctor_id = doc.idleft join (select id,name hospital_namefrom ${APP}.dim_hospital_fullwhere dt = '$do_date') hoson doc.hospital_id = hos.idleft join(select id,gender_code,gender,year('$do_date') - year(birthday) agefrom ${APP}.dim_patient_fullwhere dt = '$do_date') patienton patient_id = patient.id) with_group
group by hospital_id,hospital_name,gender_code,gender,age_group;"dws_trade_hospital_gender_age_group_prescription_pay_suc_1d="
insert overwrite table ${APP}.dws_trade_hospital_gender_age_group_prescription_pay_suc_1dpartition (dt = '$do_date')
select hospital_id,hospital_name,gender_code,gender,age_group,sum(total_amount) prescription_pay_suc_amount,count(*)          prescription_pay_suc_count
from (select hospital_id,hospital_name,gender_code,gender,casewhen age >= 0 and age <= 2 then '婴儿期'when age >= 3 and age <= 5 then '幼儿期'when age >= 6 and age <= 11 then '小学阶段'when age >= 12 and age <= 17 then '青少年期(中学阶段)'when age >= 18 and age <= 29 then '青年期'when age >= 30 and age <= 59 then '中年期'when age >= 60 and age <= 122 then '老年期'else '年龄异常' end age_group,total_amountfrom (select max(doctor_id)    doctor_id,max(patient_id)   patient_id,max(total_amount) total_amountfrom ${APP}.dwd_trade_prescription_incwhere dt = '$do_date'group by prescription_id) prescrleft join(select id,hospital_idfrom ${APP}.dim_doctor_fullwhere dt = '$do_date') docon doctor_id = doc.idleft join (select id,name hospital_namefrom ${APP}.dim_hospital_fullwhere dt = '$do_date') hoson doc.hospital_id = hos.idleft join(select id,gender_code,gender,year('$do_date') - year(birthday) agefrom ${APP}.dim_patient_fullwhere dt = '$do_date') patienton patient_id = patient.id) with_group
group by hospital_id,hospital_name,gender_code,gender,age_group;"dws_trade_doctor_consultation_1d="
insert overwrite table ${APP}.dws_trade_doctor_consultation_1dpartition (dt = '$do_date')
select doctor_id,name doctor_name,consultation_count
from (select doctor_id,count(*) consultation_countfrom ${APP}.dwd_trade_consultation_incwhere dt = '$do_date'group by doctor_id) avgleft join (select id,namefrom ${APP}.dim_doctor_fullwhere dt = '$do_date') docon avg.doctor_id = doc.id;"case $1 indws_trade_hospital_gender_age_group_consultation_1d | dws_trade_hospital_gender_age_group_consultation_pay_suc_1d | dws_trade_hospital_gender_age_group_prescription_1d | dws_trade_hospital_gender_age_group_prescription_pay_suc_1d | dws_trade_doctor_consultation_1d)hive -e "${!1}";;"all")hive -e "$dws_trade_hospital_gender_age_group_consultation_1d$dws_trade_hospital_gender_age_group_consultation_pay_suc_1d$dws_trade_hospital_gender_age_group_prescription_1d$dws_trade_hospital_gender_age_group_prescription_pay_suc_1d$dws_trade_doctor_consultation_1d";;
esac

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

2.最近n日汇总表

1.交易域医院患者性别年龄段粒度问诊最近n日汇总表

建表语句

CREATE EXTERNAL TABLE IF NOT EXISTS dws_trade_hospital_gender_age_group_consultation_nd
(`hospital_id`             STRING COMMENT '医院ID',`hospital_name`           STRING COMMENT '医院名称',`gender_code`             STRING COMMENT '患者性别编码',`gender`                  STRING COMMENT '患者性别',`age_group`               STRING COMMENT '年龄段:[0,2]婴儿期, [3,5]幼儿期, [6,11]小学阶段, [12,17]青少年期(中学阶段), [18-29]青年期, [30-59]中年期, [60-122]老年期',`consultation_amount_7d`  DECIMAL(16, 2) COMMENT '最近 7 日问诊金额',`consultation_count_7d`   BIGINT COMMENT '最近 7 日问诊次数',`consultation_amount_30d` DECIMAL(16, 2) COMMENT '最近 30 日问诊金额',`consultation_count_30d`  BIGINT COMMENT '最近 30 日问诊次数'
) COMMENT '交易域医院患者性别年龄段粒度问诊最近n日汇总表'PARTITIONED BY (`dt` STRING)STORED AS ORCLOCATION '/warehouse/medical/dws/dws_trade_hospital_gender_age_group_consultation_nd'TBLPROPERTIES ('orc.compress' = 'snappy');

2.交易域医院患者性别年龄段粒度问诊支付成功最近n日汇总表

建表语句

CREATE EXTERNAL TABLE IF NOT EXISTS dws_trade_hospital_gender_age_group_consultation_pay_suc_nd
(`hospital_id`                 STRING COMMENT '医院ID',`hospital_name`               STRING COMMENT '医院名称',`gender_code`                 STRING COMMENT '患者性别编码',`gender`                      STRING COMMENT '患者性别',`age_group`                   STRING COMMENT '年龄段:[0,2]婴儿期, [3,5]幼儿期, [6,11]小学阶段, [12,17]青少年期(中学阶段), [18-29]青年期, [30-59]中年期, [60-]老年期',`consultation_pay_suc_amount_7d` DECIMAL(16, 2) COMMENT '最近 7 日问诊支付成功金额',`consultation_pay_suc_count_7d`  BIGINT COMMENT '最近 7 日问诊支付成功次数',`consultation_pay_suc_amount_30d` DECIMAL(16, 2) COMMENT '最近 30 日问诊支付成功金额',`consultation_pay_suc_count_30d`  BIGINT COMMENT '最近 30 日问诊支付成功次数'
) COMMENT '交易域医院患者性别年龄段粒度问诊支付成功最近n日汇总表'PARTITIONED BY (`dt` STRING)STORED AS ORCLOCATION '/warehouse/medical/dws/dws_trade_hospital_gender_age_group_consultation_pay_suc_nd'TBLPROPERTIES ('orc.compress' = 'snappy');

3.交易域医院患者性别年龄段粒度处方开单最近n日汇总表

建表语句

CREATE EXTERNAL TABLE IF NOT EXISTS dws_trade_hospital_gender_age_group_prescription_nd
(`hospital_id`                 STRING COMMENT '医院ID',`hospital_name`               STRING COMMENT '医院名称',`gender_code`                 STRING COMMENT '患者性别编码',`gender`                      STRING COMMENT '患者性别',`age_group`                   STRING COMMENT '年龄段:[0,2]婴儿期, [3,5]幼儿期, [6,11]小学阶段, [12,17]青少年期(中学阶段), [18-29]青年期, [30-59]中年期, [60-]老年期',`prescription_amount_7d` DECIMAL(16, 2) COMMENT '最近 7 日处方开单金额',`prescription_count_7d`  BIGINT COMMENT '最近 7 日处方开单次数',`prescription_amount_30d` DECIMAL(16, 2) COMMENT '最近 30 日处方开单金额',`prescription_count_30d`  BIGINT COMMENT '最近 30 日处方开单次数'
) COMMENT '交易域医院患者性别年龄段粒度处方开单最近n日汇总表'PARTITIONED BY (`dt` STRING)STORED AS ORCLOCATION '/warehouse/medical/dws/dws_trade_hospital_gender_age_group_prescription_nd'TBLPROPERTIES ('orc.compress' = 'snappy');

4.交易域医院患者性别年龄段粒度处方开单支付成功最近n日汇总表

建表语句

CREATE EXTERNAL TABLE IF NOT EXISTS dws_trade_hospital_gender_age_group_prescription_pay_suc_nd
(`hospital_id`                 STRING COMMENT '医院ID',`hospital_name`               STRING COMMENT '医院名称',`gender_code`                 STRING COMMENT '患者性别编码',`gender`                      STRING COMMENT '患者性别',`age_group`                   STRING COMMENT '年龄段:[0,2]婴儿期, [3,5]幼儿期, [6,11]小学阶段, [12,17]青少年期(中学阶段), [18-29]青年期, [30-59]中年期, [60-]老年期',`prescription_pay_suc_amount_7d` DECIMAL(16, 2) COMMENT '最近 7 日处方开单支付成功金额',`prescription_pay_suc_count_7d`  BIGINT COMMENT '最近 7 日处方开单支付成功次数',`prescription_pay_suc_amount_30d` DECIMAL(16, 2) COMMENT '最近 30 日处方开单支付成功金额',`prescription_pay_suc_count_30d`  BIGINT COMMENT '最近 30 日处方开单支付成功次数'
) COMMENT '交易域医院患者性别年龄段粒度处方开单支付成功最近n日汇总表'PARTITIONED BY (`dt` STRING)STORED AS ORCLOCATION '/warehouse/medical/dws/dws_trade_hospital_gender_age_group_prescription_pay_suc_nd'TBLPROPERTIES ('orc.compress' = 'snappy');

5.交易域医生粒度问诊最近n日汇总表

建表语句

CREATE EXTERNAL TABLE IF NOT EXISTS dws_trade_doctor_consultation_nd
(`doctor_id`                 STRING COMMENT '医生ID',`doctor_name`               STRING COMMENT '医生姓名',`consultation_count_7d`  BIGINT COMMENT '最近 7 日接诊次数',`consultation_count_30d`  BIGINT COMMENT '最近 30 日接诊次数'
) COMMENT '交易域医生粒度问诊最近n日汇总表'PARTITIONED BY (`dt` STRING)STORED AS ORCLOCATION '/warehouse/medical/dws/dws_trade_doctor_consultation_nd'TBLPROPERTIES ('orc.compress' = 'snappy');

6.首日装载脚本

vim ~/bin/medical_dws_1d_to_dws_nd.sh

#!/bin/bashAPP=medicalif [ -n $2 ]
then do_date=$2
elseecho "请传入日期参数!!!"exit
fidws_trade_hospital_gender_age_group_consultation_nd="
insert overwrite table ${APP}.dws_trade_hospital_gender_age_group_consultation_ndpartition (dt = '$do_date')
select hospital_id,hospital_name,gender_code,gender,age_group,sum(if(dt >= date_add('$do_date', -6), consultation_amount, 0)) consultation_amount_7d,sum(if(dt >= date_add('$do_date', -6), consultation_count, 0))  consultation_count_7d,sum(consultation_amount)                                          consultation_amount_30d,sum(consultation_count)                                           consultation_count_30d
from ${APP}.dws_trade_hospital_gender_age_group_consultation_1d
where dt >= date_add('$do_date', -29)
group by hospital_id,hospital_name,gender_code,gender,age_group;
"dws_trade_hospital_gender_age_group_consultation_pay_suc_nd="
insert overwrite table ${APP}.dws_trade_hospital_gender_age_group_consultation_pay_suc_ndpartition (dt = '$do_date')
select hospital_id,hospital_name,gender_code,gender,age_group,sum(if(dt >= date_add('$do_date', -6), consultation_pay_suc_amount, 0)) consultation_pay_suc_amount_7d,sum(if(dt >= date_add('$do_date', -6), consultation_pay_suc_count, 0))  consultation_pay_suc_count_7d,sum(consultation_pay_suc_amount)                                          consultation_pay_suc_amount_30d,sum(consultation_pay_suc_count)                                           consultation_pay_suc_count_30d
from ${APP}.dws_trade_hospital_gender_age_group_consultation_pay_suc_1d
where dt >= date_add('$do_date', -29)
group by hospital_id,hospital_name,gender_code,gender,age_group;
"dws_trade_hospital_gender_age_group_prescription_nd="
insert overwrite table ${APP}.dws_trade_hospital_gender_age_group_prescription_ndpartition (dt = '$do_date')
select hospital_id,hospital_name,gender_code,gender,age_group,sum(if(dt >= date_add('$do_date', -6), prescription_amount, 0)) prescription_amount_7d,sum(if(dt >= date_add('$do_date', -6), prescription_count, 0))  prescription_count_7d,sum(prescription_amount)                                          prescription_amount_30d,sum(prescription_count)                                           prescription_count_30d
from ${APP}.dws_trade_hospital_gender_age_group_prescription_1d
where dt >= date_add('$do_date', -29)
group by hospital_id,hospital_name,gender_code,gender,age_group;
"dws_trade_hospital_gender_age_group_prescription_pay_suc_nd="
insert overwrite table ${APP}.dws_trade_hospital_gender_age_group_prescription_pay_suc_ndpartition (dt = '$do_date')
select hospital_id,hospital_name,gender_code,gender,age_group,sum(if(dt >= date_add('$do_date', -6), prescription_pay_suc_amount, 0)) prescription_pay_suc_amount_7d,sum(if(dt >= date_add('$do_date', -6), prescription_pay_suc_count, 0))  prescription_pay_suc_count_7d,sum(prescription_pay_suc_amount)                                          prescription_pay_suc_amount_30d,sum(prescription_pay_suc_count)                                           prescription_pay_suc_count_30d
from ${APP}.dws_trade_hospital_gender_age_group_prescription_pay_suc_1d
where dt >= date_add('$do_date', -29)
group by hospital_id,hospital_name,gender_code,gender,age_group;
"dws_trade_doctor_consultation_nd="
insert overwrite table ${APP}.dws_trade_doctor_consultation_ndpartition (dt = '$do_date')
select doctor_id,doctor_name,sum(if(dt >= date_add('$do_date', -6), consultation_count, 0)) consultation_count_7d,sum(consultation_count)                                          consultation_count_30d
from ${APP}.dws_trade_doctor_consultation_1d
where dt >= date_add('$do_date', -29)
group by doctor_id,doctor_name;
"case $1 indws_trade_hospital_gender_age_group_consultation_nd | dws_trade_hospital_gender_age_group_consultation_pay_suc_nd | dws_trade_hospital_gender_age_group_prescription_nd | dws_trade_hospital_gender_age_group_prescription_pay_suc_nd | dws_trade_doctor_consultation_nd)hive -e "${!1}";;"all")hive -e "$dws_trade_hospital_gender_age_group_consultation_nd$dws_trade_hospital_gender_age_group_consultation_pay_suc_nd$dws_trade_hospital_gender_age_group_prescription_nd$dws_trade_hospital_gender_age_group_prescription_pay_suc_nd$dws_trade_doctor_consultation_nd";;"*")echo "非法参数!!!";;
esac

添加权限
chmod +x ~/bin/medical_dws_1d_to_dws_nd.sh
数据装载
medical_dws_1d_to_dws_nd.sh all 2023-05-09
在这里插入图片描述

3.历史至今汇总表

1.交易域医生粒度问诊历史至今汇总表

建表语句

CREATE TABLE IF NOT EXISTS dws_trade_doctor_consultation_td(`doctor_id` STRING COMMENT '医生ID',`doctor_name` STRING COMMENT '医生姓名',`first_consultation_dt` STRING COMMENT '首次接诊日期'
) COMMENT '交易域医生粒度问诊历史至今汇总表'PARTITIONED BY (`dt` STRING)STORED AS ORCLOCATION '/warehouse/medical/dws/dws_trade_doctor_consultation_td'TBLPROPERTIES ('orc.compress' = 'snappy');

2.互动域医院用户粒度用户评价历史至今汇总表

建表语句

CREATE TABLE IF NOT EXISTS dws_interaction_hospital_user_review_td(`hospital_id` STRING COMMENT '医院ID',`hospital_name` STRING COMMENT '医院名称',`user_id` STRING COMMENT '用户ID',`username` STRING COMMENT '用户姓名',`first_review_dt` STRING COMMENT '首次评价日期'
) COMMENT '互动域医院用户粒度用户评价历史至今汇总表'PARTITIONED BY (`dt` STRING)STORED AS ORCLOCATION '/warehouse/medical/dws/dws_interaction_hospital_user_review_td'TBLPROPERTIES ('orc.compress' = 'snappy');

3.互动域医院粒度用户评价历史至今汇总表

建表语句

CREATE TABLE IF NOT EXISTS dws_interaction_hospital_review_td(`hospital_id` STRING COMMENT '医院ID',`hospital_name` STRING COMMENT '医院名称',`review_count` BIGINT COMMENT '评价次数',`good_review_count` BIGINT COMMENT '好评次数'
) COMMENT '互动域医院粒度用户评价历史至今汇总表'PARTITIONED BY (`dt` STRING)STORED AS ORCLOCATION '/warehouse/medical/dws/dws_interaction_hospital_review_td'TBLPROPERTIES ('orc.compress' = 'snappy');

4.首日数据装载

vim ~/bin/medical_dws_1d_to_dws_td_init.sh

#!/bin/bashAPP=medicalif [ -n $2 ]
then do_date=$2
elseecho "请传入日期参数!!!"exit
fidws_trade_doctor_consultation_td="
insert overwrite table ${APP}.dws_trade_doctor_consultation_tdpartition (dt = '$do_date')
select doctor_id,doctor_name,min(dt) first_consultation_dt
from ${APP}.dws_trade_doctor_consultation_1d
group by doctor_id,doctor_name;
"dws_interaction_hospital_user_review_td="
insert overwrite table ${APP}.dws_interaction_hospital_user_review_tdpartition (dt = '$do_date')
select hospital_id,name hospital_name,user_id,username,first_review_dt
from (select hospital_id,user_id,min(review.dt) first_review_dtfrom (select doctor_id,user_id,dtfrom ${APP}.dwd_interaction_review_inc) reviewleft join (select id,hospital_idfrom ${APP}.dim_doctor_fullwhere dt = '$do_date') docon review.doctor_id = doc.idgroup by hospital_id,user_id) avgleft join (select id,namefrom ${APP}.dim_hospital_fullwhere dt = '$do_date') hoson avg.hospital_id = hos.idleft join (select id,usernamefrom ${APP}.dim_user_fullwhere dt = '$do_date') \`user\`on avg.user_id = \`user\`.id;
"dws_interaction_hospital_review_td="
insert overwrite table ${APP}.dws_interaction_hospital_review_tdpartition (dt = '$do_date')
select hospital_id,name hospital_name,review_count,good_review_count
from (select hospital_id,count(*)                  review_count,sum(if(rating = 5, 1, 0)) good_review_countfrom (select doctor_id,ratingfrom ${APP}.dwd_interaction_review_inc) reviewleft join(select id,hospital_idfrom ${APP}.dim_doctor_fullwhere dt = '$do_date') docon review.doctor_id = doc.idgroup by hospital_id) avgleft join (select id,namefrom ${APP}.dim_hospital_fullwhere dt = '$do_date') hoson hospital_id = hos.id;
"case $1 indws_trade_doctor_consultation_td | dws_interaction_hospital_user_review_td | dws_interaction_hospital_review_td)hive -e "${!1}";;"all")hive -e "$dws_trade_doctor_consultation_td$dws_interaction_hospital_user_review_td$dws_interaction_hospital_review_td";;"*")echo "非法参数!!!";;
esac

添加权限
chmod +x ~/bin/medical_dws_1d_to_dws_td_init.sh
数据装载
medical_dws_1d_to_dws_td_init.sh all 2023-05-09

5.每日数据装载

vim ~/bin/medical_dws_1d_to_dws_td.sh

#!/bin/bashAPP=medicalif [ -n $2 ]
then do_date=$2
elseecho "请传入时间参数!!!"exit
fidws_trade_doctor_consultation_td="
insert overwrite table ${APP}.dws_trade_doctor_consultation_tdpartition (dt = '$do_date')
select nvl(old.doctor_id, new.doctor_id)                              doctor_id,nvl(old.doctor_name, new.doctor_name)                          doctor_name,if(old.doctor_id is null, '$do_date', first_consultation_dt) first_consultation_dt
from (select doctor_id,doctor_name,first_consultation_dtfrom ${APP}.dws_trade_doctor_consultation_tdwhere dt = date_add('$do_date', -1)) oldfull outer join(select doctor_id,doctor_namefrom ${APP}.dws_trade_doctor_consultation_1dwhere dt = '$do_date') newon old.doctor_id = new.doctor_idand old.doctor_name = new.doctor_name;
"dws_interaction_hospital_user_review_td="
insert overwrite table ${APP}.dws_interaction_hospital_user_review_tdpartition (dt = '$do_date')
select hospital_id,hospital_name,user_id,username,min(first_review_dt) first_review_dt
from (select hospital_id,hospital_name,user_id,username,first_review_dtfrom ${APP}.dws_interaction_hospital_user_review_tdwhere dt = date_add('$do_date', -1)unionselect hospital_id,name hospital_name,user_id,username,first_reveiw_dtfrom (select hospital_id,user_id,'$do_date' first_reveiw_dtfrom (select doctor_id,user_idfrom ${APP}.dwd_interaction_review_incwhere dt = '$do_date') reivewleft join (select id,hospital_idfrom ${APP}.dim_doctor_full) docon reivew.doctor_id = doc.idgroup by user_id,hospital_id) avgleft join (select id,namefrom ${APP}.dim_hospital_fullwhere dt = '$do_date') hoson avg.hospital_id = hos.idleft join (select id,usernamefrom ${APP}.dim_user_fullwhere dt = '$do_date') \`user\`on avg.user_id = \`user\`.id) \`all\`
group by hospital_id,hospital_name,user_id,username;
"dws_interaction_hospital_review_td="
insert overwrite table ${APP}.dws_interaction_hospital_review_tdpartition (dt = '$do_date')
select hospital_id,hospital_name,sum(review_count)      review_count,sum(good_review_count) good_review_count
from (select hospital_id,hospital_name,review_count,good_review_countfrom ${APP}.dws_interaction_hospital_review_tdwhere dt = date_add('$do_date', -1)unionselect hospital_id,name hospital_name,review_count,good_review_countfrom (select hospital_id,count(*)                  review_count,sum(if(rating = 5, 1, 0)) good_review_countfrom (select doctor_id,ratingfrom ${APP}.dwd_interaction_review_incwhere dt = '$do_date') reviewleft join (select id,hospital_idfrom ${APP}.dim_doctor_fullwhere dt = '$do_date') docgroup by hospital_id) avgleft join (select id,namefrom ${APP}.dim_hospital_fullwhere dt = '$do_date') hoson hospital_id = hos.id) \`all\`
group by hospital_id,hospital_name;
"case $1 indws_trade_doctor_consultation_td | dws_interaction_hospital_user_review_td | dws_interaction_hospital_review_td)hive -e "${!1}";;"all")hive -e "$dws_trade_doctor_consultation_td$dws_interaction_hospital_user_review_td$dws_interaction_hospital_review_td";;"*")echo "非法参数!!!";;
esac

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


总结

内容有点多,可能还要一次才能完成。

相关文章:

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

系列文章目录 线上问诊&#xff1a;业务数据采集 线上问诊&#xff1a;数仓数据同步 线上问诊&#xff1a;数仓开发(一) 线上问诊&#xff1a;数仓开发(二) 文章目录 系列文章目录前言一、DWS1.最近1日汇总表1.交易域医院患者性别年龄段粒度问诊最近1日汇总表2.交易域医院患者…...

Ansible自动化运维工具(三)

目录 Ansible 的脚本 --- playbook 剧本 ​编辑2.vars模块实战实例 3.指定远程主机sudo切换用户 4.when模块实战实例 5.with_items迭代模块实战实例 6.Templates 模块实战实例 &#xff08;1&#xff09;先准备一个以 .j2 为后缀的 template 模板文件&#xff0c;设置引用…...

ChatGPT在创新和创业中的应用如何?

ChatGPT是一种基于大规模预训练的语言模型&#xff0c;它在创新和创业中有着广泛的应用。作为一种具备自然语言处理能力的模型&#xff0c;ChatGPT可以与用户进行对话&#xff0c;并提供相关的信息、建议和创意。以下是ChatGPT在创新和创业中的一些应用&#xff1a; 创意生成和…...

Log4j2 配置日志记录发送到 kafka 中

前言 log4j2 在 2.11.0 之后的版本&#xff0c;已经内置了 KafkaAppender 支持可以将打印的日志直接发送到 kafka 中&#xff0c;在这之前如果想要集中收集应用的日志&#xff0c;就需要自定义一个 Layout 来实现&#xff0c;相对来说还是比较麻烦的。 官网文档&#xff1a;L…...

Linux用户与组管理(03)(八)

提示&#xff1a;文章写完后&#xff0c;目录可以自动生成&#xff0c;如何生成可参考右边的帮助文档 目录 前言 一、组管理 1、概述 2、用户信息查看 总结 前言 今天是学习用户与组管理的最后一节课&#xff0c;这节课主要是组管理的内容&#xff0c;希望能一起学习&#xff…...

Java自定义异常

Java标准库定义的常用异常包括&#xff1a; 当我们在代码中需要抛出异常时&#xff0c;尽量使用JDK已定义的异常类型。例如&#xff0c;参数检查不合法&#xff0c;应该抛出IllegalArgumentException&#xff1a; static void process1(int age) {if (age < 0) {throw new…...

vscode远程调试php

使用vscode远程调试php的方法 1.安装remote ssh插件 2.连接服务器 可以点击左下角的绿色按钮&#xff0c;或者ctrlshiftp打开命令框输入remote ssh应该也有。 3.在服务器端vscode安装php debug插件 4.安装xdebug xdebug是用来调试php的软件&#xff0c;原本和vscode没什么关…...

C语言:截断+整型提升练习

详情关于整型提升与截断见文章&#xff1a;《C语言&#xff1a;整型提升》 一、代码一 int main() { char a -1; signed char b -1; unsigned char c -1; printf("%d %d %d", a, b, c); return 0; } 求输出结果 解析如下代码&#xff1a; int mai…...

Kubernetes技术--k8s核心技术kubectl命令行工具

(1).概述 kubectl是Kubernetes集群的命令行工具,通过 kubectl 能够对集群本身进行管理,并能够在集群上进行容器化应用的安装部署。 (2).语法 Kubectl [command] [type] [name] [flags] 语法参数说明: command: 指定要对资源执行的操作,例如 create、get、describe 和 delet…...

Element浅尝辄止9:Popover 弹出框组件

Popover 的属性与 Tooltip 很类似&#xff0c;它们都是基于Vue-popper开发的&#xff0c;因此有重复属性 1.如何使用&#xff1f; /*trigger属性用于设置何时触发 Popover&#xff0c;支持四种触发方式&#xff1a; hover&#xff0c;click&#xff0c;focus 和 manual。 对于…...

程序开发:构建功能强大的应用的艺术

程序开发是在今天的数字化时代中扮演重要角色的一项技术。通过编写代码&#xff0c;开发人员能创造出无数不同的应用&#xff0c;从简单的计算器到复杂的社交平台。电子商务应用、在线教育平台、医疗记录系统等&#xff0c;都重视程序开发的重要性&#xff0c;通过这其中的交互…...

(七)k8s实战-高级调度

一、CronJob 定时任务 1、cron 表达式 # ┌───────────── 分钟 (0 - 59) # │ ┌───────────── 小时 (0 - 23) # │ │ ┌───────────── 月的某天 (1 - 31) # │ │ │ ┌───────────── 月份 (1 - 12) # │ │ │ │ ┌…...

HTTP/1.1协议中的八种请求

2023年8月29日&#xff0c;周二晚上 目录 概述八种请求GET请求POST请求PUT请求PATCH请求DELETE请求HEAD请求OPTIONS请求TRACE请求 概述八种请求 HTTP/1.1协议中定义了8种常用的请求方法,分别是:1. GET 用途:请求指定的页面信息,并返回实体主体。例子:获取一个网页、图片等静态…...

面试系列 - JVM内存模型和调优详解

目录 一、JVM内存模型 1. 程序计数器&#xff08;Program Counter Register&#xff09;&#xff1a; 2.Java虚拟机栈&#xff08;Java Virtual Machine Stacks&#xff09;&#xff1a; 3. 本地方法栈&#xff08;Native Method Stack&#xff09;&#xff1a; 5. 方法区…...

JavaScript -【第一周】

文章来源于网上收集和自己原创&#xff0c;若侵害到您的权利&#xff0c;请您及时联系并删除~~~ JavaScript 介绍 变量、常量、数据类型、运算符等基础概念 能够实现数据类型的转换&#xff0c;结合四则运算体会如何编程。 体会现实世界中的事物与计算机的关系理解什么是数据并…...

高性能缓存 Caffeine 原理及实战

Caffeine 是基于Java 8 开发的、提供了近乎最佳命中率的高性能本地缓存组件&#xff0c;Spring5 开始不再支持 Guava Cache&#xff0c;改为使用 Caffeine。 1 算法原理 对于 Java 进程内缓存我们可以通过 HashMap 来实现。不过&#xff0c;Java 进程内存是有限的&#xff0c;…...

【算法】leetcode 105 从前序与中序遍历序列构造二叉树

题目 输入某二叉树的前序遍历和中序遍历的结果&#xff0c;请构建该二叉树并返回其根节点。 假设输入的前序遍历和中序遍历的结果中都不含重复的数字。 示例 1: Input: preorder [3,9,20,15,7], inorder [9,3,15,20,7] Output: [3,9,20,null,null,15,7]示例 2: Input: pr…...

11 | Spark计算数据文件中每行数值的平均值

需求:计算数据文件中的数值的平均值 背景: 你有一个数据文件,其中包含一系列数值,每行一个数值,数值之间用逗号分隔。你想使用Apache Spark分布式计算框架来读取数据文件中的数值并计算它们的平均值。功能要求: 通过Spark配置和上下文初始化Spark应用程序。从数据文件中…...

AI与游戏创新:深度学习的起跑枪声

《AI与游戏创新&#xff1a;深度学习的起跑枪声》 目录 引言AIGC定义与重要性AI在游戏中的应用AI推动游戏创新的可能途径AIGC的挑战与解决方案结论&#xff1a;AI是游戏行业的下一站 引言 AI&#xff08;人工智能&#xff09;正在全球范围内改变各个行业&#xff0c;游戏行…...

【GUI开发】用python爬YouTube博主信息,并开发成exe软件

文章目录 一、背景介绍二、代码讲解2.1 爬虫2.2 tkinter界面2.3 存日志 三、软件演示视频四、说明 一、背景介绍 你好&#xff0c;我是马哥python说&#xff0c;一名10年程序猿。 最近我用python开发了一个GUI桌面软件&#xff0c;目的是爬取相关YouTube博主的各种信息&#…...

[特殊字符] 智能合约中的数据是如何在区块链中保持一致的?

&#x1f9e0; 智能合约中的数据是如何在区块链中保持一致的&#xff1f; 为什么所有区块链节点都能得出相同结果&#xff1f;合约调用这么复杂&#xff0c;状态真能保持一致吗&#xff1f;本篇带你从底层视角理解“状态一致性”的真相。 一、智能合约的数据存储在哪里&#xf…...

rknn优化教程(二)

文章目录 1. 前述2. 三方库的封装2.1 xrepo中的库2.2 xrepo之外的库2.2.1 opencv2.2.2 rknnrt2.2.3 spdlog 3. rknn_engine库 1. 前述 OK&#xff0c;开始写第二篇的内容了。这篇博客主要能写一下&#xff1a; 如何给一些三方库按照xmake方式进行封装&#xff0c;供调用如何按…...

ffmpeg(四):滤镜命令

FFmpeg 的滤镜命令是用于音视频处理中的强大工具&#xff0c;可以完成剪裁、缩放、加水印、调色、合成、旋转、模糊、叠加字幕等复杂的操作。其核心语法格式一般如下&#xff1a; ffmpeg -i input.mp4 -vf "滤镜参数" output.mp4或者带音频滤镜&#xff1a; ffmpeg…...

爬虫基础学习day2

# 爬虫设计领域 工商&#xff1a;企查查、天眼查短视频&#xff1a;抖音、快手、西瓜 ---> 飞瓜电商&#xff1a;京东、淘宝、聚美优品、亚马逊 ---> 分析店铺经营决策标题、排名航空&#xff1a;抓取所有航空公司价格 ---> 去哪儿自媒体&#xff1a;采集自媒体数据进…...

[Java恶补day16] 238.除自身以外数组的乘积

给你一个整数数组 nums&#xff0c;返回 数组 answer &#xff0c;其中 answer[i] 等于 nums 中除 nums[i] 之外其余各元素的乘积 。 题目数据 保证 数组 nums之中任意元素的全部前缀元素和后缀的乘积都在 32 位 整数范围内。 请 不要使用除法&#xff0c;且在 O(n) 时间复杂度…...

九天毕昇深度学习平台 | 如何安装库?

pip install 库名 -i https://pypi.tuna.tsinghua.edu.cn/simple --user 举个例子&#xff1a; 报错 ModuleNotFoundError: No module named torch 那么我需要安装 torch pip install torch -i https://pypi.tuna.tsinghua.edu.cn/simple --user pip install 库名&#x…...

Java求职者面试指南:Spring、Spring Boot、Spring MVC与MyBatis技术解析

Java求职者面试指南&#xff1a;Spring、Spring Boot、Spring MVC与MyBatis技术解析 一、第一轮基础概念问题 1. Spring框架的核心容器是什么&#xff1f;它的作用是什么&#xff1f; Spring框架的核心容器是IoC&#xff08;控制反转&#xff09;容器。它的主要作用是管理对…...

【UE5 C++】通过文件对话框获取选择文件的路径

目录 效果 步骤 源码 效果 步骤 1. 在“xxx.Build.cs”中添加需要使用的模块 &#xff0c;这里主要使用“DesktopPlatform”模块 2. 添加后闭UE编辑器&#xff0c;右键点击 .uproject 文件&#xff0c;选择 "Generate Visual Studio project files"&#xff0c;重…...

全面解析数据库:从基础概念到前沿应用​

在数字化时代&#xff0c;数据已成为企业和社会发展的核心资产&#xff0c;而数据库作为存储、管理和处理数据的关键工具&#xff0c;在各个领域发挥着举足轻重的作用。从电商平台的商品信息管理&#xff0c;到社交网络的用户数据存储&#xff0c;再到金融行业的交易记录处理&a…...

前端调试HTTP状态码

1xx&#xff08;信息类状态码&#xff09; 这类状态码表示临时响应&#xff0c;需要客户端继续处理请求。 100 Continue 服务器已收到请求的初始部分&#xff0c;客户端应继续发送剩余部分。 2xx&#xff08;成功类状态码&#xff09; 表示请求已成功被服务器接收、理解并处…...