企业供应链解决方案

核心流程

业务流程核心定义解读

screenshot-20260616-111828.png

数据资产

dim_equ 设备信息表

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
create external table if not exists dim_equ (
equ_id string comment '设备ID',
equ_no string comment '设备编号',
equ_model_cd string comment '设备型号代码',
equ_model_name string comment '设备型号名称',
equ_brand_cd string comment '设备品牌代码',
equ_brand_name string comment '设备品牌名称',
equ_type_cd string comment '设备类型代码',
equ_type_name string comment '设备类型名称',
equ_spec string comment '设备规格',
unit_name string comment '计量单位名称',
core_part_id string comment '核心部位ID',
nameplate_no string comment '铭牌编号',
motor_no string comment '发动机编号',
mach_no string comment '主机编号',
rels_date date comment '出厂日期',
rgst_date date comment '注册日期',
recv_date date comment '到货日期',
stock_date date comment '入库/接收日期',
acpt_date date comment '验收日期',
equ_use_type_cd string comment '设备使用机制代码:10自有;30转租;50销售',
equ_prop_cd string comment '设备产权代码:10自有;20融资;30外协',
asset_type_cd string comment '资产分类代码:10租赁设备;20辅助租赁设备;30生产性设备',
car_type_cd string comment '车辆类型代码:10服务车;20清障车;30运输车',
car_plate_type_cd string comment '号牌种类代码:1大型 汽车;2小型汽车;51新能源大车;52新能源小车',
equ_stand_cd string comment '设备标准代码:10国标;20美标;30欧标',
equ_new_state_cd string comment '设备新旧状态代码:10新设备 20二手设备',
check_state_cd string comment '验收状态代码:10合格;20让步接收;30待维修',
lock_state_cd string comment '锁机状态代码:0.未锁机;1.已锁机;10.锁机执行中;11.解锁执行中',
is_operate_asset string comment '是否经营性资产:1是 0 否',
is_stop string comment '是否停机待复核:1是 0否',
is_bind_gps string comment '是否绑定GPS:0否;1是',
is_overhaul string comment '是否大修:1是 0否',
sap_main_asset_no string comment 'SAP主资产号',
sap_status_cd string comment 'SAP接口状态 -1:撤销建卡,0:未建卡,1: 已建卡,999:期初',
quality_hour int comment '质保小时数',
quality_dt date comment '质保期截止日',
vendor_cd string comment '供应商代码',
vendor_name string comment '供应商名称',
equ_pur_no string comment '采购订单编号',
equ_notax_price string comment '不含税资产价格',
equ_tax_price string comment '含税资产价格',
accept_ad_no string comment '验收人AD账号',
create_ad_no string comment '创建人AD账号',
create_time timestamp comment '创建时间',
edit_ad_no string comment '更新人AD账号',
edit_time timestamp comment '更新时间',
sys_def_time timestamp comment '系统默认时间',
store_id string comment '设备归属门店ID',
store_cd string comment '设备归属门店代码',
store_name string comment '设备归属门店名称',
store_erp_cd string comment '对应ERP门店代码',
dept_id string comment '事业部ID',
dept_cd string comment '事业部代码',
dept_name string comment '事业部名称',
serv_belg_store_cd string comment '服务归属营业店代码',
serv_belg_store_name string comment '服务归属营业店名称',
serv_belg_whs_cd string comment '服务归属仓库代码',
serv_belg_whs_name string comment '服务归属仓库名称',
network_type_cd string comment '设备所在网点类型代码:1基地;3营业店;4服务驻点;5客户工地;6资产仓;7存货仓;8暂放单;9项目',
network_cd string comment '设备所在网点代码',
network_name string comment '设备所在网点名称',
equ_card_state_cd string comment '设备卡片状态代码:10023待入库;10024已入库;10092已归还;10093待销售;10094已销售;10091已停用;100已废弃',
equ_use_state_cd string comment '设备启用状态代码:10正常(租赁),20已停用(租赁),30已归还(租赁),50正常(销售),60 已停用(销售)',
equ_lease_state_cd string comment '设备租赁状态代码:1110待租;1120订单占用;1121内场工单占用;1140进场中;1150在租;1170退场中;1195停租;9110无效',
equ_position_state_cd string comment '设备位置状态代码 1010在途,1015在库,1020公司基地(非仓库内),1025客户现场(非在租),1030客户现场(在租),1090其他',
equ_repair_state_cd string comment '设备维修状态代码:1260待清洗,1270清洗中,1280待检修,1290检修中,1250待维修,1230维修中,1210正常',
item_id string comment '商品ID',
item_cd string comment '商品代码',
item_name string comment '商品名称',
fty_model_cd string comment '厂家型号编码',
etl_time timestamp comment '数据加载时间',
is_modif_vhc string comment '是否改装车:0否;1是',
is_try_vhc string comment '是否试用车:0否;1是',
try_vhc_use_type_cd string comment '试用车使用类型代码:1长期采购-检查使用;2长期采购-验收使用',
jv_prod_line_cd string comment 'JV产品线代码:10道路,20通用设备,30叉车,40电力,50支护系统,70模架系统,80临建',
year_check_exp_date timestamp comment '年检到期日',
lics_num string comment '牌照号码',
envi_lics_num string comment '环保号牌',
efflut_std string comment '排放标准',
espec_rgst_cd string comment '特种设备注册登记代码',
espec_rgst_status_cd string comment '特种设备注册登记状态:0未知;1使用;2停用;3注销',
espec_rgst_date timestamp comment '特种设备注册登记日期',
espec_use_rgst_no string comment '特种设备使用登记证编号',
is_espec_equ string comment '是否特种设备',
light_asset_vdr_cd string comment '轻资产供应商编码',
light_asset_vdr_name string comment '轻资产供应商名称',
comp_cd string comment '所属公司编号',
comp_name string comment '所属公司名称',
resp_org_cd string comment '所属责任部门编码',
resp_org_name string comment '所属责任部门名称',
resp_person_ad_no string comment '所属责任人AD账号',
resp_person_name string comment '所属责任人姓名',
overhaul_date timestamp comment '大修日期',
recv_mode_cd string comment '接收方式代码:10基地接收入库;20现场接收入库',
check_acpt_ad_no string comment '验收人AD账号',
check_acpt_name string comment '验收人姓名',
notes string comment '备注',
equ_age string comment '设备年限',
rgst_plat_desc string comment '注册平台描述',
asset_prop_type_cd string comment '资产产权类型代码:10:自有, 20:长租(外协), 30:点租(外协)',
fin_name string comment '融资方名称',
fin_no string comment '融资方编号',
main_account_set_code string comment '设备基础-账套信息',
currency_code string comment '币种',
equ_procure_mode string comment '设备采购模式',
license_number string comment '许可证编号',
stained_level string comment '污损等级',
group_currency_equ_notax_price decimal(38, 6) comment '集团本位币-不含税资产价格',
group_currency_equ_tax_price decimal(38, 6) comment '集团本位币-含税资产价格',
is_lower_eff_asset int comment '设备是否低效资产, 1:是 0:否',
fin_asset_belong string comment '资产所属主体_财务卡',
fin_asset_property string comment '资产产权_财务卡',
fin_asset_status string comment '财务资产卡状态',
nominal_purchase_price string comment '名义采购价',
cost_share_lvl int comment '成本分摊层级:10 营业店 20 区域 30 业务部 40 公司',
height string comment '平台高度',
powerresources string comment '动力源',
asset_accounting_store_code string comment '资产核算营业店编码',
asset_accounting_store_name string comment '资产核算营业店名称',
asset_accounting_store_code_saas string comment '资产核算营业店编码-saas编码',
asset_accounting_store_name_saas string comment '资产核算营业店名称-saas名称',
equ_age_fin_caliber int comment '设备年限(财务口径)',
card_type int comment '设备卡片类型: 0:固定资产卡,1:非固定资产卡',
special_work_env string comment '10: 粉刷涂装(涂料), 30: 涉水环境(地铁、隧道、基坑等), 40: 船厂(造船), 50: 船厂(修船), 20: 非特殊作业, 60: 镍矿(工业园区)',
health_level string comment '设备健康度'
) comment '设备信息表' partitioned by (dt string comment '按天分区') ROW FORMAT DELIMITED FIELDS TERMINATED BY '\\u0001' STORED AS PARQUET LOCATION 'hdfs://prd-bd66110-zazk02.hd:8020/apps/hive/warehouse/dwd.db/dim_equ' TBLPROPERTIES (
'comment' = '设备信息表',
'transient_lastDdlTime' = '1778137731',
'bucketing_version' = '2',
'parquet.compression' = 'snappy'
);

ods_so_main_info_df 工单信息主表

常用代码
udf.get_dict_enum_desc(“stg_so_main_info”,”job_type”,job_type) as so_name –工单类型描述

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
create external table if not exists ods_so_main_info_df (
id string comment '主键',
create_time string comment '记录创建时间',
edit_time string comment '记录修改时间',
delete_flag string comment '删除标志位 0 否 1-是',
no string comment '工单编号',
job_type string comment '工单类型 100:"验收派工",110:"清洗工单",200:"保养派工",300:"抢修派工",330:"内场派工",360:"销售设备维修",370:"检修工单",500:"巡检派工",600:"对外维修",700:"出库工单",701:"进场工单",702:"入库工单",703:"退场工单",704:"停租工单",800:"通用外场工单",810:"通用内场工单",900:"运输工单",910:"拣货工单"',
relation_id string comment '上游单据id',
relation_no string comment '上游单据编号',
relation_type string comment '上游单据类型(工单来源单据类型) 0:"手工创建",10:"EIM保养计划",11:"ERP报故单",12:"EIM巡检点计划单",20:"销售订单",21:"ERP采购订单",22:"ERP交机/验收单",23:"ERP对外维修申请",24:"ERP备件及服务销售订单",25:"ERP租赁订单",30:"ERP物流运输单",31:"ERP进场调度单",32:"ERP进场出库单",33:"ERP进场交接单",34:"ERP退场调度单",35:"ERP退场预调度单",36:"ERP退场交接单",37:"ERP',
relation_billdate string comment '上游单据时间,如报故时间',
so_status string comment '工单状态 "草稿";1,"待派工";2,"处理中";3,"已完成";5,"已作废";6,"完工待登记";7,"完成待确认"',
so_desc string comment '工单描述',
create_by string comment '创建人ad账号 0-系统自动建立',
modify_by string comment '最后修改人ad账号 0-人为未修改 ad账号',
org_code string comment '所属事业部id',
org_name string comment '所属事业部名称',
org_dept_code string comment '部门编号',
org_dept_name string comment '所属营业店名称',
dispatcher string comment '派工人ad账号',
dispatcher_name string comment '派工人名称',
relation_so_id string comment '遗留问题生成新工单使用',
relation_so_no string comment '关联工单编号',
remark string comment '备注',
finished_type string comment '工单完成方式 0-正常完成 1-非正常完成',
create_by_name string comment '创建人名称',
modify_by_name string comment '修改人名称',
source_document_type string comment '来源单据类型 0-ERP 1-DMS 2-GDMS 3-PMS 4-GPS 5-OMS 6-EAS',
main_type string comment '工单类别 0-设备,1-材料',
org_service_code string comment '服务组织code',
org_service_name string comment '服务组织名称',
remark2 string comment '对内备注',
relation_bill_timestamp string comment '上游单据时间,如报故时间',
create_timestamp string comment '记录创建时间',
edit_timestamp string comment '记录修改时间',
account_set_code string comment '账套编码'
) comment '工单主表_全量' partitioned by (dt string comment '日期', et string comment '服务') STORED AS PARQUET LOCATION 'hdfs://prd-bd66110-zazk02.hd:8020/apps/hive/warehouse/ods.db/ods_so_main_info_df' TBLPROPERTIES (
'comment' = '工单主表_全量',
'transient_lastDdlTime' = '1740481996',
'bucketing_version' = '2',
'parquet.compression' = 'SNAPPY'
);

用户反馈问题处理

物流业务部台账明细表,系统里面有交接费,但物流台账里是0

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
-- 根据托运单号 查询 托运单uuid cef4d4fe1dd74c52acedb2b7e56d896f
select csg_uuid from dwd.fct_tms_csg_df where csg_no = '26E004345'
-- 根据托运单uuid 查询 结算送货信息uuid a3e70be3205c48f1935a4bb54b3577f8
select demd_uuid,csg_sub_uuid,csg_uuid,crr_head_uuid,stl_dlvr_uuid
from dwd.fct_tms_order_rela_df_add --物流单据关系表
where 1=1 and csg_uuid = '8c393f2db841449cbd72e60c67239469'
group by demd_uuid,csg_sub_uuid,csg_uuid,crr_head_uuid,stl_dlvr_uuid
-- 根据结算送货信息uuid 查询 交接费
with cte_adj as (
select
t1.stl_dlvr_uuid,
t1.csg_no,
t1.csg_uuid,
t1.csg_status,
t2.stl_dlvr_cost_uuid,
case t1.cost_type when '6' then t1.adj_amt else 0 end as fangk_fee , --放空
case t1.cost_type when '39' then t1.adj_amt else 0 end as jud_fee --拒单
from ads.ads_tms_cost_adj_di t1 --物流费用调整明细
left join dwd.fct_tms_stl_dlvr_cost_di t2
on t1.stl_dlvr_uuid = t2.stl_dlvr_uuid and t1.cost_type = t2.cost_type
where t1.cost_type in ('39','6') and t1.csg_status in ('80','0') and t1.task_status = '20'
)
,cte_yzf_yjs as (
select
t2.demd_uuid,t2.csg_sub_uuid,t2.csg_uuid,t2.crr_head_uuid,t2.stl_dlvr_uuid,t1.stl_dlvr_cost_uuid,t1.csg_status,t1.fangk_fee,t1.jud_fee
from cte_adj t1
left join dwd.fct_tms_order_rela_df_add t2
on t1.csg_uuid = t2.csg_uuid and t1.stl_dlvr_uuid = t2.stl_dlvr_uuid
)
select a.stl_dlvr_uuid,b.tax_includ_amt,b.cost_type,c.csg_status
,case when (c.csg_status != '0' or c.csg_status is null) and b.cost_type = '7' then b.tax_includ_amt else 0 end
from dwd.fct_tms_stl_dlvr_di a
join dwd.fct_tms_stl_dlvr_cost_di b
on a.stl_dlvr_uuid = b.stl_dlvr_uuid and b.delete_flag = '0' and b.cost_type not in ('37','1')
left join cte_yzf_yjs c
on b.stl_dlvr_uuid = c.stl_dlvr_uuid and b.stl_dlvr_cost_uuid = c.stl_dlvr_cost_uuid
WHERE a.is_valid = '1' and a.stl_dlvr_uuid = 'a3e70be3205c48f1935a4bb54b3577f8'
  • 产生原因 :
    • 托运单号对应的uuid没有查到结算送货信息uuid,拿不到交接费
    • saas系统入账状态为未入账,回单审核日期为当天,结算送货信息uuid没有生成
  • 解决方案 :
    • 当客户托运单签收后才能产生交接费

设备保内保外故障率统计表 查询 设备在租天数 取值逻辑

提取逻辑步骤
1.定位统计年月、设备编号:SHX-JG134553XG1012HA
2.拆解核心逻辑

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
ads_srv_equ_mon_rent_so_cnt_collect >ads_srv_equ_mon_rent_so_cnt>ads_srv_equ_month_quality_rent
--一些历史数据没有退场时间 下一次的起租时间作为上一次的退场时间
with cre_equinout as (
select
equno,
equ_startrentdate,
equ_exitdate,
row_number() over(partition by equno order by equ_startrentdate ) as rk
from
rpt.rpt_equinout
where equ_startrentdate is not null
)
, cte_all_equinout as (
select
a.equno,
a.equ_startrentdate,
if(a.equ_exitdate = '' or a.equ_exitdate is null,b.equ_startrentdate ,a.equ_exitdate) as equ_exitdate
from
cre_equinout a
left join
cre_equinout b
on a.equno = b.equno and (a.rk+1) = b.rk
)
select
equno,
pos,
val,
rent_start_date,
rent_end_date,
date_format(add_months(rent_start_date, pos),'yyyy-MM-01') as mid_date
from(
select
sre.equno,

substr(sre.equ_startrentdate, 1, 10) as rent_start_date,
substr(nvl(sre.equ_exitdate, '2026-06-11'), 1, 10) as rent_end_date
from cte_all_equinout sre
inner join dwd.dim_equ b on sre.equno = b.equ_no and b.dt = '2026-06-11'
left join dwd.dim_item c on c.item_cd = b.equ_model_cd and c.dt = '2026-06-11' and c.item_class_cd = '1' --设备
left join dwd.dim_accountset_country_currency t11 on t11.dt='2026-06-11' and t11.account_set_code = b.main_account_set_code
where sre.equno = 'SHX-JG134553XG1012HA'
) h lateral view posexplode( split( space( cast(floor( (date_format(rent_end_date,'yyyy') - date_format(rent_start_date,'yyyy')) * 12 + ( date_format(rent_end_date,'MM') - date_format(rent_start_date,'MM'))) as int) ), '' ) ) t as pos, val
where
rent_start_date = '2026-04-26'
--date_format(add_months(rent_start_date, pos),'yyyy-MM-01') = '2026-06-01'
order by rent_start_date desc

3.组合最终结果

1
2
3
4
5
--step1
case when mid_date < rent_start_date then rent_start_date else mid_date end as cur_mon_start
case when add_months(mid_date,1) < rent_end_date then add_months(mid_date,1) else rent_end_date end as cur_mon_end
--step2
SUM(datediff( cur_mon_end, cur_mon_start)) as rent_cnt -- 每月在租天数

设备_设备卡片_序时簿(SAAS) 设备编号:SHX-CD00681LF classic D 400G48/100 B F15这个设备这几个字段不一致 设备启用状态、设备租赁状态、设备位置状态

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
fct_equ_card_dtl>dim_equ>fct_asset_card_status_df>ods_asset_card_status_change_df
select equ_use_state,lease_state,position_state
from ods.ods_asset_card_status_change_df
where dt = '2026-06-14'
and delete_flag = '0'
and asset_code in(
'SHX-CD00681LF classic D 400G48/100 B F15'
,'GHX-DJ00045PCF-350'
,'GHX-0500486NB-500T'
,'GHX-0501028ZX7-400T'
,'GHX-0501030ZX7-400T'
,'THX-8100001750'
,'苏U36Y15'
,'GHX-DJ00047PCF-350'
,'GHX-0500481ZX7-400T'
,'SHX-1700323200T'
,'SHX-1700330200T'
,'SHX-1700339200T'
,'THX-2900012KM9500'
,'苏U162J3'
)