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

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

相关文章

SpringBoot分段处理List集合多线程批量插入数据方式

《SpringBoot分段处理List集合多线程批量插入数据方式》文章介绍如何处理大数据量List批量插入数据库的优化方案:通过拆分List并分配独立线程处理,结合Spring线程池与异步方法提升效率... 目录项目场景解决方案1.实体类2.Mapper3.spring容器注入线程池bejsan对象4.创建

PHP轻松处理千万行数据的方法详解

《PHP轻松处理千万行数据的方法详解》说到处理大数据集,PHP通常不是第一个想到的语言,但如果你曾经需要处理数百万行数据而不让服务器崩溃或内存耗尽,你就会知道PHP用对了工具有多强大,下面小编就... 目录问题的本质php 中的数据流处理:为什么必不可少生成器:内存高效的迭代方式流量控制:避免系统过载一次性

C#实现千万数据秒级导入的代码

《C#实现千万数据秒级导入的代码》在实际开发中excel导入很常见,现代社会中很容易遇到大数据处理业务,所以本文我就给大家分享一下千万数据秒级导入怎么实现,文中有详细的代码示例供大家参考,需要的朋友可... 目录前言一、数据存储二、处理逻辑优化前代码处理逻辑优化后的代码总结前言在实际开发中excel导入很

使用Python实现Word文档的自动化对比方案

《使用Python实现Word文档的自动化对比方案》我们经常需要比较两个Word文档的版本差异,无论是合同修订、论文修改还是代码文档更新,人工比对不仅效率低下,还容易遗漏关键改动,下面通过一个实际案例... 目录引言一、使用python-docx库解析文档结构二、使用difflib进行差异比对三、高级对比方

MyBatis-plus处理存储json数据过程

《MyBatis-plus处理存储json数据过程》文章介绍MyBatis-Plus3.4.21处理对象与集合的差异:对象可用内置Handler配合autoResultMap,集合需自定义处理器继承F... 目录1、如果是对象2、如果需要转换的是List集合总结对象和集合分两种情况处理,目前我用的MP的版本

JWT + 拦截器实现无状态登录系统

《JWT+拦截器实现无状态登录系统》JWT(JSONWebToken)提供了一种无状态的解决方案:用户登录后,服务器返回一个Token,后续请求携带该Token即可完成身份验证,无需服务器存储会话... 目录✅ 引言 一、JWT 是什么? 二、技术选型 三、项目结构 四、核心代码实现4.1 添加依赖(pom

GSON框架下将百度天气JSON数据转JavaBean

《GSON框架下将百度天气JSON数据转JavaBean》这篇文章主要为大家详细介绍了如何在GSON框架下实现将百度天气JSON数据转JavaBean,文中的示例代码讲解详细,感兴趣的小伙伴可以了解下... 目录前言一、百度天气jsON1、请求参数2、返回参数3、属性映射二、GSON属性映射实战1、类对象映

C# LiteDB处理时间序列数据的高性能解决方案

《C#LiteDB处理时间序列数据的高性能解决方案》LiteDB作为.NET生态下的轻量级嵌入式NoSQL数据库,一直是时间序列处理的优选方案,本文将为大家大家简单介绍一下LiteDB处理时间序列数... 目录为什么选择LiteDB处理时间序列数据第一章:LiteDB时间序列数据模型设计1.1 核心设计原则

基于Python实现自动化邮件发送系统的完整指南

《基于Python实现自动化邮件发送系统的完整指南》在现代软件开发和自动化流程中,邮件通知是一个常见且实用的功能,无论是用于发送报告、告警信息还是用户提醒,通过Python实现自动化的邮件发送功能都能... 目录一、前言:二、项目概述三、配置文件 `.env` 解析四、代码结构解析1. 导入模块2. 加载环

linux系统上安装JDK8全过程

《linux系统上安装JDK8全过程》文章介绍安装JDK的必要性及Linux下JDK8的安装步骤,包括卸载旧版本、下载解压、配置环境变量等,强调开发需JDK,运行可选JRE,现JDK已集成JRE... 目录为什么要安装jdk?1.查看linux系统是否有自带的jdk:2.下载jdk压缩包2.解压3.配置环境