未完工数据和系统数据对比分析

2024-06-21 02:52

本文主要是介绍未完工数据和系统数据对比分析,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

select

*

FROM

(

select

a.`db_close_systime` AS a_db_close_systime, -- 订单关闭时间

u.`db_close_systime` AS u_db_close_systime, -- 订单关闭时间

COALESCE( u.`db_close_systime`,a.`db_close_systime`) AS db_close_systime_coalesced ,-- 取非空值的订单关闭时间

a.`inv_code` AS a_inv_code, -- 存货编码

u.`inv_code` AS u_inv_code, -- 存货编码

a.`inv_so_type1` AS a_inv_so_type1, -- 销售一级归类

u.`inv_so_type1` AS u_inv_so_type1, -- 销售一级归类

CASE WHEN a.inv_so_type1 <> u.inv_so_type1 THEN 'Different' ELSE 'Same' END AS inv_so_type1_difference,

a.`order_type` AS a_order_type, -- 销售订单状态

u.`order_type` AS u_order_type, -- 销售订单状态

COALESCE(u.`order_type`, a.`order_type`) AS order_type_coalesced,

a.`so_code_row` AS a_so_code_row, -- 销售子订单编号

u.`so_code_row` AS u_so_code_row, -- 销售子订单编号

a.`so_code` AS a_so_code, -- 销售订单编号

u.`so_code` AS u_so_code, -- 销售订单编号

a.`so_region` AS a_so_region, -- 销售区域

u.`so_region` AS u_so_region, -- 销售区域

CASE

WHEN a.so_region <> u.so_region THEN 'Different'

ELSE 'Same'

END AS region_difference,

a.so_num AS a_so_num,

u.so_num AS u_so_num,

CASE WHEN a.so_num <> u.so_num THEN 'Different' ELSE 'Same' END AS so_num_difference,

a.unfinished_num AS a_unfinished_num, -- 未完工数量

u.unfinished_num AS u_unfinished_num,

CASE WHEN a.unfinished_num <> u.unfinished_num THEN 'Different' ELSE 'Same' END AS unfinished_num_difference,

a.unsold_num AS a_unsold_num,-- 未投单存货数量

u.unsold_num AS u_unsold_num,

CASE WHEN a.unsold_num <> u.unsold_num THEN 'Different' ELSE 'Same' END AS unsold_num_difference,

a.in_num AS a_in_num,-- 累计入库存货数量

u.in_num AS u_in_num,

CASE WHEN a.in_num <> u.in_num THEN 'Different' ELSE 'Same' END AS in_num_difference,

a.in_process AS a_in_process, -- 在制数量

u.in_process AS u_in_process,

CASE WHEN a.in_process <> u.in_process THEN 'Different' ELSE 'Same' END AS in_process_difference,

a.verify_date AS a_verify_date,

u.verify_date AS u_verify_date,

CASE WHEN a.verify_date <> u.verify_date THEN 'Different' ELSE 'Same' END AS verify_date_difference

from

(

SELECT

o.so_code, -- 销售订单号

o.so_code_row,-- 销售子订单号

o.so_region, -- 销售区域

o.pre_month_bt, -- 要货月份

o.verify_date, -- 审核日期

o.st_code, -- 销售类型编码

o.st_name, -- 销售类型名称

o.region, -- 大区

o.order_date, -- 单据日期

o.pre_date, -- 预发货日期

o.inv_so_type1, -- 销售一级归类

o.cus_code, -- 客户编码

o.cus_name, -- 客户名称

o.project, --项目

o.inv_code, -- 存货编码

o.inv_name, -- 存货名称

o.inv_std, -- 产品规格

SUM(COALESCE(o.quantity, 0)) AS so_num, -- 销售订单存货数量

SUM(COALESCE(o.quantity, 0)) - SUM(COALESCE(r.in_num, 0)) AS unfinished_num, -- 未完工数量

SUM(COALESCE(m.in_process, 0)) AS in_process, -- 在制数量

SUM(COALESCE(o.quantity, 0)) - SUM(COALESCE(r.in_num, 0)) - SUM(COALESCE(m.in_process, 0)) AS unsold_num, -- 未投单存货数量

SUM(COALESCE(r.in_num, 0)) AS in_num , -- 累计入库存货数量

case when o.define23 is null and o.db_close_systime is null then '正常'

when o.define23 is null and o.db_close_systime is not null then '异常' else o.define23 end as order_type,

o.db_close_systime,

'2024-06-17' as dt

FROM

(select * from warehouse.dwd_sa_order_details_df where dt = '2024-06-17' and inv_code LIKE '3%'

-- ,'订单取消'

-- 不要备料,取'2022-06-01',不要库存发货

and st_code not in ('10') and substr(cast(verify_date as string),1,10) > '2022-06-01'

and substr(cast(so_code as string),1,2) <> 'BL'

)o

LEFT JOIN

(select so_code,inv_code,so_seq,sum(in_qty) as in_num from warehouse.dwd_wh_inv_in_df

where dt='2024-06-17'

and inv_code like '3%'

and mo_code NOT LIKE '%CX%'

AND mo_code NOT LIKE '%FG%'

group by so_code,inv_code ,so_seq

)r

ON cast(o.so_code as string)=cast(r.so_code as string) and o.inv_code = r.inv_code and so_seq = row_no

left join

(select so_order_detail_id,inv_code,sum(incomplete_num) AS in_process

from warehouse.dwd_pro_order_details_df

where dt = '2024-06-17' and status = 3 and inv_code LIKE '3%'

group by

so_order_detail_id,inv_code

)m

on cast(o.auto_id as string) = cast(m.so_order_detail_id as string) and o.inv_code = m.inv_code

-- where o.db_close_systime is null or o.define23 like '临时失效'

-- OR r.in_num is not null

group by

o.so_code, -- 销售订单号

o.so_code_row,-- 销售子订单号

o.so_region, -- 销售区域

o.pre_month_bt, -- 要货月份

o.verify_date, -- 审核日期

o.st_code, -- 销售类型编码

o.st_name, -- 销售类型名称

o.region, -- 大区

o.order_date, -- 单据日期

o.pre_date, -- 预发货日期

o.inv_so_type1, -- 销售一级归类

o.cus_code, -- 客户编码

o.cus_name, -- 客户名称

o.project, --项目

o.inv_code, -- 存货编码

o.inv_name, -- 存货名称

o.define23 ,

o.db_close_systime,

o.inv_std -- 产品规格

)a

left join warehouse.dws_sa_unfinished_order_amend_df u

on a.so_code_row = u.so_code_row

-- where a.db_close_systime is null and

-- a.unfinished_num >0 and a.so_code is not null and a.so_code_row is not null and a.inv_code is not null

where u.unfinished_num >0 and u.so_code is not null and u.so_code_row is not null and u.inv_code is not null

)T

where T.a_unfinished_num >0 and T.order_type_coalesced = '正常'

and u_order_type is not null

select

distinct verify_state

from warehouse.dwd_sa_order_details_df

这篇关于未完工数据和系统数据对比分析的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1080009

相关文章

MySQL 中查询 VARCHAR 类型 JSON 数据的问题记录

《MySQL中查询VARCHAR类型JSON数据的问题记录》在数据库设计中,有时我们会将JSON数据存储在VARCHAR或TEXT类型字段中,本文将详细介绍如何在MySQL中有效查询存储为V... 目录一、问题背景二、mysql jsON 函数2.1 常用 JSON 函数三、查询示例3.1 基本查询3.2

SpringBatch数据写入实现

《SpringBatch数据写入实现》SpringBatch通过ItemWriter接口及其丰富的实现,提供了强大的数据写入能力,本文主要介绍了SpringBatch数据写入实现,具有一定的参考价值,... 目录python引言一、ItemWriter核心概念二、数据库写入实现三、文件写入实现四、多目标写入

Python 迭代器和生成器概念及场景分析

《Python迭代器和生成器概念及场景分析》yield是Python中实现惰性计算和协程的核心工具,结合send()、throw()、close()等方法,能够构建高效、灵活的数据流和控制流模型,这... 目录迭代器的介绍自定义迭代器省略的迭代器生产器的介绍yield的普通用法yield的高级用法yidle

使用Python将JSON,XML和YAML数据写入Excel文件

《使用Python将JSON,XML和YAML数据写入Excel文件》JSON、XML和YAML作为主流结构化数据格式,因其层次化表达能力和跨平台兼容性,已成为系统间数据交换的通用载体,本文将介绍如何... 目录如何使用python写入数据到Excel工作表用Python导入jsON数据到Excel工作表用

Mysql如何将数据按照年月分组的统计

《Mysql如何将数据按照年月分组的统计》:本文主要介绍Mysql如何将数据按照年月分组的统计方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录mysql将数据按照年月分组的统计要的效果方案总结Mysql将数据按照年月分组的统计要的效果方案① 使用 DA

鸿蒙中Axios数据请求的封装和配置方法

《鸿蒙中Axios数据请求的封装和配置方法》:本文主要介绍鸿蒙中Axios数据请求的封装和配置方法,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友参考下吧... 目录1.配置权限 应用级权限和系统级权限2.配置网络请求的代码3.下载在Entry中 下载AxIOS4.封装Htt

利用Python快速搭建Markdown笔记发布系统

《利用Python快速搭建Markdown笔记发布系统》这篇文章主要为大家详细介绍了使用Python生态的成熟工具,在30分钟内搭建一个支持Markdown渲染、分类标签、全文搜索的私有化知识发布系统... 目录引言:为什么要自建知识博客一、技术选型:极简主义开发栈二、系统架构设计三、核心代码实现(分步解析

C++ Sort函数使用场景分析

《C++Sort函数使用场景分析》sort函数是algorithm库下的一个函数,sort函数是不稳定的,即大小相同的元素在排序后相对顺序可能发生改变,如果某些场景需要保持相同元素间的相对顺序,可使... 目录C++ Sort函数详解一、sort函数调用的两种方式二、sort函数使用场景三、sort函数排序

kotlin中const 和val的区别及使用场景分析

《kotlin中const和val的区别及使用场景分析》在Kotlin中,const和val都是用来声明常量的,但它们的使用场景和功能有所不同,下面给大家介绍kotlin中const和val的区别,... 目录kotlin中const 和val的区别1. val:2. const:二 代码示例1 Java

Python获取中国节假日数据记录入JSON文件

《Python获取中国节假日数据记录入JSON文件》项目系统内置的日历应用为了提升用户体验,特别设置了在调休日期显示“休”的UI图标功能,那么问题是这些调休数据从哪里来呢?我尝试一种更为智能的方法:P... 目录节假日数据获取存入jsON文件节假日数据读取封装完整代码项目系统内置的日历应用为了提升用户体验,