当前位置: 首页 > 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博主的各种信息&#…...

Flask RESTful 示例

目录 1. 环境准备2. 安装依赖3. 修改main.py4. 运行应用5. API使用示例获取所有任务获取单个任务创建新任务更新任务删除任务 中文乱码问题&#xff1a; 下面创建一个简单的Flask RESTful API示例。首先&#xff0c;我们需要创建环境&#xff0c;安装必要的依赖&#xff0c;然后…...

Redis相关知识总结(缓存雪崩,缓存穿透,缓存击穿,Redis实现分布式锁,如何保持数据库和缓存一致)

文章目录 1.什么是Redis&#xff1f;2.为什么要使用redis作为mysql的缓存&#xff1f;3.什么是缓存雪崩、缓存穿透、缓存击穿&#xff1f;3.1缓存雪崩3.1.1 大量缓存同时过期3.1.2 Redis宕机 3.2 缓存击穿3.3 缓存穿透3.4 总结 4. 数据库和缓存如何保持一致性5. Redis实现分布式…...

【SQL学习笔记1】增删改查+多表连接全解析(内附SQL免费在线练习工具)

可以使用Sqliteviz这个网站免费编写sql语句&#xff0c;它能够让用户直接在浏览器内练习SQL的语法&#xff0c;不需要安装任何软件。 链接如下&#xff1a; sqliteviz 注意&#xff1a; 在转写SQL语法时&#xff0c;关键字之间有一个特定的顺序&#xff0c;这个顺序会影响到…...

微信小程序云开发平台MySQL的连接方式

注&#xff1a;微信小程序云开发平台指的是腾讯云开发 先给结论&#xff1a;微信小程序云开发平台的MySQL&#xff0c;无法通过获取数据库连接信息的方式进行连接&#xff0c;连接只能通过云开发的SDK连接&#xff0c;具体要参考官方文档&#xff1a; 为什么&#xff1f; 因为…...

Go 并发编程基础:通道(Channel)的使用

在 Go 中&#xff0c;Channel 是 Goroutine 之间通信的核心机制。它提供了一个线程安全的通信方式&#xff0c;用于在多个 Goroutine 之间传递数据&#xff0c;从而实现高效的并发编程。 本章将介绍 Channel 的基本概念、用法、缓冲、关闭机制以及 select 的使用。 一、Channel…...

GitHub 趋势日报 (2025年06月06日)

&#x1f4ca; 由 TrendForge 系统生成 | &#x1f310; https://trendforge.devlive.org/ &#x1f310; 本日报中的项目描述已自动翻译为中文 &#x1f4c8; 今日获星趋势图 今日获星趋势图 590 cognee 551 onlook 399 project-based-learning 348 build-your-own-x 320 ne…...

计算机基础知识解析:从应用到架构的全面拆解

目录 前言 1、 计算机的应用领域&#xff1a;无处不在的数字助手 2、 计算机的进化史&#xff1a;从算盘到量子计算 3、计算机的分类&#xff1a;不止 “台式机和笔记本” 4、计算机的组件&#xff1a;硬件与软件的协同 4.1 硬件&#xff1a;五大核心部件 4.2 软件&#…...

WebRTC从入门到实践 - 零基础教程

WebRTC从入门到实践 - 零基础教程 目录 WebRTC简介 基础概念 工作原理 开发环境搭建 基础实践 三个实战案例 常见问题解答 1. WebRTC简介 1.1 什么是WebRTC&#xff1f; WebRTC&#xff08;Web Real-Time Communication&#xff09;是一个支持网页浏览器进行实时语音…...

django blank 与 null的区别

1.blank blank控制表单验证时是否允许字段为空 2.null null控制数据库层面是否为空 但是&#xff0c;要注意以下几点&#xff1a; Django的表单验证与null无关&#xff1a;null参数控制的是数据库层面字段是否可以为NULL&#xff0c;而blank参数控制的是Django表单验证时字…...

给网站添加live2d看板娘

给网站添加live2d看板娘 参考文献&#xff1a; stevenjoezhang/live2d-widget: 把萌萌哒的看板娘抱回家 (ノ≧∇≦)ノ | Live2D widget for web platformEikanya/Live2d-model: Live2d model collectionzenghongtu/live2d-model-assets 前言 网站环境如下&#xff0c;文章也主…...