Commit 577b5953 by 宋祥

1.入库数据不对问题修复

parent ca1c5d3a
......@@ -211,14 +211,22 @@
,ifnull(C.CKNUM,0) as "cknum",ifnull(C.RKNUM,0) as "rknum",ifnull(C.PROJ_STATUS,1) as "projStatus"
FROM ${hpjxSchema}.t_hpsc002 A
LEFT JOIN ${hpjxSchema}.t_hpsc005 B on A.ID = B.MAT_ID
LEFT JOIN (select A.COMPANY_CODE,A.PROJ_CODE,A.PRDT_CODE,A.PARENT_PRDT_NAME,sum(ifnull(A.NUM,0)) as JHNUM,sum(ifnull(A.ACTUAL_COMPLETION_NUM,0)) as RKNUM,sum(ifnull(B.AMOUNT,0)) as CKNUM,
LEFT JOIN (select A.COMPANY_CODE,A.PROJ_CODE,A.PRDT_CODE,A.PARENT_PRDT_NAME,
A.LENGTH, A.WIDTH, A.THICK,
sum(ifnull(A.NUM,0)) as JHNUM,sum(ifnull(A.ACTUAL_COMPLETION_NUM,0)) as RKNUM,sum(ifnull(B.AMOUNT,0)) as CKNUM,
case when sum(ifnull(A.NUM,0)) <![CDATA[ <> ]]> sum(ifnull(A.ACTUAL_COMPLETION_NUM,0)) and sum(ifnull(A.NUM,0)) <![CDATA[ <> ]]> sum(ifnull(B.AMOUNT,0)) then 1
when sum(ifnull(A.NUM,0)) = sum(ifnull(A.ACTUAL_COMPLETION_NUM,0)) and sum(ifnull(A.NUM,0)) <![CDATA[ <> ]]> sum(ifnull(B.AMOUNT,0)) then 2
when sum(ifnull(A.NUM,0)) = sum(ifnull(A.ACTUAL_COMPLETION_NUM,0)) and sum(ifnull(A.NUM,0)) = sum(ifnull(B.AMOUNT,0)) then 3 else 0 end as PROJ_STATUS
from ${hpjxSchema}.T_HPSC004 a
left join ${hpjxSchema}.T_HPKC004 b on a.PROJ_CODE = b.PROJ_CODE and a.PRDT_CODE = b.SUB_INVENT_CODE
group by A.COMPANY_CODE,A.PROJ_CODE,A.PRDT_CODE,A.PARENT_PRDT_NAME) C on A.COMPANY_CODE = C.COMPANY_CODE and A.PROJ_CODE = C.PROJ_CODE
and A.PARENT_PRDT_NAME = C.PARENT_PRDT_NAME and A.PRDT_CODE = C.PRDT_CODE
group by A.COMPANY_CODE,A.PROJ_CODE,A.PRDT_CODE,A.PARENT_PRDT_NAME,A.LENGTH, A.WIDTH, A.THICK) C
on A.COMPANY_CODE = C.COMPANY_CODE
and A.PROJ_CODE = C.PROJ_CODE
and A.PARENT_PRDT_NAME = C.PARENT_PRDT_NAME
and A.PRDT_CODE = C.PRDT_CODE
and A.LENGTH = C.LENGTH
and A.WIDTH = C.WIDTH
and A.THICK = C.THICK
WHERE 1=1
AND PARENT_ID NOT IN ('root')
AND DEL_STATUS = 0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment