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

news2024/11/16 18:19:30

系列文章目录

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


文章目录

  • 系列文章目录
  • 前言
  • 一、ADS
    • 1.交易主题
      • 1.交易综合统计
      • 2.各医院交易统计
      • 3.各性别患者交易统计
      • 4.各年龄段患者交易统计
    • 2.医生主题
      • 1.医生变动统计
    • 3.用户主题
      • 1.用户变动统计
    • 4.评价主题
      • 1.评价综合统计
      • 2.各医院评价统计
      • 5.数据装载脚本
  • 一、报表数据导出
    • 1.MySQL建库建表
      • 1.创建数据库
      • 2.创建表
    • 2.数据导出
      • 1.DataX配置文件生成脚本
      • 2.执行配置文件生成器
      • 3.编写每日导出脚本
  • 总结


前言

这次我们继续进行数仓的开发,应该能写完。


一、ADS

1.交易主题

1.交易综合统计

建表语句

CREATE EXTERNAL TABLE IF NOT EXISTS ads_trade_stats
(
    `dt`                          STRING COMMENT '统计日期',
    `recent_days`                 BIGINT COMMENT '统计周期: 最近1,7,30日',
    `consultation_amount`         DECIMAL(16, 2) COMMENT '问诊金额',
    `consultation_count`          BIGINT COMMENT '问诊次数',
    `consultation_pay_suc_amount` DECIMAL(16, 2) COMMENT '问诊支付成功金额',
    `consultation_pay_suc_count`  BIGINT COMMENT '问诊支付成功次数',
    `prescription_amount`         DECIMAL(16, 2) COMMENT '处方金额',
    `prescription_count`          BIGINT COMMENT '处方次数',
    `prescription_pay_suc_amount` DECIMAL(16, 2) COMMENT '处方支付成功金额',
    `prescription_pay_suc_count`  BIGINT COMMENT '处方支付成功次数'
) COMMENT '交易综合统计'
    ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t'
    LOCATION '/warehouse/medical/ads/ads_trade_stats';

2.各医院交易统计

建表语句

CREATE EXTERNAL TABLE IF NOT EXISTS ads_hospital_trade_stats
(
    `dt`                          STRING COMMENT '统计日期',
    `recent_days`                 BIGINT COMMENT '统计周期: 最近1,7,30日',
    `hospital_id`                 STRING COMMENT '医院ID',
    `hospital_name`               STRING COMMENT '医院名称',
    `consultation_amount`         DECIMAL(16, 2) COMMENT '问诊金额',
    `consultation_count`          BIGINT COMMENT '问诊次数',
    `consultation_pay_suc_amount` DECIMAL(16, 2) COMMENT '问诊支付成功金额',
    `consultation_pay_suc_count`  BIGINT COMMENT '问诊支付成功次数',
    `prescription_amount`         DECIMAL(16, 2) COMMENT '处方金额',
    `prescription_count`          BIGINT COMMENT '处方次数',
    `prescription_pay_suc_amount` DECIMAL(16, 2) COMMENT '处方支付成功金额',
    `prescription_pay_suc_count`  BIGINT COMMENT '处方支付成功次数'
) COMMENT '各医院交易统计'
    ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t'
    LOCATION '/warehouse/medical/ads/ads_hospital_trade_stats';

3.各性别患者交易统计

建表语句

CREATE EXTERNAL TABLE IF NOT EXISTS ads_gender_trade_stats
(
    `dt`                          STRING COMMENT '统计日期',
    `recent_days`                 BIGINT COMMENT '统计周期: 最近1,7,30日',
    `gender_code`                 STRING COMMENT '患者性别编码',
    `gender`                      STRING COMMENT '患者性别',
    `consultation_amount`         DECIMAL(16, 2) COMMENT '问诊金额',
    `consultation_count`          BIGINT COMMENT '问诊次数',
    `consultation_pay_suc_amount` DECIMAL(16, 2) COMMENT '问诊支付成功金额',
    `consultation_pay_suc_count`  BIGINT COMMENT '问诊支付成功次数',
    `prescription_amount`         DECIMAL(16, 2) COMMENT '处方金额',
    `prescription_count`          BIGINT COMMENT '处方次数',
    `prescription_pay_suc_amount` DECIMAL(16, 2) COMMENT '处方支付成功金额',
    `prescription_pay_suc_count`  BIGINT COMMENT '处方支付成功次数'
) COMMENT '各性别患者交易统计'
    ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t'
    LOCATION '/warehouse/medical/ads/ads_gender_trade_stats';

4.各年龄段患者交易统计

建表语句

CREATE EXTERNAL TABLE IF NOT EXISTS ads_age_group_trade_stats
(
    `dt`                          STRING COMMENT '统计日期',
    `recent_days`                 BIGINT COMMENT '统计周期: 最近1,7,30日',
    `age_group`                   STRING COMMENT '患者年龄段',
    `consultation_amount`         DECIMAL(16, 2) COMMENT '问诊金额',
    `consultation_count`          BIGINT COMMENT '问诊次数',
    `consultation_pay_suc_amount` DECIMAL(16, 2) COMMENT '问诊支付成功金额',
    `consultation_pay_suc_count`  BIGINT COMMENT '问诊支付成功次数',
    `prescription_amount`         DECIMAL(16, 2) COMMENT '处方金额',
    `prescription_count`          BIGINT COMMENT '处方次数',
    `prescription_pay_suc_amount` DECIMAL(16, 2) COMMENT '处方支付成功金额',
    `prescription_pay_suc_count`  BIGINT COMMENT '处方支付成功次数'
) COMMENT '各年龄段患者交易统计'
    ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t'
    LOCATION '/warehouse/medical/ads/ads_age_group_trade_stats';

数据装载

2.医生主题

1.医生变动统计

建表语句

CREATE EXTERNAL TABLE IF NOT EXISTS ads_doctor_change_stats(
    `dt` STRING COMMENT '统计日期',
    `recent_days` BIGINT COMMENT '统计周期: 最近1,7,30日',
    `new_doctor_count` BIGINT COMMENT '新增医生数',
    `activated_doctor_count` BIGINT COMMENT '激活医生数',
    `active_doctor_count` BIGINT COMMENT '活跃医生数'
) COMMENT '医生变动统计'
    ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t'
    LOCATION '/warehouse/medical/ads/ads_doctor_change_stats';

3.用户主题

1.用户变动统计

建表语句

CREATE EXTERNAL TABLE IF NOT EXISTS ads_user_change_stats(
    `dt` STRING COMMENT '统计日期',
    `recent_days` BIGINT COMMENT '统计周期: 最近1,7,30日',
    `new_user_count` BIGINT COMMENT '新增用户数',
    `new_patient_count` BIGINT COMMENT '新增患者数'
) COMMENT '用户变动统计'
    ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t'
    LOCATION '/warehouse/medical/ads/ads_user_change_stats';

4.评价主题

1.评价综合统计

建表语句

CREATE EXTERNAL TABLE IF NOT EXISTS ads_review_stats(
    `dt` STRING COMMENT '统计日期',
    `review_user_count` BIGINT COMMENT '评价人数',
    `review_count` BIGINT COMMENT '评价次数',
    `good_review_rate` DECIMAL(16,2) COMMENT '好评率'
) COMMENT '用户变动统计'
    ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t'
    LOCATION '/warehouse/medical/ads/ads_review_stats';

2.各医院评价统计

建表语句

CREATE EXTERNAL TABLE IF NOT EXISTS ads_hospital_review_stats(
    `dt` STRING COMMENT '统计日期',
    `hospital_id` STRING COMMENT '医院ID',
    `hospital_name` STRING COMMENT '医院名称',
    `review_user_count` BIGINT COMMENT '评价人数',
    `review_count` BIGINT COMMENT '评价次数',
    `good_review_rate` DECIMAL(16,2) COMMENT '好评率'
) COMMENT '各医院评价统计'
    ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t'
    LOCATION '/warehouse/medical/ads/ads_hospital_review_stats';

5.数据装载脚本

vim ~/bin/medical_dws_to_ads.sh

#!/bin/bash

APP=medical

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

ads_trade_stats="
insert overwrite table ${APP}.ads_trade_stats
select dt,
       recent_days,
       consultation_amount,
       consultation_count,
       consultation_pay_suc_amount,
       consultation_pay_suc_count,
       prescription_amount,
       prescription_count,
       prescription_pay_suc_amount,
       prescription_pay_suc_count
from ${APP}.ads_trade_stats
union
select '$do_date' dt,
       consul.recent_days,
       consultation_amount,
       consultation_count,
       consultation_pay_suc_amount,
       consultation_pay_suc_count,
       prescription_amount,
       prescription_count,
       prescription_pay_suc_amount,
       prescription_pay_suc_count
from (select 1                        recent_days,
             sum(consultation_amount) consultation_amount,
             sum(consultation_count)  consultation_count
      from ${APP}.dws_trade_hospital_gender_age_group_consultation_1d
      where dt = '$do_date'
      union
      select recent_days,
             sum(if(recent_days = 7, consultation_amount_7d, consultation_amount_30d)) consultation_amount,
             sum(if(recent_days = 7, consultation_count_7d, consultation_count_30d))   consultation_count
      from ${APP}.dws_trade_hospital_gender_age_group_consultation_nd lateral view explode(array(7, 30)) tmp as recent_days
      where dt = '$do_date'
      group by recent_days) consul
         left join
     (select 1                                recent_days,
             sum(consultation_pay_suc_amount) consultation_pay_suc_amount,
             sum(consultation_pay_suc_count)  consultation_pay_suc_count
      from ${APP}.dws_trade_hospital_gender_age_group_consultation_pay_suc_1d
      where dt = '$do_date'
      union
      select recent_days,
             sum(if(recent_days = 7, consultation_pay_suc_amount_7d,
                    consultation_pay_suc_amount_30d)) consultation_pay_suc_amount,
             sum(if(recent_days = 7, consultation_pay_suc_count_7d,
                    consultation_pay_suc_count_30d))  consultation_pay_suc_count
      from ${APP}.dws_trade_hospital_gender_age_group_consultation_pay_suc_nd lateral view explode(array(7, 30)) tmp as recent_days
      where dt = '$do_date'
      group by recent_days) consul_pay_suc
     on consul.recent_days = consul_pay_suc.recent_days
         left join
     (select 1                        recent_days,
             sum(prescription_amount) prescription_amount,
             sum(prescription_count)  prescription_count
      from ${APP}.dws_trade_hospital_gender_age_group_prescription_1d
      where dt = '$do_date'
      union
      select recent_days,
             sum(if(recent_days = 7, prescription_amount_7d, prescription_amount_30d)) prescription_amount,
             sum(if(recent_days = 7, prescription_count_7d, prescription_count_30d))   prescription_count
      from ${APP}.dws_trade_hospital_gender_age_group_prescription_nd lateral view explode(array(7, 30)) tmp as recent_days
      where dt = '$do_date'
      group by recent_days) prescription
     on consul.recent_days = prescription.recent_days
         left join
     (select 1                                recent_days,
             sum(prescription_pay_suc_amount) prescription_pay_suc_amount,
             sum(prescription_pay_suc_count)  prescription_pay_suc_count
      from ${APP}.dws_trade_hospital_gender_age_group_prescription_pay_suc_1d
      where dt = '$do_date'
      union
      select recent_days,
             sum(if(recent_days = 7, prescription_pay_suc_amount_7d,
                    prescription_pay_suc_amount_30d)) prescription_pay_suc_amount,
             sum(if(recent_days = 7, prescription_pay_suc_count_7d,
                    prescription_pay_suc_count_30d))  prescription_pay_suc_count
      from ${APP}.dws_trade_hospital_gender_age_group_prescription_pay_suc_nd lateral view explode(array(7, 30)) tmp as recent_days
      where dt = '$do_date'
      group by recent_days) prescription_pay_suc
     on consul.recent_days = prescription_pay_suc.recent_days;
"
ads_hospital_trade_stats="
insert overwrite table ${APP}.ads_hospital_trade_stats
select dt,
       recent_days,
       hospital_id,
       hospital_name,
       consultation_amount,
       consultation_count,
       consultation_pay_suc_amount,
       consultation_pay_suc_count,
       prescription_amount,
       prescription_count,
       prescription_pay_suc_amount,
       prescription_pay_suc_count
from ${APP}.ads_hospital_trade_stats
union
select '$do_date' dt,
       consul.recent_days,
       consul.hospital_id,
       consul.hospital_name,
       consultation_amount,
       consultation_count,
       consultation_pay_suc_amount,
       consultation_pay_suc_count,
       prescription_amount,
       prescription_count,
       prescription_pay_suc_amount,
       prescription_pay_suc_count
from (select 1                        recent_days,
             hospital_id,
             hospital_name,
             sum(consultation_amount) consultation_amount,
             sum(consultation_count)  consultation_count
      from ${APP}.dws_trade_hospital_gender_age_group_consultation_1d
      where dt = '$do_date'
      group by hospital_id,
               hospital_name
      union
      select recent_days,
             hospital_id,
             hospital_name,
             sum(if(recent_days = 7, consultation_amount_7d, consultation_amount_30d)) consultation_amount,
             sum(if(recent_days = 7, consultation_count_7d, consultation_count_30d))   consultation_count
      from ${APP}.dws_trade_hospital_gender_age_group_consultation_nd lateral view explode(array(7, 30)) tmp as recent_days
      where dt = '$do_date'
      group by recent_days,
               hospital_id,
               hospital_name) consul
         left join
     (select 1                                recent_days,
             hospital_id,
             hospital_name,
             sum(consultation_pay_suc_amount) consultation_pay_suc_amount,
             sum(consultation_pay_suc_count)  consultation_pay_suc_count
      from ${APP}.dws_trade_hospital_gender_age_group_consultation_pay_suc_1d
      where dt = '$do_date'
      group by hospital_id,
               hospital_name
      union
      select recent_days,
             hospital_id,
             hospital_name,
             sum(if(recent_days = 7, consultation_pay_suc_amount_7d,
                    consultation_pay_suc_amount_30d)) consultation_pay_suc_amount,
             sum(if(recent_days = 7, consultation_pay_suc_count_7d,
                    consultation_pay_suc_count_30d))  consultation_pay_suc_count
      from ${APP}.dws_trade_hospital_gender_age_group_consultation_pay_suc_nd lateral view explode(array(7, 30)) tmp as recent_days
      where dt = '$do_date'
      group by recent_days,
               hospital_id,
               hospital_name) consul_pay_suc
     on consul.recent_days = consul_pay_suc.recent_days
         and consul.hospital_id = consul_pay_suc.hospital_id
         and consul.hospital_name = consul_pay_suc.hospital_name
         left join
     (select 1                        recent_days,
             hospital_id,
             hospital_name,
             sum(prescription_amount) prescription_amount,
             sum(prescription_count)  prescription_count
      from ${APP}.dws_trade_hospital_gender_age_group_prescription_1d
      where dt = '$do_date'
      group by hospital_id,
               hospital_name
      union
      select recent_days,
             hospital_id,
             hospital_name,
             sum(if(recent_days = 7, prescription_amount_7d, prescription_amount_30d)) prescription_amount,
             sum(if(recent_days = 7, prescription_count_7d, prescription_count_30d))   prescription_count
      from ${APP}.dws_trade_hospital_gender_age_group_prescription_nd lateral view explode(array(7, 30)) tmp as recent_days
      where dt = '$do_date'
      group by recent_days,
               hospital_id,
               hospital_name) prescription
     on consul.recent_days = prescription.recent_days
         and consul.hospital_id = prescription.hospital_id
         and consul.hospital_name = prescription.hospital_name
         left join
     (select 1                                recent_days,
             hospital_id,
             hospital_name,
             sum(prescription_pay_suc_amount) prescription_pay_suc_amount,
             sum(prescription_pay_suc_count)  prescription_pay_suc_count
      from ${APP}.dws_trade_hospital_gender_age_group_prescription_pay_suc_1d
      where dt = '$do_date'
      group by hospital_id,
               hospital_name
      union
      select recent_days,
             hospital_id,
             hospital_name,
             sum(if(recent_days = 7, prescription_pay_suc_amount_7d,
                    prescription_pay_suc_amount_30d)) prescription_pay_suc_amount,
             sum(if(recent_days = 7, prescription_pay_suc_count_7d,
                    prescription_pay_suc_count_30d))  prescription_pay_suc_count
      from ${APP}.dws_trade_hospital_gender_age_group_prescription_pay_suc_nd lateral view explode(array(7, 30)) tmp as recent_days
      where dt = '$do_date'
      group by recent_days,
               hospital_id,
               hospital_name) prescription_pay_suc
     on consul.recent_days = prescription_pay_suc.recent_days
         and consul.hospital_id = prescription_pay_suc.hospital_id
         and consul.hospital_name = prescription_pay_suc.hospital_name;
"
ads_gender_trade_stats="
insert overwrite table ${APP}.ads_gender_trade_stats
select dt,
       recent_days,
       gender_code,
       gender,
       consultation_amount,
       consultation_count,
       consultation_pay_suc_amount,
       consultation_pay_suc_count,
       prescription_amount,
       prescription_count,
       prescription_pay_suc_amount,
       prescription_pay_suc_count
from ${APP}.ads_gender_trade_stats
union
select '$do_date' dt,
       consul.recent_days,
       consul.gender_code,
       consul.gender,
       consultation_amount,
       consultation_count,
       consultation_pay_suc_amount,
       consultation_pay_suc_count,
       prescription_amount,
       prescription_count,
       prescription_pay_suc_amount,
       prescription_pay_suc_count
from (select 1                        recent_days,
             gender_code,
             gender,
             sum(consultation_amount) consultation_amount,
             sum(consultation_count)  consultation_count
      from ${APP}.dws_trade_hospital_gender_age_group_consultation_1d
      where dt = '$do_date'
      group by gender_code,
               gender
      union
      select recent_days,
             gender_code,
             gender,
             sum(if(recent_days = 7, consultation_amount_7d, consultation_amount_30d)) consultation_amount,
             sum(if(recent_days = 7, consultation_count_7d, consultation_count_30d))   consultation_count
      from ${APP}.dws_trade_hospital_gender_age_group_consultation_nd lateral view explode(array(7, 30)) tmp as recent_days
      where dt = '$do_date'
      group by recent_days,
               gender_code,
               gender) consul
         left join
     (select 1                                recent_days,
             gender_code,
             gender,
             sum(consultation_pay_suc_amount) consultation_pay_suc_amount,
             sum(consultation_pay_suc_count)  consultation_pay_suc_count
      from ${APP}.dws_trade_hospital_gender_age_group_consultation_pay_suc_1d
      where dt = '$do_date'
      group by gender_code,
               gender
      union
      select recent_days,
             gender_code,
             gender,
             sum(if(recent_days = 7, consultation_pay_suc_amount_7d,
                    consultation_pay_suc_amount_30d)) consultation_pay_suc_amount,
             sum(if(recent_days = 7, consultation_pay_suc_count_7d,
                    consultation_pay_suc_count_30d))  consultation_pay_suc_count
      from ${APP}.dws_trade_hospital_gender_age_group_consultation_pay_suc_nd lateral view explode(array(7, 30)) tmp as recent_days
      where dt = '$do_date'
      group by recent_days,
               gender_code,
               gender) consul_pay_suc
     on consul.recent_days = consul_pay_suc.recent_days
         and consul.gender_code = consul_pay_suc.gender_code
         and consul.gender = consul_pay_suc.gender
         left join
     (select 1                        recent_days,
             gender_code,
             gender,
             sum(prescription_amount) prescription_amount,
             sum(prescription_count)  prescription_count
      from ${APP}.dws_trade_hospital_gender_age_group_prescription_1d
      where dt = '$do_date'
      group by gender_code,
               gender
      union
      select recent_days,
             gender_code,
             gender,
             sum(if(recent_days = 7, prescription_amount_7d, prescription_amount_30d)) prescription_amount,
             sum(if(recent_days = 7, prescription_count_7d, prescription_count_30d))   prescription_count
      from ${APP}.dws_trade_hospital_gender_age_group_prescription_nd lateral view explode(array(7, 30)) tmp as recent_days
      where dt = '$do_date'
      group by recent_days,
               gender_code,
               gender) prescription
     on consul.recent_days = prescription.recent_days
         and consul.gender_code = prescription.gender_code
         and consul.gender = prescription.gender
         left join
     (select 1                                recent_days,
             gender_code,
             gender,
             sum(prescription_pay_suc_amount) prescription_pay_suc_amount,
             sum(prescription_pay_suc_count)  prescription_pay_suc_count
      from ${APP}.dws_trade_hospital_gender_age_group_prescription_pay_suc_1d
      where dt = '$do_date'
      group by gender_code,
               gender
      union
      select recent_days,
             gender_code,
             gender,
             sum(if(recent_days = 7, prescription_pay_suc_amount_7d,
                    prescription_pay_suc_amount_30d)) prescription_pay_suc_amount,
             sum(if(recent_days = 7, prescription_pay_suc_count_7d,
                    prescription_pay_suc_count_30d))  prescription_pay_suc_count
      from ${APP}.dws_trade_hospital_gender_age_group_prescription_pay_suc_nd lateral view explode(array(7, 30)) tmp as recent_days
      where dt = '$do_date'
      group by recent_days,
               gender_code,
               gender) prescription_pay_suc
     on consul.recent_days = prescription_pay_suc.recent_days
         and consul.gender_code = prescription_pay_suc.gender_code
         and consul.gender = prescription_pay_suc.gender;
"
ads_age_group_trade_stats="
insert overwrite table ${APP}.ads_age_group_trade_stats
select dt,
       recent_days,
       age_group,
       consultation_amount,
       consultation_count,
       consultation_pay_suc_amount,
       consultation_pay_suc_count,
       prescription_amount,
       prescription_count,
       prescription_pay_suc_amount,
       prescription_pay_suc_count
from ${APP}.ads_age_group_trade_stats
union
select '$do_date' dt,
       consul.recent_days,
       consul.age_group,
       consultation_amount,
       consultation_count,
       consultation_pay_suc_amount,
       consultation_pay_suc_count,
       prescription_amount,
       prescription_count,
       prescription_pay_suc_amount,
       prescription_pay_suc_count
from (select 1                        recent_days,
             age_group,
             sum(consultation_amount) consultation_amount,
             sum(consultation_count)  consultation_count
      from ${APP}.dws_trade_hospital_gender_age_group_consultation_1d
      where dt = '$do_date'
      group by age_group
      union
      select recent_days,
             age_group,
             sum(if(recent_days = 7, consultation_amount_7d, consultation_amount_30d)) consultation_amount,
             sum(if(recent_days = 7, consultation_count_7d, consultation_count_30d))   consultation_count
      from ${APP}.dws_trade_hospital_gender_age_group_consultation_nd lateral view explode(array(7, 30)) tmp as recent_days
      where dt = '$do_date'
      group by recent_days,
               age_group) consul
         left join
     (select 1                                recent_days,
             age_group,
             sum(consultation_pay_suc_amount) consultation_pay_suc_amount,
             sum(consultation_pay_suc_count)  consultation_pay_suc_count
      from ${APP}.dws_trade_hospital_gender_age_group_consultation_pay_suc_1d
      where dt = '$do_date'
      group by age_group
      union
      select recent_days,
             age_group,
             sum(if(recent_days = 7, consultation_pay_suc_amount_7d,
                    consultation_pay_suc_amount_30d)) consultation_pay_suc_amount,
             sum(if(recent_days = 7, consultation_pay_suc_count_7d,
                    consultation_pay_suc_count_30d))  consultation_pay_suc_count
      from ${APP}.dws_trade_hospital_gender_age_group_consultation_pay_suc_nd lateral view explode(array(7, 30)) tmp as recent_days
      where dt = '$do_date'
      group by recent_days,
               age_group) consul_pay_suc
     on consul.recent_days = consul_pay_suc.recent_days
         and consul.age_group = consul_pay_suc.age_group
         left join
     (select 1                        recent_days,
             age_group,
             sum(prescription_amount) prescription_amount,
             sum(prescription_count)  prescription_count
      from ${APP}.dws_trade_hospital_gender_age_group_prescription_1d
      where dt = '$do_date'
      group by age_group
      union
      select recent_days,
             age_group,
             sum(if(recent_days = 7, prescription_amount_7d, prescription_amount_30d)) prescription_amount,
             sum(if(recent_days = 7, prescription_count_7d, prescription_count_30d))   prescription_count
      from ${APP}.dws_trade_hospital_gender_age_group_prescription_nd lateral view explode(array(7, 30)) tmp as recent_days
      where dt = '$do_date'
      group by recent_days,
               age_group) prescription
     on consul.recent_days = prescription.recent_days
         and consul.age_group = prescription.age_group
         left join
     (select 1                                recent_days,
             age_group,
             sum(prescription_pay_suc_amount) prescription_pay_suc_amount,
             sum(prescription_pay_suc_count)  prescription_pay_suc_count
      from ${APP}.dws_trade_hospital_gender_age_group_prescription_pay_suc_1d
      where dt = '$do_date'
      group by age_group
      union
      select recent_days,
             age_group,
             sum(if(recent_days = 7, prescription_pay_suc_amount_7d,
                    prescription_pay_suc_amount_30d)) prescription_pay_suc_amount,
             sum(if(recent_days = 7, prescription_pay_suc_count_7d,
                    prescription_pay_suc_count_30d))  prescription_pay_suc_count
      from ${APP}.dws_trade_hospital_gender_age_group_prescription_pay_suc_nd lateral view explode(array(7, 30)) tmp as recent_days
      where dt = '$do_date'
      group by recent_days,
               age_group) prescription_pay_suc
     on consul.recent_days = prescription_pay_suc.recent_days
         and consul.age_group = prescription_pay_suc.age_group;
"
ads_doctor_change_stats="
insert overwrite table ${APP}.ads_doctor_change_stats
select dt,
       recent_days,
       new_doctor_count,
       activated_doctor_count,
       active_doctor_count
from ${APP}.ads_doctor_change_stats
union
select '$do_date' dt,
       new.recent_days,
       new_doctor_count,
       activated_doctor_count,
       active_doctor_count
from (select recent_days,
             count(*) new_doctor_count
      from ${APP}.dwd_doctor_register_inc lateral view explode(array(1, 7, 30)) tmp as recent_days
      where dt >= date_add('$do_date', -recent_days + 1)
      group by recent_days) new
         left join
     (select recent_days,
             count(*) activated_doctor_count
      from ${APP}.dws_trade_doctor_consultation_td lateral view explode(array(1, 7, 30)) tmp as recent_days
      where dt = '$do_date'
        and first_consultation_dt >= date_add('$do_date', -recent_days + 1)
      group by recent_days) activated
     on new.recent_days = activated.recent_days
         left join
     (select 1        recent_days,
             count(*) active_doctor_count
      from ${APP}.dws_trade_doctor_consultation_1d
      where dt = '$do_date'
        and consultation_count >= 2
      union
      select recent_days,
             count(*) active_doctor_count
      from ${APP}.dws_trade_doctor_consultation_nd lateral view explode(array(7, 30)) tmp as recent_days
      where dt = '$do_date'
        and ((recent_days = 7 and consultation_count_7d >= 2)
          or (recent_days = 30 and consultation_count_30d >= 2))
      group by recent_days) active
     on new.recent_days = active.recent_days;
"
ads_user_change_stats="
insert overwrite table ${APP}.ads_user_change_stats
select dt,
       recent_days,
       new_user_count,
       new_patient_count
from ${APP}.ads_user_change_stats
union
select '$do_date' dt,
       new_user.recent_days,
       new_user_count,
       new_patient_count
from (select recent_days,
             count(*) new_user_count
      from ${APP}.dwd_user_register_inc lateral view explode(array(1, 7, 30)) tmp as recent_days
      where dt >= date_add('$do_date', -recent_days + 1)
      group by recent_days) new_user
         left join
     (select recent_days,
             count(*) new_patient_count
      from ${APP}.dwd_user_patient_add_inc lateral view explode(array(1, 7, 30)) tmp as recent_days
      where dt >= date_add('$do_date', -recent_days + 1)
      group by recent_days) new_patient
     on new_user.recent_days = new_patient.recent_days;
"
ads_review_stats="
insert overwrite table ${APP}.ads_review_stats
select dt,
       review_user_count,
       review_count,
       good_review_rate
from ${APP}.ads_review_stats
union
select '$do_date' dt,
       review_user_count,
       review_count,
       good_review_rate
from (select count(distinct user_id) review_user_count
      from ${APP}.dws_interaction_hospital_user_review_td
      where dt = '$do_date') user_count
         left join
     (select sum(review_count)                          review_count,
             sum(good_review_count) / sum(review_count) good_review_rate
      from ${APP}.dws_interaction_hospital_review_td
      where dt = '$do_date') review_stats;
"
ads_hospital_review_stats="
insert overwrite table ${APP}.ads_hospital_review_stats
select dt,
       hospital_id,
       hospital_name,
       review_user_count,
       review_count,
       good_review_rate
from ${APP}.ads_hospital_review_stats
union
select '$do_date' dt,
       user_count.hospital_id,
       user_count.hospital_name,
       review_user_count,
       review_count,
       good_review_rate
from (select hospital_id,
             hospital_name,
             count(user_id) review_user_count
      from ${APP}.dws_interaction_hospital_user_review_td
      where dt = '$do_date'
      group by hospital_id,
               hospital_name) user_count
         left join
     (select hospital_id,
             hospital_name,
             review_count,
             good_review_count / review_count good_review_rate
      from ${APP}.dws_interaction_hospital_review_td
      where dt = '$do_date') review_stats
     on user_count.hospital_id = review_stats.hospital_id
         and user_count.hospital_name = review_stats.hospital_name;
"

case $1 in 
    ads_trade_stats | ads_hospital_trade_stats | ads_gender_trade_stats | ads_age_group_trade_stats | ads_doctor_change_stats | ads_user_change_stats | ads_review_stats | ads_hospital_review_stats)
    hive -e "${!1}"
    ;;
    "all")
    hive -e "$ads_trade_stats$ads_hospital_trade_stats$ads_gender_trade_stats$ads_age_group_trade_stats$ads_doctor_change_stats$ads_user_change_stats$ads_review_stats$ads_hospital_review_stats"
    ;;
    "*")
    echo "非法参数!!!"
    ;;
esac

数据装载
medical_dws_to_ads.sh all 2023-05-09
在这里插入图片描述
找个表看一下数据就行。

一、报表数据导出

1.MySQL建库建表

1.创建数据库

CREATE DATABASE IF NOT EXISTS medical_report DEFAULT CHARSET utf8 COLLATE utf8_general_ci;

2.创建表

1.交易综合统计

CREATE TABLE `ads_trade_stats` (
  `dt` date NOT NULL COMMENT '统计日期',
  `recent_days` bigint NOT NULL COMMENT '统计周期: 最近1,7,30日',
  `consultation_amount` decimal(16,2) DEFAULT NULL COMMENT '问诊金额',
  `consultation_count` bigint DEFAULT NULL COMMENT '问诊次数',
  `consultation_pay_suc_amount` decimal(16,2) DEFAULT NULL COMMENT '问诊支付成功金额',
  `consultation_pay_suc_count` bigint DEFAULT NULL COMMENT '问诊支付成功次数',
  `prescription_amount` decimal(16,2) DEFAULT NULL COMMENT '处方金额',
  `prescription_count` bigint DEFAULT NULL COMMENT '处方次数',
  `prescription_pay_suc_amount` decimal(16,2) DEFAULT NULL COMMENT '处方支付成功金额',
  `prescription_pay_suc_count` bigint DEFAULT NULL COMMENT '处方支付成功次数',
  PRIMARY KEY (`dt`,`recent_days`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='交易综合统计';

2.各医院交易统计

CREATE TABLE `ads_hospital_trade_stats` (
  `dt` date NOT NULL COMMENT '统计日期',
  `recent_days` bigint NOT NULL COMMENT '统计周期: 最近1,7,30日',
  `hospital_id` varchar(255) NOT NULL COMMENT '医院ID',
  `hospital_name` varchar(255) NOT NULL COMMENT '医院名称',
  `consultation_amount` decimal(16,2) DEFAULT NULL COMMENT '问诊金额',
  `consultation_count` bigint DEFAULT NULL COMMENT '问诊次数',
  `consultation_pay_suc_amount` decimal(16,2) DEFAULT NULL COMMENT '问诊支付成功金额',
  `consultation_pay_suc_count` bigint DEFAULT NULL COMMENT '问诊支付成功次数',
  `prescription_amount` decimal(16,2) DEFAULT NULL COMMENT '处方金额',
  `prescription_count` bigint DEFAULT NULL COMMENT '处方次数',
  `prescription_pay_suc_amount` decimal(16,2) DEFAULT NULL COMMENT '处方支付成功金额',
  `prescription_pay_suc_count` bigint DEFAULT NULL COMMENT '处方支付成功次数',
  PRIMARY KEY (`dt`,`recent_days`,`hospital_id`,`hospital_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='各医院交易统计';

3.各性别患者交易统计

CREATE TABLE `ads_gender_trade_stats` (
  `dt` date NOT NULL COMMENT '统计日期',
  `recent_days` bigint NOT NULL COMMENT '统计周期: 最近1,7,30日',
  `gender_code` varchar(255) NOT NULL COMMENT '患者性别编码',
  `gender` varchar(255) NOT NULL COMMENT '患者性别',
  `consultation_amount` decimal(16,2) DEFAULT NULL COMMENT '问诊金额',
  `consultation_count` bigint DEFAULT NULL COMMENT '问诊次数',
  `consultation_pay_suc_amount` decimal(16,2) DEFAULT NULL COMMENT '问诊支付成功金额',
  `consultation_pay_suc_count` bigint DEFAULT NULL COMMENT '问诊支付成功次数',
  `prescription_amount` decimal(16,2) DEFAULT NULL COMMENT '处方金额',
  `prescription_count` bigint DEFAULT NULL COMMENT '处方次数',
  `prescription_pay_suc_amount` decimal(16,2) DEFAULT NULL COMMENT '处方支付成功金额',
  `prescription_pay_suc_count` bigint DEFAULT NULL COMMENT '处方支付成功次数',
  PRIMARY KEY (`dt`,`recent_days`,`gender_code`,`gender`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='各性别患者交易统计';

4.各年龄段患者交易统计

CREATE TABLE `ads_age_group_trade_stats` (
  `dt` date NOT NULL COMMENT '统计日期',
  `recent_days` bigint NOT NULL COMMENT '统计周期: 最近1,7,30日',
  `age_group` varchar(255) NOT NULL COMMENT '患者年龄段',
  `consultation_amount` decimal(16,2) DEFAULT NULL COMMENT '问诊金额',
  `consultation_count` bigint DEFAULT NULL COMMENT '问诊次数',
  `consultation_pay_suc_amount` decimal(16,2) DEFAULT NULL COMMENT '问诊支付成功金额',
  `consultation_pay_suc_count` bigint DEFAULT NULL COMMENT '问诊支付成功次数',
  `prescription_amount` decimal(16,2) DEFAULT NULL COMMENT '处方金额',
  `prescription_count` bigint DEFAULT NULL COMMENT '处方次数',
  `prescription_pay_suc_amount` decimal(16,2) DEFAULT NULL COMMENT '处方支付成功金额',
  `prescription_pay_suc_count` bigint DEFAULT NULL COMMENT '处方支付成功次数',
  PRIMARY KEY (`dt`,`recent_days`,`age_group`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='各年龄段患者交易统计';

5.医生变动统计

CREATE TABLE `ads_doctor_change_stats` (
  `dt` date NOT NULL COMMENT '统计日期',
  `recent_days` bigint NOT NULL COMMENT '统计周期: 最近1,7,30日',
  `new_doctor_count` bigint DEFAULT NULL COMMENT '新增医生数',
  `activated_doctor_count` bigint DEFAULT NULL COMMENT '激活医生数',
  `active_doctor_count` bigint DEFAULT NULL COMMENT '活跃医生数',
  PRIMARY KEY (`dt`,`recent_days`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='医生变动统计';

6.用户变动统计

CREATE TABLE `ads_user_change_stats` (
  `dt` date NOT NULL COMMENT '统计日期',
  `recent_days` bigint NOT NULL COMMENT '统计周期: 最近1,7,30日',
  `new_user_count` bigint DEFAULT NULL COMMENT '新增用户数',
  `new_patient_count` bigint DEFAULT NULL COMMENT '新增患者数',
  PRIMARY KEY (`dt`,`recent_days`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='用户变动统计';

7.评价综合统计

CREATE TABLE `ads_review_stats` (
  `dt` date NOT NULL COMMENT '统计日期',
  `review_user_count` bigint DEFAULT NULL COMMENT '评价人数',
  `review_count` bigint DEFAULT NULL COMMENT '评价次数',
  `good_review_rate` decimal(16,2) DEFAULT NULL COMMENT '好评率',
  PRIMARY KEY (`dt`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='用户变动统计';

8.各医院评价统计

CREATE TABLE `ads_hospital_review_stats` (
  `dt` date NOT NULL COMMENT '统计日期',
  `hospital_id` varchar(255) NOT NULL COMMENT '医院ID',
  `hospital_name` varchar(255) NOT NULL COMMENT '医院名称',
  `review_user_count` bigint DEFAULT NULL COMMENT '评价人数',
  `review_count` bigint DEFAULT NULL COMMENT '评价次数',
  `good_review_rate` decimal(16,2) DEFAULT NULL COMMENT '好评率',
  PRIMARY KEY (`dt`,`hospital_id`,`hospital_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='各医院评价统计';

2.数据导出

1.DataX配置文件生成脚本

vim /opt/module/gen_datax_config/configuration.properties
在这里插入图片描述

mysql.username=root
mysql.password=000000
mysql.host=hadoop102
mysql.port=3306
mysql.database.import=medical
# 从HDFS导出进入的 MySQL 数据库名称
mysql.database.export=medical_report
mysql.tables.import=dict,doctor,hospital,medicine,patient,user
# MySQL 库中需要导出的表,空串表示导出库的所有表
mysql.tables.export=
is.seperated.tables=0
hdfs.uri=hdfs://hadoop102:8020
import_out_dir=/opt/module/datax/job/medical/import
# DataX 导出配置文件存放路径
export_out_dir=/opt/module/datax/job/medical/export

2.执行配置文件生成器

java -jar datax-config-generator-1.0-SNAPSHOT-jar-with-dependencies.jar
在这里插入图片描述

3.编写每日导出脚本

vim ~/bin/medical_hdfs_to_mysql.sh

#!/bin/bash

DATAX_HOME=/opt/module/datax

handle_path(){
	for file in `hadoop fs -ls -R $1 | awk '{print $8}'`
	do
		hadoop fs -test -z $file
		if [[ $? -eq 0 ]]
		then 
			echo "文件 $file 大小为零,正在删除..."
			hadoop fs -rm -f -r $file
		fi
	done
}

export_data(){
	export_dir=$1
	datax_config=$2

	echo "正在校验目录 $export_dir ..."
	handle_path $export_dir
	count=`hadoop fs -count $export_dir | awk '{print $2}'`
	if [[ $count -eq 0 ]]
	then 
		echo "目录为空,跳过"
	else
		echo "正在处理目录 $export_dir ..."
		$DATAX_HOME/bin/datax.py -p"-Dexportdir=$export_dir" $datax_config >$DATAX_HOME/job/medical/export.log 2>&1
		if [[ $? -ne 0 ]]
		then 
			echo "执行出错,日志如下 ..."
			cat $DATAX_HOME/job/medical/export.log
		fi
	fi
}

case $1 in
	ads_trade_stats | ads_hospital_trade_stats | ads_gender_trade_stats | ads_age_group_trade_stats | ads_doctor_change_stats | ads_user_change_stats | ads_review_stats | ads_hospital_review_stats)
	export_data /warehouse/medical/ads/$1 $DATAX_HOME/job/medical/export/medical_report.$1.json
	;;
	"all")
	for tab in ads_trade_stats ads_hospital_trade_stats ads_gender_trade_stats ads_age_group_trade_stats ads_doctor_change_stats ads_user_change_stats ads_review_stats ads_hospital_review_stats
	do 
		export_data /warehouse/medical/ads/${tab} $DATAX_HOME/job/medical/export/medical_report.${tab}.json
	done
	;;
	"*")
	echo "非法参数!!!"
	;;
esac

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


总结

数仓开发到这里就结束了。

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

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

相关文章

行业追踪,2023-09-04

自动复盘 2023-09-04 凡所有相,皆是虚妄。若见诸相非相,即见如来。 k 线图是最好的老师,每天持续发布板块的rps排名,追踪板块,板块来开仓,板块去清仓,丢弃自以为是的想法,板块去留让…

实时操作系统Freertos开坑学习笔记:(四):临界段保护、列表与列表项

前言 废话不多说,直接看主要要探究的问题: 一、临界段代码保护 1.什么是临界段? 图里面说,临界区的代码是不能被打断的,它运行时不能被中断打断,也不能由于非阻塞任务延时而切换到其他任务去。 比如说…

【Java转Go】Go中使用WebSocket实现聊天室(私聊+群聊)

目录 前言功能效果(一人分饰多角.jpg😎)用户上线、群聊私聊和留言下线 实现思路代码服务端 chat.go 完整代码客户端 html 完整代码 最后 前言 之前在Java中,用 springbootwebsocket 实现了一个聊天室:springbootwebso…

用BAPI创建销售订单条件价格有多个

说明: 在用BAPI_SALESORDER_CREATEFROMDAT2创建销售订单的时候,业务配置的是Z001自动出来的,我在BAPI条件那块赋值更改标识也是U,但是创建出来的单据还是有两条件类型。 解决方法: LOGIC_SWITCH-PRICING G .即可

AP9193 升压恒流驱动芯片 美容护肤仪 美容灯 锂电池升压驱动IC

AP9193 是一款高效率、高精度的升 压型大功率 LED 灯恒流驱动控制芯片。 应用领域 LED 灯杯 电池供电的 LED 灯串 平板显示 LED 背光 恒流充电器控制 大功率 LED 照明 AP9193 内置高精度误差放大器,固 定关断时间控制电路,恒流驱动电路等&#xff…

签到系统怎么设计

背景 相信签到系统大家都有接触过,更多的是使用。但是有思考过这种系统是怎么设计的吗?比方说我统计一下每个月中每天的签到情况,怎么设计呢?今天一篇文章告诉你。 首先,我们熟悉的思维是:我设计一个数据…

电商平台-业务中台-SPU,SKU,SN概念简介

什么是SPU (Standard Product Unit)? SPU标准属性是商品基本属性,基本属性中最核心两个属性是品牌和型号,电商平台一般采用 品牌和型号 来确定SPU(Standard Product Unit)标准化管理单元, 例如:小米 10 就…

Vue3 el-tooltip 根据内容控制宽度大小换行和并且内容太短不显示

el-tooltip 根据长度自适应换行以及显隐 环境 vue: "3.2.37" element-ui: "2.1.8"要求 tooltip 根据内容自动换行如果内容超出显示省略号显示&#xff0c;不超出不显示 tooltip 代码 组件 // ContentTip 组件 <template><el-tooltipv-bind&qu…

excel中的引用与查找函数篇1

1、COLUMN(reference)&#xff1a;返回与列号对应的数字 2、ROW(reference)&#xff1a;返回与行号对应的数字 参数reference表示引用/参考单元格&#xff0c;输入后引用单元格后colimn()和row()会返回这个单元格对应的列号和行号。若参数reference没有引用单元格&#xff0c;…

SOME/IP TTL 在各种Entry 中各是什么意思?有什么限制?

1 服务发现 SOME/IP SD 服务发现主要用于 定位服务实例检测服务实例状态是否在运行发布/订阅行为管理SOME/IP SD 也是 SOME/IP 消息,遵循 SOME/IP 消息格式,有固定的 Message ID、Request ID 以及 Message Type 等。并对 SOME/IP Payload 进行了详细的定义。 SOME/IP SD …

2023-9-4 快速幂求逆元

题目链接&#xff1a;快速幂求逆元 #include <iostream> #include <algorithm>using namespace std;typedef long long LL;LL qmi(int a, int k, int p) {LL res 1;while(k){if(k & 1) res (LL) res * a % p;k >> 1;a (LL) a * a % p;}return res; }i…

能力和结果之间的关系

大家好,这里是大话硬件。 今天这篇文章想和大家分享前段时间的一点工作体会,关于个人能力和工作结果之间的关系。 其实这些感悟是在上周三晚上下班,走在回家的路上,脑海中突然出现这样的体会,回到家里立马写了下来。因为是即时的灵感,完全是因为工作状态触发,立刻写下…

手写RPC框架--4.服务注册

RPC框架-Gitee代码(麻烦点个Starred, 支持一下吧) RPC框架-GitHub代码(麻烦点个Starred, 支持一下吧) 服务注册 服务注册a.添加服务节点和主机节点b.抽象注册中心c.本地服务列表 服务注册 a.添加服务节点和主机节点 主要完成服务注册和发现的功能&#xff0c;其具体流程如下&…

智能配电室运维云平台

智能配电室运维云平台依托电易云-智慧电力物联网&#xff0c;是通过物联网技术实现配电设备智能化管理和运维的云服务系统。该平台可以实时监测配电设备的运行状态、能耗情况、故障报警等信息&#xff0c;并通过云计算、大数据等技术进行分析和处理&#xff0c;提供精准的数据支…

数据结构前言

一、什么是数据结构&#xff1f; 数据结构是计算机存储、组织数据的方式。数据结构是指相互之间存在一种或多种特定关系的数据元素的集合。 上面是百度百科的定义&#xff0c;通俗的来讲数据结构就是数据元素集合与数据元素集合或者数据元素与数据元素之间的组成形式。 举个…

MyBatisPlus 基础实现(一)

说明 创建一个最基本的MyBatisPlus项目&#xff0c;参考官网。 依赖 MyBatisPlus 依赖&#xff0c;最新版是&#xff1a;3.5.3.2 &#xff08;截止2023-9-4&#xff09;。 <dependency><groupId>com.baomidou</groupId><artifactId>mybatis-plus-bo…

Xcode打包ipa文件,查看app包内文件

1、Xcode发布ipa文件前&#xff0c;在info中打开如下两个选项&#xff0c;即可在手机上查看app包名文件夹下的文件及数据。

基于QWebEngine实现无头浏览器

无头浏览器 无头浏览器&#xff08;Headless Browser&#xff09;是一种没有图形用户界面&#xff08;GUI&#xff09;的浏览器。它通过在内存中渲染页面&#xff0c;然后将结果发送回请求它的用户或程序来实现对网页的访问&#xff0c;而不会在屏幕上显示网页。这种方式使得无…

编译OpenWrt内核驱动

编译OpenWrt内核驱动可以参考OpenWrt内部其它驱动的编写例程&#xff0c;来修改成自己需要的驱动 一、OpenWrt源代码获取与编译 1.1、搭建环境 下载OpenWrt的官方源码&#xff1a; git clone https://github.com/openwrt/openwrt.git1.2、安装编译依赖项 sudo apt update -…

机器人中的数值优化(九)——拟牛顿方法(下)、BB方法

本系列文章主要是我在学习《数值优化》过程中的一些笔记和相关思考&#xff0c;主要的学习资料是深蓝学院的课程《机器人中的数值优化》和高立编著的《数值最优化方法》等&#xff0c;本系列文章篇数较多&#xff0c;不定期更新&#xff0c;上半部分介绍无约束优化&#xff0c;…